Skip to content

Add SessionAffinity and SessionAffinityConfig fields to ServiceOptions #571

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions api/v1beta1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,10 @@ type ServiceOptions struct {
// +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"`

// sessionAffinityConfig contains the configurations of session affinity.
// +optional
SessionAffinityConfig corev1.SessionAffinityConfig `json:"sessionAffinityConfig,omitempty"`
// +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
6 changes: 5 additions & 1 deletion api/v1beta1/zz_generated.deepcopy.go

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

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
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 | | 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) |
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