Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chart: Deploy PodDisruptionBudget with KEDA. #11032

@@ -1,4 +1,10 @@
{{- if or (and .Values.controller.autoscaling.enabled (gt (.Values.controller.autoscaling.minReplicas | int) 1)) (and (not .Values.controller.autoscaling.enabled) (gt (.Values.controller.replicaCount | int) 1)) }}
{{- $replicas := .Values.controller.replicaCount }}
{{- if .Values.controller.autoscaling.enabled }}
{{- $replicas = .Values.controller.autoscaling.minReplicas }}
{{- else if .Values.controller.keda.enabled }}
{{- $replicas = .Values.controller.keda.minReplicas }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need to add some docs for this?

What if the user enable both by mistake?
Can we try to use the OR instead or that does not work?

/hold for clarification

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, yeah, I get your point. HPA and KEDA being mutually exclusive always was a problem and looking at the particular resource templates, we are not even preventing that in there.

So right now what you see above is pretty close the best we can get without making the conditions too complex and unreadable.

I created an issue for improving and aligning that everywhere. But for now, I'd just go on and merge this PR. Aligning all these conditions is out of scope here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the issue I created: #10814

{{- 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
@@ -0,0 +1,65 @@
suite: Controller > PodDisruptionBudget
templates:
- controller-poddisruptionbudget.yaml

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

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

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

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

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

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