Skip to content

Commit a71b801

Browse files
kishorjTimothy-Dougherty
authored andcommitted
add readiness gate documentation (kubernetes-sigs#1551)
1 parent 3f046e0 commit a71b801

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Pod readiness gate
2+
3+
AWS Load Balancer controller supports [»Pod readiness gates«](https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-readiness-gate) to indicate that pod is registered to the ALB/NLB and healthy to receive traffic.
4+
The controller automatically injects the necessary readiness gate configuration to the pod spec via mutating webhook during pod creation.
5+
For readiness gate configuration to be injected to the pod spec, you need to apply the label `elbv2.k8s.aws/pod-readiness-gate-inject: enabled` to the pod namespace.
6+
7+
The pod readiness gate is needed under certain circumstances to achieve full zero downtime rolling deployments. Consider the following example:
8+
9+
* Low number of replicas in a deployment
10+
* Start a rolling update of the deployment
11+
* Rollout of new pods takes less time than it takes the AWS Load Balancer controller to register the new pods and for their health state turn »Healthy« in the target group
12+
* At some point during this rolling update, the target group might only have registered targets that are in »Initial« or »Draining« state; this results in service outage
13+
14+
In order to avoid this situation, the AWS Load Balancer controller can set the readiness condition on the pods that constitute your ingress or service backend. The condition status on a pod will be set to `True` only when the corresponding target in the ALB/NLB target group shows a health state of »Healthy«.
15+
This prevents the rolling update of a deployment from terminating old pods until the newly created pods are »Healthy« in the ALB/NLB target group and ready to take traffic.
16+
17+
!!!note "upgrading from AWS ALB ingress controller"
18+
If you have a pod spec with legacy readiness gate configuration, ensure you label the namespace and create the Service/Ingress objects before applying the pod/deployment manifest.
19+
The load balancer controller will remove all legacy readiness-gate configuration and add new ones during pod creation.
20+
21+
## Configuration
22+
Pod readiness gate support is enabled by default on the AWS load balancer controller. You need to apply the readiness gate inject label to each of the namespace that you would
23+
like to use this feature. You can create and label a namespace as follows -
24+
25+
```shell script
26+
$ kubectl create namespace readiness
27+
namespace/readiness created
28+
29+
$ kubectl label namespace readiness elbv2.k8s.aws/pod-readiness-gate-inject=enabled
30+
namespace/readiness labeled
31+
32+
$ kubectl describe namespace readiness
33+
Name: readiness
34+
Labels: elbv2.k8s.aws/pod-readiness-gate-inject=enabled
35+
Annotations: <none>
36+
Status: Active
37+
```
38+
Once labelled, the controller will add the pod readiness gates config to all the pods created subsequently that meet all the following conditions
39+
* There exists a service matching the pod labels in the same namespace
40+
* There exists at least one target group binding that refers to the matching service
41+
* The target type is IP
42+
43+
The readiness gates have the prefix `target-health.elbv2.k8s.aws` and the controller injects the config to the pod spec only during pod creation.
44+
45+
!!!tip "create ingress or service before pod"
46+
To ensure all of your pods in a namespace get the readiness gate config, you need create your Ingress or Service and label the namespace before creating the pods
47+
48+
## Upgrading from AWS ALB Ingress controller
49+
If you have a pod spec with the AWS ALB ingress controller (aka v1) style readiness-gate configuration, the controller will automatically remove the legacy readiness gates config and add new ones during pod creation if the pod namespace is labelled correctly. Other than the namespace labeling, no further configuration is necessary.
50+
The legacy readiness gates have the `target-health.alb.ingress.k8s.aws` prefix.
51+
52+
## Disabling the readiness gate inject
53+
You can specify the controller flag `--enable-pod-readiness-gate-inject=false` during controller startup to disable the controller from modifying the pod spec.
54+
55+
## Checking the pod condition status
56+
57+
The status of the readiness gates can be verified with `kubectl get pod -o wide`:
58+
```
59+
NAME READY STATUS RESTARTS AGE IP NODE READINESS GATES
60+
nginx-test-5744b9ff84-7ftl9 1/1 Running 0 81s 10.1.2.3 ip-10-1-2-3.ec2.internal 0/1
61+
```
62+
63+
When the target is registered and healthy in the ALB/NLB, the output will look like:
64+
```
65+
NAME READY STATUS RESTARTS AGE IP NODE READINESS GATES
66+
nginx-test-5744b9ff84-7ftl9 1/1 Running 0 81s 10.1.2.3 ip-10-1-2-3.ec2.internal 1/1
67+
```
68+
69+
If a readiness gate doesn't get ready, you can check the reason via:
70+
71+
```console
72+
$ kubectl get pod nginx-test-545d8f4d89-l7rcl -o yaml | grep -B7 'type: target-health'
73+
status:
74+
conditions:
75+
- lastProbeTime: null
76+
lastTransitionTime: null
77+
message: Initial health checks in progress
78+
reason: Elb.InitialHealthChecking
79+
status: "True"
80+
type: target-health.elbv2.k8s.aws/k8s-readines-perf1000-7848e5026b
81+
```

0 commit comments

Comments
 (0)