Skip to content

Commit

Permalink
[VDEVOPS-000]: Stickiness support
Browse files Browse the repository at this point in the history
Signed-off-by: adobrodey <[email protected]>
  • Loading branch information
ADobrodey committed Mar 18, 2024
1 parent 51bf42f commit 88a7f01
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
25 changes: 25 additions & 0 deletions stable/deployment/templates/ingress-extra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,31 @@ metadata:
{{- if .Values.ingressExtra.annotations }}
{{- include "k8s-common.tplvalues.render" ( dict "value" .Values.ingressExtra.annotations "context" $ ) | nindent 4 }}
{{- end }}
{{- if gt .Values.ingress.stickiness 0 }}
alb.ingress.kubernetes.io/target-group-attributes: stickiness.enabled=true,stickiness.lb_cookie.duration_seconds={{ .Values.ingress.stickiness }}
alb.ingress.kubernetes.io/actions.weighted-routing: |
{
"type":"forward",
"forwardConfig": {
"targetGroups": [
{
"serviceName": "{{ include "k8s-common.ingress.serviceName" . }}",
"servicePort": "{{ .Values.service.ports.http }}",
}
{{- if .Values.rollouts.enabled }}
,{
"serviceName": "preview-{{ include "k8s-common.ingress.serviceName" . }}",
"servicePort": "{{ .Values.service.ports.http }}",
}
{{- end }}
],
"TargetGroupStickinessConfig": {
"Enabled": true,
"DurationSeconds": {{ .Values.ingress.stickiness }}
}
}
}
{{- end }}

spec:
rules:
Expand Down
32 changes: 31 additions & 1 deletion stable/deployment/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{- if and .Values.ingress.enabled .Values.service.enabled ( eq .Values.service.type "ClusterIP") -}}
{{- $serviceName := ternary "weighted-routing" (include "k8s-common.ingress.serviceName" .) (gt .Values.ingress.stickiness 0) }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
Expand All @@ -9,7 +10,32 @@ metadata:
{{- include "k8s-common.ingress.annotations" . | nindent 4 }}
{{- if .Values.ingress.annotations }}
{{- include "k8s-common.tplvalues.render" ( dict "value" .Values.ingress.annotations "context" $ ) | nindent 4 }}
{{- end }}
{{- end }}
{{- if gt .Values.ingress.stickiness 0 }}
alb.ingress.kubernetes.io/target-group-attributes: stickiness.enabled=true,stickiness.lb_cookie.duration_seconds={{ .Values.ingress.stickiness }}
alb.ingress.kubernetes.io/actions.weighted-routing: |
{
"type":"forward",
"forwardConfig": {
"targetGroups": [
{
"serviceName": "{{ include "k8s-common.ingress.serviceName" . }}",
"servicePort": "{{ .Values.service.ports.http }}",
}
{{- if .Values.rollouts.enabled }}
,{
"serviceName": "preview-{{ include "k8s-common.ingress.serviceName" . }}",
"servicePort": "{{ .Values.service.ports.http }}",
}
{{- end }}
],
"TargetGroupStickinessConfig": {
"Enabled": true,
"DurationSeconds": {{ .Values.ingress.stickiness }}
}
}
}
{{- end }}

spec:
rules:
Expand All @@ -21,11 +47,15 @@ spec:
backend: {{- include "k8s-common.ingress.backend" (dict "serviceName" "ssl-redirect" "servicePort" "use-annotation" "context" $) | nindent 14 }}
- path: {{ .Values.ingress.path }}
pathType: {{ .Values.ingress.pathType }}
{{- if gt .Values.ingress.stickiness 0 }}
backend: {{- include "k8s-common.ingress.backend" (dict "serviceName" "weighted-routing" "servicePort" "use-annotation" "context" $) | nindent 14 }}
{{- else }}
{{- if and (eq .Values.rollouts.strategy "canary") .Values.rollouts.enabled }}
backend: {{- include "k8s-common.ingress.backend" (dict "serviceName" (include "k8s-common.ingress.serviceName" .) "servicePort" "use-annotation" "context" $) | nindent 14 }}
{{- else }}
backend: {{- include "k8s-common.ingress.backend" (dict "serviceName" (include "k8s-common.ingress.serviceName" .) "servicePort" "http" "context" $) | nindent 14 }}
{{- end }}
{{- end }}

{{- if and (eq .Values.rollouts.strategy "blueGreen") .Values.rollouts.enabled }}
- host: preview-{{ include "k8s-common.ingress.host" . }}
Expand Down
3 changes: 3 additions & 0 deletions stable/deployment/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,9 @@ ingress:
## Not recommended to for non-production environments.
##
public: false
## @param ingress.stickiness enable sticky sessions for provided number of seconds
##
stickiness: 0
## @param ingress.subDomain If DNS has environment as sub-domain.
## The default DNS is constructed as:
## <global.serviceName>.[<global.product>.<global.environment>].<global.domain>
Expand Down

0 comments on commit 88a7f01

Please sign in to comment.