Configure sticky session for AWS Network Load Balancer from helm chart

8/26/2020

I'm write helm chart for deploy web service to eks. I need to deploy Load balancer for pods running web application. I'm create service that deploy Network Load Balancer

apiVersion: v1
kind: Service
metadata:
  name: my-service
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-type: "nlb"
spec:
  selector:
    app: "MyApp"
  type: LoadBalancer
  ports:
  - name: http
    port: {{ .Values.app.port }}
    protocol: TCP
    targetPort: {{ .Values.app.port }}

I'm need sticky session for this application.

I'd tried to add sessionAffinity: ClientIP to chart, but this failed. LoadBalancer wont to be created.

Other way LoadBalancer created, but sticky session in Target group still disabled.

What are correct way to configure sticky session for NLB via helm chart?

-- ozlevka
amazon-eks
kubernetes
kubernetes-helm

1 Answer

8/29/2020

This is impossible due to AWS feature sequence.

This feature belongs to TargetGroup of NLB.

When you create LoadBalancer you can't edit attributes of Target group.

After creation attributes of TargetGroup can be modified.

Kubernetes does not implement any annotation to change this flag.

Conclusion: After creating LoadBalancer run awscli script for change sticky session flag.

-- ozlevka
Source: StackOverflow