Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SessionAffinity and SessionAffinityConfig fields to ServiceOptions #571

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions api/v1beta1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// +optional
// +optional
// +kubebuilder:default=None
// +kubebuilder:validation:Enum=None,ClientIP

So we can actually put the default, and the enum constraints into the CRD itself using Kubebuilder CRD markers!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, neat code-gen

SessionAffinity string `json:"sessionAffinity,omitempty"`

// +optional
// +kubebuilder:default=None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These (the default and enum lines) were meant to be put up above with sessionAffinity, not sessionAffinityConfig.

// +kubebuilder:validation:Enum=None,ClientIP
SessionAffinityConfig *corev1.SessionAffinityConfig `json:"sessionAffinityConfig,omitempty"`
}

// IngressOptions defines custom options for ingresses
Expand Down
5 changes: 5 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions config/crd/bases/solr.apache.org_solrclouds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions config/crd/bases/solr.apache.org_solrprometheusexporters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions helm/solr-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
88 changes: 88 additions & 0 deletions helm/solr-operator/crds/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions helm/solr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
Expand Down
8 changes: 8 additions & 0 deletions helm/solr/templates/_custom_option_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}

{{/*
Expand Down
2 changes: 2 additions & 0 deletions helm/solr/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,8 @@ statefulSetOptions:
commonServiceOptions:
annotations: {}
labels: {}
sessionAffinity: ""
sessionAffinityConfig: {}

headlessServiceOptions:
annotations: {}
Expand Down