Annotations - AWS Load Balancer Controller (original) (raw)

Ingress annotations

You can add annotations to kubernetes Ingress and Service objects to customize their behavior.

Name Type Default Location MergeBehavior
alb.ingress.kubernetes.io/load-balancer-name string N/A Ingress Exclusive
alb.ingress.kubernetes.io/group.name string N/A Ingress N/A
alb.ingress.kubernetes.io/group.order integer 0 Ingress N/A
alb.ingress.kubernetes.io/tags stringMap N/A Ingress,Service Merge
alb.ingress.kubernetes.io/ip-address-type ipv4 | dualstack dualstack-without-public-ipv4 ipv4 Ingress Exclusive
alb.ingress.kubernetes.io/scheme internal | internet-facing internal Ingress Exclusive
alb.ingress.kubernetes.io/subnets stringList N/A Ingress Exclusive
alb.ingress.kubernetes.io/security-groups stringList N/A Ingress Exclusive
alb.ingress.kubernetes.io/manage-backend-security-group-rules boolean N/A Ingress Exclusive
alb.ingress.kubernetes.io/customer-owned-ipv4-pool string N/A Ingress Exclusive
alb.ingress.kubernetes.io/load-balancer-attributes stringMap N/A Ingress Exclusive
alb.ingress.kubernetes.io/wafv2-acl-arn string N/A Ingress Exclusive
alb.ingress.kubernetes.io/waf-acl-id string N/A Ingress Exclusive
alb.ingress.kubernetes.io/shield-advanced-protection boolean N/A Ingress Exclusive
alb.ingress.kubernetes.io/listen-ports json '[{"HTTP": 80}]' | '[{"HTTPS": 443}]' Ingress Merge
alb.ingress.kubernetes.io/ssl-redirect integer N/A Ingress Exclusive
alb.ingress.kubernetes.io/inbound-cidrs stringList 0.0.0.0/0, ::/0 Ingress Exclusive
alb.ingress.kubernetes.io/security-group-prefix-lists stringList pl-00000000, pl-1111111 Ingress Exclusive
alb.ingress.kubernetes.io/certificate-arn stringList N/A Ingress Merge
alb.ingress.kubernetes.io/ssl-policy string ELBSecurityPolicy-2016-08 Ingress Exclusive
alb.ingress.kubernetes.io/target-type instance | ip instance Ingress,Service N/A
alb.ingress.kubernetes.io/backend-protocol HTTP | HTTPS HTTP Ingress,Service N/A
alb.ingress.kubernetes.io/backend-protocol-version string HTTP1 Ingress,Service N/A
alb.ingress.kubernetes.io/target-group-attributes stringMap N/A Ingress,Service N/A
alb.ingress.kubernetes.io/healthcheck-port integer | traffic-port traffic-port Ingress,Service N/A
alb.ingress.kubernetes.io/healthcheck-protocol HTTP | HTTPS HTTP Ingress,Service N/A
alb.ingress.kubernetes.io/healthcheck-path string / | /AWS.ALB/healthcheck Ingress,Service N/A
alb.ingress.kubernetes.io/healthcheck-interval-seconds integer '15' Ingress,Service N/A
alb.ingress.kubernetes.io/healthcheck-timeout-seconds integer '5' Ingress,Service N/A
alb.ingress.kubernetes.io/healthy-threshold-count integer '2' Ingress,Service N/A
alb.ingress.kubernetes.io/unhealthy-threshold-count integer '2' Ingress,Service N/A
alb.ingress.kubernetes.io/success-codes string '200' | '12' Ingress,Service N/A
alb.ingress.kubernetes.io/auth-type none|oidc cognito none Ingress,Service N/A
alb.ingress.kubernetes.io/auth-idp-cognito json N/A Ingress,Service N/A
alb.ingress.kubernetes.io/auth-idp-oidc json N/A Ingress,Service N/A
alb.ingress.kubernetes.io/auth-on-unauthenticated-request authenticate|allow deny authenticate Ingress,Service N/A
alb.ingress.kubernetes.io/auth-scope string openid Ingress,Service N/A
alb.ingress.kubernetes.io/auth-session-cookie string AWSELBAuthSessionCookie Ingress,Service N/A
alb.ingress.kubernetes.io/auth-session-timeout integer '604800' Ingress,Service N/A
alb.ingress.kubernetes.io/actions.${action-name} json N/A Ingress N/A
alb.ingress.kubernetes.io/conditions.${conditions-name} json N/A Ingress N/A
alb.ingress.kubernetes.io/target-node-labels stringMap N/A Ingress,Service N/A
alb.ingress.kubernetes.io/mutual-authentication json N/A Ingress Exclusive

