Skip to content

Commit

Permalink
Chart: Align default backend PodDisruptionBudget.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gacko committed Sep 19, 2024
1 parent 9e6c406 commit 58fdc31
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 2 deletions.
2 changes: 1 addition & 1 deletion charts/ingress-nginx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ As of version `1.26.0` of this chart, by simply not providing any clusterIP valu
| defaultBackend.livenessProbe.periodSeconds | int | `10` | |
| defaultBackend.livenessProbe.successThreshold | int | `1` | |
| defaultBackend.livenessProbe.timeoutSeconds | int | `5` | |
| defaultBackend.minAvailable | int | `1` | |
| defaultBackend.minAvailable | int | `1` | Minimum available pods set in PodDisruptionBudget. |
| defaultBackend.minReadySeconds | int | `0` | `minReadySeconds` to avoid killing pods before we are ready # |
| defaultBackend.name | string | `"defaultbackend"` | |
| defaultBackend.networkPolicy.enabled | bool | `false` | Enable 'networkPolicy' or not |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{{- if .Values.defaultBackend.enabled -}}
{{- if or (gt (.Values.defaultBackend.replicaCount | int) 1) (gt (.Values.defaultBackend.autoscaling.minReplicas | int) 1) }}
{{- $replicas := .Values.defaultBackend.replicaCount }}
{{- if .Values.defaultBackend.autoscaling.enabled }}
{{- $replicas = .Values.defaultBackend.autoscaling.minReplicas }}
{{- end }}
{{- if gt ($replicas | int) 1 }}
apiVersion: {{ ternary "policy/v1" "policy/v1beta1" (semverCompare ">=1.21.0-0" .Capabilities.KubeVersion.Version) }}
kind: PodDisruptionBudget
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
suite: Default Backend > PodDisruptionBudget
templates:
- default-backend-poddisruptionbudget.yaml

tests:
- it: should create a PodDisruptionBudget if `defaultBackend.replicaCount` is greater than 1
set:
defaultBackend.enabled: true
defaultBackend.replicaCount: 2
asserts:
- hasDocuments:
count: 1
- isKind:
of: PodDisruptionBudget
- equal:
path: metadata.name
value: RELEASE-NAME-ingress-nginx-defaultbackend

- it: should not create a PodDisruptionBudget if `defaultBackend.replicaCount` is less than or equal 1
set:
defaultBackend.enabled: true
defaultBackend.replicaCount: 1
asserts:
- hasDocuments:
count: 0

- it: should create a PodDisruptionBudget if `defaultBackend.autoscaling.enabled` is true and `defaultBackend.autoscaling.minReplicas` is greater than 1
set:
defaultBackend.enabled: true
defaultBackend.autoscaling.enabled: true
defaultBackend.autoscaling.minReplicas: 2
asserts:
- hasDocuments:
count: 1
- isKind:
of: PodDisruptionBudget
- equal:
path: metadata.name
value: RELEASE-NAME-ingress-nginx-defaultbackend

- it: should not create a PodDisruptionBudget if `defaultBackend.autoscaling.enabled` is true and `defaultBackend.autoscaling.minReplicas` is less than or equal 1
set:
defaultBackend.enabled: true
defaultBackend.autoscaling.enabled: true
defaultBackend.autoscaling.minReplicas: 1
asserts:
- hasDocuments:
count: 0
1 change: 1 addition & 0 deletions charts/ingress-nginx/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,7 @@ defaultBackend:
##
podAnnotations: {}
replicaCount: 1
# -- Minimum available pods set in PodDisruptionBudget.
minAvailable: 1
resources: {}
# limits:
Expand Down

0 comments on commit 58fdc31

Please sign in to comment.