Skip to content

Commit

Permalink
add toggle to adjust failurePolicy of pod webhook and documentations (#…
Browse files Browse the repository at this point in the history
…4063)

the vulcheck failed due to other reasons.
  • Loading branch information
M00nF1sh authored Feb 19, 2025
1 parent 9ab7f9d commit 526b830
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion config/webhook/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ webhooks:
name: webhook-service
namespace: system
path: /mutate-v1-pod
failurePolicy: Fail
failurePolicy: Ignore
name: mpod.elbv2.k8s.aws
rules:
- apiGroups:
Expand Down
15 changes: 15 additions & 0 deletions docs/deploy/pod_readiness_gate.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@ The readiness gates have the prefix `target-health.elbv2.k8s.aws` and the contro
!!!tip "create ingress or service before pod"
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

## FailurePolicy
The `failurePolicy` of a webhook determines how errors, such as unrecognized or timeout errors, are handled by the admission webhook.

* `failurePolicy: Fail`: When applied to a pod mutation webhook, this setting will prevent the launch of any pods in labeled namespaces if the AWSLoadBalancerController pods are unavailable. While this can help avoid incomplete or faulty deployments, it could also delay the cluster's recovery in extreme scenarios, such as an API Server outage.
* `failurePolicy: Ignore`: Setting this policy allows Kubernetes to proceed with pod deployments even if the AWSLoadBalancerController pods are unavailable. This can lead to availability risks for applications since Kubernetes may terminate application pods before the new pods have become healthy in the TargetGroups

To strike a balance between reliability and availability, the default failurePolicy for pod mutation webhooks that inject readiness gates is configured as follows:

* `failurePolicy: Ignore` (for versions > v2.11.0)
* `failurePolicy: Fail` (for versions <= v2.11.0)
You can customize the behavior using Helm chart settings, e.g. `--set podMutatorWebhookConfig.failurePolicy=Fail`

!!!note "Recommended settings"
For optimal reliability & availability, it is recommended to use `failurePolicy: Fail` combined with an explicit [Object Selector](#object-selector)

## Object Selector
The default webhook configuration matches all pods in the namespaces containing the label `elbv2.k8s.aws/pod-readiness-gate-inject=enabled`. You can modify the webhook configuration further
to select specific pods from the labeled namespace by specifying the `objectSelector`. For example, in order to select resources with `elbv2.k8s.aws/pod-readiness-gate-inject: enabled` label,
Expand Down
2 changes: 1 addition & 1 deletion helm/aws-load-balancer-controller/templates/webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ webhooks:
name: {{ template "aws-load-balancer-controller.webhookService" . }}
namespace: {{ $.Release.Namespace }}
path: /mutate-v1-pod
failurePolicy: Ignore
failurePolicy: {{ .Values.podMutatorWebhookConfig.failurePolicy }}
name: mpod.elbv2.k8s.aws
admissionReviewVersions:
- v1beta1
Expand Down
4 changes: 4 additions & 0 deletions helm/aws-load-balancer-controller/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -353,3 +353,7 @@ serviceMutatorWebhookConfig:
operations:
- CREATE
# - UPDATE

podMutatorWebhookConfig:
# whether or not to fail the pod creation if the webhook fails
failurePolicy: Ignore
5 changes: 5 additions & 0 deletions helm/aws-load-balancer-controller/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,11 @@ serviceMutatorWebhookConfig:
- CREATE
# - UPDATE

# podMutatorWebhookConfig contains configurations specific to the service mutator webhook
podMutatorWebhookConfig:
# whether or not to fail the pod creation if the webhook fails
failurePolicy: Ignore

# serviceTargetENISGTags specifies AWS tags, in addition to the cluster tags, for finding the target ENI SG to which to add inbound rules from NLBs.
serviceTargetENISGTags:

Expand Down

0 comments on commit 526b830

Please sign in to comment.