IngressGroup

IngressGroup feature enables you to group multiple Ingress resources together. The controller will automatically merge Ingress rules for all Ingresses within IngressGroup and support them with a single ALB. In addition, most annotations defined on an Ingress only apply to the paths defined by that Ingress.

By default, Ingresses don't belong to any IngressGroup, and we treat it as a "implicit IngressGroup" consisting of the Ingress itself.

Traffic Listening

Traffic Listening can be controlled with the following annotations:

Traffic Routing

Traffic Routing can be controlled with following annotations:

spec:
ingressClassName: alb
rules:
- http:
paths:
- path: /503
pathType: Exact
backend:
service:
name: response-503
port:
name: use-annotation
- path: /eks
pathType: Exact
backend:
service:
name: redirect-to-eks
port:
name: use-annotation
- path: /path1
pathType: Exact
backend:
service:
name: forward-single-tg
port:
name: use-annotation
- path: /path2
pathType: Exact
backend:
service:
name: forward-multiple-tg
port:
name: use-annotation
`

apiVersion: networking.k8s.io/v1 kind: Ingress metadata: namespace: default name: ingress annotations: alb.ingress.kubernetes.io/scheme: internet-facing alb.ingress.kubernetes.io/actions.rule-path1: > {"type":"fixed-response","fixedResponseConfig":{"contentType":"text/plain","statusCode":"200","messageBody":"Host is www.example.com OR anno.example.com"}} alb.ingress.kubernetes.io/conditions.rule-path1: > [{"field":"host-header","hostHeaderConfig":{"values":["anno.example.com"]}}] alb.ingress.kubernetes.io/actions.rule-path2: > {"type":"fixed-response","fixedResponseConfig":{"contentType":"text/plain","statusCode":"200","messageBody":"Path is /path2 OR /anno/path2"}} alb.ingress.kubernetes.io/conditions.rule-path2: > [{"field":"path-pattern","pathPatternConfig":{"values":["/anno/path2"]}}] alb.ingress.kubernetes.io/actions.rule-path3: > {"type":"fixed-response","fixedResponseConfig":{"contentType":"text/plain","statusCode":"200","messageBody":"Http header HeaderName is HeaderValue1 OR HeaderValue2"}} alb.ingress.kubernetes.io/conditions.rule-path3: > [{"field":"http-header","httpHeaderConfig":{"httpHeaderName": "HeaderName", "values":["HeaderValue1", "HeaderValue2"]}}] alb.ingress.kubernetes.io/actions.rule-path4: > {"type":"fixed-response","fixedResponseConfig":{"contentType":"text/plain","statusCode":"200","messageBody":"Http request method is GET OR HEAD"}} alb.ingress.kubernetes.io/conditions.rule-path4: > [{"field":"http-request-method","httpRequestMethodConfig":{"Values":["GET", "HEAD"]}}] alb.ingress.kubernetes.io/actions.rule-path5: > {"type":"fixed-response","fixedResponseConfig":{"contentType":"text/plain","statusCode":"200","messageBody":"Query string is paramA:valueA1 OR paramA:valueA2"}} alb.ingress.kubernetes.io/conditions.rule-path5: > [{"field":"query-string","queryStringConfig":{"values":[{"key":"paramA","value":"valueA1"},{"key":"paramA","value":"valueA2"}]}}] alb.ingress.kubernetes.io/actions.rule-path6: > {"type":"fixed-response","fixedResponseConfig":{"contentType":"text/plain","statusCode":"200","messageBody":"Source IP is 192.168.0.0/16 OR 172.16.0.0/16"}} alb.ingress.kubernetes.io/conditions.rule-path6: > [{"field":"source-ip","sourceIpConfig":{"values":["192.168.0.0/16", "172.16.0.0/16"]}}] alb.ingress.kubernetes.io/actions.rule-path7: > {"type":"fixed-response","fixedResponseConfig":{"contentType":"text/plain","statusCode":"200","messageBody":"multiple conditions applies"}} alb.ingress.kubernetes.io/conditions.rule-path7: > [{"field":"http-header","httpHeaderConfig":{"httpHeaderName": "HeaderName", "values":["HeaderValue"]}},{"field":"query-string","queryStringConfig":{"values":[{"key":"paramA","value":"valueA"}]}},{"field":"query-string","queryStringConfig":{"values":[{"key":"paramB","value":"valueB"}]}}] spec: ingressClassName: alb rules: - host: www.example.com http: paths: - path: /path1 pathType: Exact backend: service: name: rule-path1 port: name: use-annotation - path: /path2 pathType: Exact backend: service: name: rule-path2 port: name: use-annotation - path: /path3 pathType: Exact backend: service: name: rule-path3 port: name: use-annotation - path: /path4 pathType: Exact backend: service: name: rule-path4 port: name: use-annotation - path: /path5 pathType: Exact backend: service: name: rule-path5 port: name: use-annotation - path: /path6 pathType: Exact backend: service: name: rule-path6 port: name: use-annotation - path: /path7 pathType: Exact backend: service: name: rule-path7 port: name: use-annotation
Note
If you are using alb.ingress.kubernetes.io/target-group-attributes with stickiness.enabled=true, you should add TargetGroupStickinessConfig under alb.ingress.kubernetes.io/actions.weighted-routing
Example
apiVersion: networking.k8s.io/v1 kind: Ingress metadata: namespace: default name: ingress annotations: alb.ingress.kubernetes.io/scheme: internet-facing alb.ingress.kubernetes.io/target-type: ip alb.ingress.kubernetes.io/target-group-attributes: stickiness.enabled=true,stickiness.lb_cookie.duration_seconds=60 alb.ingress.kubernetes.io/actions.weighted-routing: | { "type":"forward", "forwardConfig":{ "targetGroups":[ { "serviceName":"service-1", "servicePort":"80", "weight":50 }, { "serviceName":"service-2", "servicePort":"80", "weight":50 } ], "TargetGroupStickinessConfig": { "Enabled": true, "DurationSeconds": 120 } } } spec: ingressClassName: alb rules: - host: www.example.com http: paths: - path: / pathType: Prefix backend: service: name: weighted-routing port: name: use-annotation

Access control

Access control for LoadBalancer can be controlled with following annotations:

Authentication

ALB supports authentication with Cognito or OIDC. See Authenticate Users Using an Application Load Balancer for more details.

HTTPS only

Authentication is only supported for HTTPS listeners. See TLS for configuring HTTPS listeners.

Health Check

Health check on target groups can be controlled with following annotations:

TLS

TLS support can be controlled with the following annotations:

Custom attributes

Custom attributes to LoadBalancers and TargetGroups can be controlled with following annotations:

The AWS Load Balancer Controller automatically applies following tags to the AWS resources (ALB/TargetGroups/SecurityGroups/Listener/ListenerRule) it creates:

In addition, you can use annotations to specify additional tags

Addons