Skip to content

Commit fdeff34

Browse files
authored
Add pod disruption budget for ingress controller (#3248)
1 parent 27973bf commit fdeff34

File tree

5 files changed

+83
-0
lines changed

5 files changed

+83
-0
lines changed

deployments/helm-chart/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,10 @@ Parameter | Description | Default
256256
`controller.autoscaling.maxReplicas` | Maximum number of replicas for the HPA. | 3
257257
`controller.autoscaling.targetCPUUtilizationPercentage` | The target CPU utilization percentage. | 50
258258
`controller.autoscaling.targetMemoryUtilizationPercentage` | The target memory utilization percentage. | 50
259+
`controller.podDisruptionBudget.enabled` | Enables PodDisruptionBudget. | false
260+
`controller.podDisruptionBudget.annotations` | The annotations of the Ingress Controller pod disruption budget | {}
261+
`controller.podDisruptionBudget.minAvailable` | The number of Ingress Controller pods that should be available. This is a mutually exclusive setting with "maxUnavailable". | 0
262+
`controller.podDisruptionBudget.maxUnavailable` | The number of Ingress Controller pods that can be unavailable. This is a mutually exclusive setting with "minAvailable". | 0
259263
`controller.strategy` | Specifies the strategy used to replace old Pods with new ones. Docs for [Deployment update strategy](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy) and [Daemonset update strategy](https://kubernetes.io/docs/tasks/manage-daemon/update-daemon-set/#daemonset-update-strategy) | {}
260264
`controller.disableIPV6` | Disable IPV6 listeners explicitly for nodes that do not support the IPV6 stack. | false
261265
`rbac.create` | Configures RBAC. | true
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{{- if .Values.controller.podDisruptionBudget -}}
2+
apiVersion: policy/v1
3+
kind: PodDisruptionBudget
4+
metadata:
5+
name: {{ include "nginx-ingress.serviceName" . }}
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
{{- include "nginx-ingress.labels" . | nindent 4 }}
9+
{{- if .Values.controller.podDisruptionBudget.annotations }}
10+
annotations:
11+
{{ toYaml .Values.controller.podDisruptionBudget.annotations | indent 4 }}
12+
{{- end }}
13+
spec:
14+
selector:
15+
matchLabels:
16+
app: {{ include "nginx-ingress.appName" . }}
17+
{{- if .Values.controller.podDisruptionBudget.minAvailable }}
18+
minAvailable: {{ .Values.controller.podDisruptionBudget.minAvailable }}
19+
{{- end }}
20+
{{- if .Values.controller.podDisruptionBudget.maxUnavailable }}
21+
maxUnavailable: {{ .Values.controller.podDisruptionBudget.maxUnavailable }}
22+
{{- end }}
23+
{{- end }}

deployments/helm-chart/values.schema.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,6 +1176,41 @@
11761176
"title": "The priorityClassName",
11771177
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.25.4/_definitions.json#/definitions/io.k8s.api.core.v1.PodSpec/properties/priorityClassName"
11781178
},
1179+
"podDisruptionBudget": {
1180+
"type": "object",
1181+
"default": {},
1182+
"title": "The podDisruptionBudget Schema",
1183+
"required": [
1184+
"enabled"
1185+
],
1186+
"properties": {
1187+
"enabled": {
1188+
"type": "boolean"
1189+
},
1190+
"annotations": {
1191+
"type": "object",
1192+
"default": {},
1193+
"title": "The annotations Schema",
1194+
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.25.4/_definitions.json#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta/properties/annotations"
1195+
},
1196+
"minAvailable": {
1197+
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.25.4/_definitions.json#/definitions/io.k8s.api.policy.v1.PodDisruptionBudgetSpec/properties/minAvailable"
1198+
},
1199+
"maxUnavailable": {
1200+
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.25.4/_definitions.json#/definitions/io.k8s.api.policy.v1.PodDisruptionBudgetSpec/properties/maxUnavailable"
1201+
}
1202+
},
1203+
"examples": [
1204+
{
1205+
"enable": true,
1206+
"minAvailable": 1
1207+
},
1208+
{
1209+
"enable": true,
1210+
"maxUnavailable": 1
1211+
}
1212+
]
1213+
},
11791214
"readyStatus": {
11801215
"type": "object",
11811216
"default": {},
@@ -1646,6 +1681,12 @@
16461681
"name": "",
16471682
"imagePullSecretName": ""
16481683
},
1684+
"podDisruptionBudget": {
1685+
"enabled": false,
1686+
"annotations": {},
1687+
"minAvailable": 0,
1688+
"minUnavailable": 0
1689+
},
16491690
"serviceMonitor": {
16501691
"create": false,
16511692
"name": "",

deployments/helm-chart/values.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,17 @@ controller:
179179
## The minimum number of seconds for which a newly created Pod should be ready without any of its containers crashing, for it to be considered available.
180180
minReadySeconds: 0
181181

182+
## Pod disruption budget for the Ingress Controller pods.
183+
podDisruptionBudget:
184+
## Enables PodDisruptionBudget.
185+
enabled: false
186+
## The annotations of the Ingress Controller pod disruption budget.
187+
annotations: {}
188+
## The number of Ingress Controller pods that should be available. This is a mutually exclusive setting with "maxUnavailable".
189+
# minAvailable: 1
190+
## The number of Ingress Controller pods that can be unavailable. This is a mutually exclusive setting with "minAvailable".
191+
# maxUnavailable: 1
192+
182193
## Strategy used to replace old Pods by new ones. .spec.strategy.type can be "Recreate" or "RollingUpdate" for Deployments, and "OnDelete" or "RollingUpdate" for Daemonsets. "RollingUpdate" is the default value.
183194
strategy: {}
184195

docs/content/installation/installation-with-helm.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,10 @@ The following tables lists the configurable parameters of the NGINX Ingress Cont
244244
|``controller.autoscaling.maxReplicas`` | Maximum number of replicas for the HPA. | 3 |
245245
|``controller.autoscaling.targetCPUUtilizationPercentage`` | The target CPU utilization percentage. | 50 |
246246
|``controller.autoscaling.targetMemoryUtilizationPercentage`` | The target memory utilization percentage. | 50 |
247+
|``controller.podDisruptionBudget.enabled`` | Enables PodDisruptionBudget. | false |
248+
|``controller.podDisruptionBudget.annotations`` | The annotations of the Ingress Controller pod disruption budget | {} |
249+
|``controller.podDisruptionBudget.minAvailable`` | The number of Ingress Controller pods that should be available. | 0 |
250+
|``controller.podDisruptionBudget.maxUnavailable`` | The number of Ingress Controller pods that can be unavailable. | 0 |
247251
|``controller.strategy`` | Specifies the strategy used to replace old Pods with new ones. Docs for [Deployment update strategy](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy) and [Daemonset update strategy](https://kubernetes.io/docs/tasks/manage-daemon/update-daemon-set/#daemonset-update-strategy). | {} |
248252
| `controller.disableIPV6` | Disable IPV6 listeners explicitly for nodes that do not support the IPV6 stack. | false |
249253
|``rbac.create`` | Configures RBAC. | true |

0 commit comments

Comments
 (0)