diff --git a/api/v1beta1/common_types.go b/api/v1beta1/common_types.go index b440b900..a4d4288e 100644 --- a/api/v1beta1/common_types.go +++ b/api/v1beta1/common_types.go @@ -164,6 +164,15 @@ type ServiceOptions struct { // Labels to be added for the Service. // +optional Labels map[string]string `json:"labels,omitempty"` + + // Supports "ClientIP" and "None". Used to maintain session affinity. Enable client IP based session affinity. Must be ClientIP or None. Defaults to None + // +optional + SessionAffinity string `json:"sessionAffinity,omitempty"` + + // +optional + // +kubebuilder:default=None + // +kubebuilder:validation:Enum=None,ClientIP + SessionAffinityConfig *corev1.SessionAffinityConfig `json:"sessionAffinityConfig,omitempty"` } // IngressOptions defines custom options for ingresses diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index cc3d0f41..75006f62 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -611,6 +611,11 @@ func (in *ServiceOptions) DeepCopyInto(out *ServiceOptions) { (*out)[key] = val } } + if in.SessionAffinityConfig != nil { + in, out := &in.SessionAffinityConfig, &out.SessionAffinityConfig + *out = new(v1.SessionAffinityConfig) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceOptions. diff --git a/config/crd/bases/solr.apache.org_solrclouds.yaml b/config/crd/bases/solr.apache.org_solrclouds.yaml index cc7aa279..2feb657d 100644 --- a/config/crd/bases/solr.apache.org_solrclouds.yaml +++ b/config/crd/bases/solr.apache.org_solrclouds.yaml @@ -2041,6 +2041,28 @@ spec: type: string description: Labels to be added for the Service. type: object + sessionAffinity: + description: Supports "ClientIP" and "None". Used to maintain + session affinity. Enable client IP based session affinity. + Must be ClientIP or None. Defaults to None + type: string + sessionAffinityConfig: + description: sessionAffinityConfig contains the configurations + of session affinity. + properties: + clientIP: + description: clientIP contains the configurations of Client + IP based session affinity. + properties: + timeoutSeconds: + description: timeoutSeconds specifies the seconds + of ClientIP type session sticky time. The value + must be >0 && <=86400(for 1 day) if ServiceAffinity + == "ClientIP". Default value is 10800(for 3 hours). + format: int32 + type: integer + type: object + type: object type: object configMapOptions: description: ServiceOptions defines the custom options for the @@ -2075,6 +2097,28 @@ spec: type: string description: Labels to be added for the Service. type: object + sessionAffinity: + description: Supports "ClientIP" and "None". Used to maintain + session affinity. Enable client IP based session affinity. + Must be ClientIP or None. Defaults to None + type: string + sessionAffinityConfig: + description: sessionAffinityConfig contains the configurations + of session affinity. + properties: + clientIP: + description: clientIP contains the configurations of Client + IP based session affinity. + properties: + timeoutSeconds: + description: timeoutSeconds specifies the seconds + of ClientIP type session sticky time. The value + must be >0 && <=86400(for 1 day) if ServiceAffinity + == "ClientIP". Default value is 10800(for 3 hours). + format: int32 + type: integer + type: object + type: object type: object ingressOptions: description: IngressOptions defines the custom options for the @@ -2115,6 +2159,28 @@ spec: type: string description: Labels to be added for the Service. type: object + sessionAffinity: + description: Supports "ClientIP" and "None". Used to maintain + session affinity. Enable client IP based session affinity. + Must be ClientIP or None. Defaults to None + type: string + sessionAffinityConfig: + description: sessionAffinityConfig contains the configurations + of session affinity. + properties: + clientIP: + description: clientIP contains the configurations of Client + IP based session affinity. + properties: + timeoutSeconds: + description: timeoutSeconds specifies the seconds + of ClientIP type session sticky time. The value + must be >0 && <=86400(for 1 day) if ServiceAffinity + == "ClientIP". Default value is 10800(for 3 hours). + format: int32 + type: integer + type: object + type: object type: object podOptions: description: SolrPodOptions defines the custom options for solrCloud diff --git a/config/crd/bases/solr.apache.org_solrprometheusexporters.yaml b/config/crd/bases/solr.apache.org_solrprometheusexporters.yaml index ed8d5efc..33673bc8 100644 --- a/config/crd/bases/solr.apache.org_solrprometheusexporters.yaml +++ b/config/crd/bases/solr.apache.org_solrprometheusexporters.yaml @@ -6831,6 +6831,28 @@ spec: type: string description: Labels to be added for the Service. type: object + sessionAffinity: + description: Supports "ClientIP" and "None". Used to maintain + session affinity. Enable client IP based session affinity. + Must be ClientIP or None. Defaults to None + type: string + sessionAffinityConfig: + description: sessionAffinityConfig contains the configurations + of session affinity. + properties: + clientIP: + description: clientIP contains the configurations of Client + IP based session affinity. + properties: + timeoutSeconds: + description: timeoutSeconds specifies the seconds + of ClientIP type session sticky time. The value + must be >0 && <=86400(for 1 day) if ServiceAffinity + == "ClientIP". Default value is 10800(for 3 hours). + format: int32 + type: integer + type: object + type: object type: object type: object exporterEntrypoint: diff --git a/helm/solr-operator/Chart.yaml b/helm/solr-operator/Chart.yaml index 35893b57..74511e88 100644 --- a/helm/solr-operator/Chart.yaml +++ b/helm/solr-operator/Chart.yaml @@ -68,6 +68,13 @@ annotations: url: https://github.com/apache/solr-operator/pull/561 - name: Documentation url: https://apache.github.io/solr-operator/docs/solr-cloud/autoscaling.html + - kind: added + description: Ability to set SessionAffinity and SessionAffinityConfig for Services + links: + - name: GitHub Issue + url: https://github.com/apache/solr-operator/issues/535 + - name: GitHub PR + url: https://github.com/apache/solr-operator/pull/571 artifacthub.io/images: | - name: solr-operator image: apache/solr-operator:v0.8.0-prerelease diff --git a/helm/solr-operator/crds/crds.yaml b/helm/solr-operator/crds/crds.yaml index 922545ad..8781567d 100644 --- a/helm/solr-operator/crds/crds.yaml +++ b/helm/solr-operator/crds/crds.yaml @@ -2290,6 +2290,28 @@ spec: type: string description: Labels to be added for the Service. type: object + sessionAffinity: + description: Supports "ClientIP" and "None". Used to maintain + session affinity. Enable client IP based session affinity. + Must be ClientIP or None. Defaults to None + type: string + sessionAffinityConfig: + description: sessionAffinityConfig contains the configurations + of session affinity. + properties: + clientIP: + description: clientIP contains the configurations of Client + IP based session affinity. + properties: + timeoutSeconds: + description: timeoutSeconds specifies the seconds + of ClientIP type session sticky time. The value + must be >0 && <=86400(for 1 day) if ServiceAffinity + == "ClientIP". Default value is 10800(for 3 hours). + format: int32 + type: integer + type: object + type: object type: object configMapOptions: description: ServiceOptions defines the custom options for the @@ -2324,6 +2346,28 @@ spec: type: string description: Labels to be added for the Service. type: object + sessionAffinity: + description: Supports "ClientIP" and "None". Used to maintain + session affinity. Enable client IP based session affinity. + Must be ClientIP or None. Defaults to None + type: string + sessionAffinityConfig: + description: sessionAffinityConfig contains the configurations + of session affinity. + properties: + clientIP: + description: clientIP contains the configurations of Client + IP based session affinity. + properties: + timeoutSeconds: + description: timeoutSeconds specifies the seconds + of ClientIP type session sticky time. The value + must be >0 && <=86400(for 1 day) if ServiceAffinity + == "ClientIP". Default value is 10800(for 3 hours). + format: int32 + type: integer + type: object + type: object type: object ingressOptions: description: IngressOptions defines the custom options for the @@ -2364,6 +2408,28 @@ spec: type: string description: Labels to be added for the Service. type: object + sessionAffinity: + description: Supports "ClientIP" and "None". Used to maintain + session affinity. Enable client IP based session affinity. + Must be ClientIP or None. Defaults to None + type: string + sessionAffinityConfig: + description: sessionAffinityConfig contains the configurations + of session affinity. + properties: + clientIP: + description: clientIP contains the configurations of Client + IP based session affinity. + properties: + timeoutSeconds: + description: timeoutSeconds specifies the seconds + of ClientIP type session sticky time. The value + must be >0 && <=86400(for 1 day) if ServiceAffinity + == "ClientIP". Default value is 10800(for 3 hours). + format: int32 + type: integer + type: object + type: object type: object podOptions: description: SolrPodOptions defines the custom options for solrCloud @@ -23626,6 +23692,28 @@ spec: type: string description: Labels to be added for the Service. type: object + sessionAffinity: + description: Supports "ClientIP" and "None". Used to maintain + session affinity. Enable client IP based session affinity. + Must be ClientIP or None. Defaults to None + type: string + sessionAffinityConfig: + description: sessionAffinityConfig contains the configurations + of session affinity. + properties: + clientIP: + description: clientIP contains the configurations of Client + IP based session affinity. + properties: + timeoutSeconds: + description: timeoutSeconds specifies the seconds + of ClientIP type session sticky time. The value + must be >0 && <=86400(for 1 day) if ServiceAffinity + == "ClientIP". Default value is 10800(for 3 hours). + format: int32 + type: integer + type: object + type: object type: object type: object exporterEntrypoint: diff --git a/helm/solr/README.md b/helm/solr/README.md index a94fd213..b300d309 100644 --- a/helm/solr/README.md +++ b/helm/solr/README.md @@ -300,6 +300,8 @@ When using the helm chart, omit `customSolrKubeOptions.` | statefulSetOptions.podManagementPolicy | string | `"Parallel"` | Policy for how Solr pods should be managed in the statefulSet, ["OrderedReady" or "Parallel"](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#pod-management-policies) | | commonServiceOptions.annotations | map[string]string | | Custom annotations to add to the Solr common service | | commonServiceOptions.labels | map[string]string | | Custom labels to add to the Solr common service | +| commonServiceOptions.sessionAffinity | string | `"None"` | Choose session affinity to setup for the common service. Available options are "None" and "ClientIP". | +| commonServiceOptions.sessionAffinityConfig | object | | Sets configuration of session affinity | | headlessServiceOptions.annotations | map[string]string | | Custom annotations to add to the Solr headless service | | headlessServiceOptions.labels | map[string]string | | Custom labels to add to the Solr headless service | | nodeServiceOptions.annotations | map[string]string | | Custom annotations to add to the Solr node service(s) | diff --git a/helm/solr/templates/_custom_option_helpers.tpl b/helm/solr/templates/_custom_option_helpers.tpl index d2b9b586..e43eee6f 100644 --- a/helm/solr/templates/_custom_option_helpers.tpl +++ b/helm/solr/templates/_custom_option_helpers.tpl @@ -167,6 +167,14 @@ labels: annotations: {{- toYaml .Values.commonServiceOptions.annotations | nindent 2 }} {{ end }} +{{- if .Values.commonServiceOptions.sessionAffinity -}} +sessionAffinity: + {{- toYaml .Values.commonServiceOptions.sessionAffinity | nindent 2 }} +{{ end }} +{{- if .Values.commonServiceOptions.sessionAffinityConfig -}} +sessionAffinityConfig: + {{- toYaml .Values.commonServiceOptions.sessionAffinityConfig | nindent 2 }} +{{ end }} {{- end -}} {{/* diff --git a/helm/solr/values.yaml b/helm/solr/values.yaml index 8c7501ef..b069b670 100644 --- a/helm/solr/values.yaml +++ b/helm/solr/values.yaml @@ -344,6 +344,8 @@ statefulSetOptions: commonServiceOptions: annotations: {} labels: {} + sessionAffinity: "" + sessionAffinityConfig: {} headlessServiceOptions: annotations: {}