From f0b677b6a5f56f24cf633df30e88d3a5528fb391 Mon Sep 17 00:00:00 2001 From: Trevor Burke Date: Wed, 24 May 2023 16:44:15 -0700 Subject: [PATCH 1/3] Add SessionAffinity and SessionAffinityConfig fields to ServiceOptions --- api/v1beta1/common_types.go | 8 ++ api/v1beta1/zz_generated.deepcopy.go | 1 + .../crd/bases/solr.apache.org_solrclouds.yaml | 66 ++++++++++++++ ...lr.apache.org_solrprometheusexporters.yaml | 22 +++++ helm/solr-operator/crds/crds.yaml | 88 +++++++++++++++++++ 5 files changed, 185 insertions(+) diff --git a/api/v1beta1/common_types.go b/api/v1beta1/common_types.go index b440b900..10b4801c 100644 --- a/api/v1beta1/common_types.go +++ b/api/v1beta1/common_types.go @@ -164,6 +164,14 @@ 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"` + + // sessionAffinityConfig contains the configurations of session affinity. + // +optional + 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..3a8a2dfb 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -611,6 +611,7 @@ func (in *ServiceOptions) DeepCopyInto(out *ServiceOptions) { (*out)[key] = val } } + in.SessionAffinityConfig.DeepCopyInto(&out.SessionAffinityConfig) } // 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/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: From f0319dc7fd7849ad632e614156e6e37df67f7d11 Mon Sep 17 00:00:00 2001 From: Trevor Burke Date: Wed, 31 May 2023 14:59:34 -0700 Subject: [PATCH 2/3] addressing initial feedback --- api/v1beta1/common_types.go | 5 +++-- api/v1beta1/zz_generated.deepcopy.go | 6 +++++- helm/solr-operator/Chart.yaml | 7 +++++++ helm/solr/README.md | 2 ++ helm/solr/templates/_custom_option_helpers.tpl | 8 ++++++++ helm/solr/values.yaml | 2 ++ 6 files changed, 27 insertions(+), 3 deletions(-) diff --git a/api/v1beta1/common_types.go b/api/v1beta1/common_types.go index 10b4801c..a4d4288e 100644 --- a/api/v1beta1/common_types.go +++ b/api/v1beta1/common_types.go @@ -169,9 +169,10 @@ type ServiceOptions struct { // +optional SessionAffinity string `json:"sessionAffinity,omitempty"` - // sessionAffinityConfig contains the configurations of session affinity. // +optional - SessionAffinityConfig corev1.SessionAffinityConfig `json:"sessionAffinityConfig,omitempty"` + // +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 3a8a2dfb..75006f62 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -611,7 +611,11 @@ func (in *ServiceOptions) DeepCopyInto(out *ServiceOptions) { (*out)[key] = val } } - in.SessionAffinityConfig.DeepCopyInto(&out.SessionAffinityConfig) + 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/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/README.md b/helm/solr/README.md index a94fd213..b611d399 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 | | Used to maintain session affinity. Enable client IP based session affinity | +| 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: {} From 17ae4941fe31e462b63ce6fb122f36f11e247c13 Mon Sep 17 00:00:00 2001 From: Houston Putman Date: Fri, 14 Jun 2024 12:16:47 -0400 Subject: [PATCH 3/3] Update helm/solr/README.md --- helm/solr/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/solr/README.md b/helm/solr/README.md index b611d399..b300d309 100644 --- a/helm/solr/README.md +++ b/helm/solr/README.md @@ -300,7 +300,7 @@ 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 | | Used to maintain session affinity. Enable client IP based session affinity | +| 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 |