From dca9803408b171414371498509bcf62cbed1f2aa Mon Sep 17 00:00:00 2001 From: Erik Godding Boye Date: Fri, 3 Nov 2023 14:31:09 +0100 Subject: [PATCH] fix(pdb-minavailable-check): ensure correct handling of 0 replicas workloads (#800) Signed-off-by: Erik Godding Boye --- .../m-q/pdb-minavailable/artifacthub-pkg.yml | 2 +- .../pdb-minavailable/pdb-minavailable.yaml | 3 ++ other/m-q/pdb-minavailable/ss-good.yaml | 32 +++++++++++++++---- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/other/m-q/pdb-minavailable/artifacthub-pkg.yml b/other/m-q/pdb-minavailable/artifacthub-pkg.yml index 57ebaf44d..4ea8874cd 100644 --- a/other/m-q/pdb-minavailable/artifacthub-pkg.yml +++ b/other/m-q/pdb-minavailable/artifacthub-pkg.yml @@ -19,4 +19,4 @@ annotations: kyverno/category: "Other" kyverno/kubernetesVersion: "1.24" kyverno/subject: "PodDisruptionBudget, Deployment, StatefulSet" -digest: bcb87ac5337aad2386c47726f85247202cdbaca62e62a6e96085adaddb7159e7 +digest: f6f12d2b34642666ce110807b85756d86012a840a15f236c53e2a4866347b628 diff --git a/other/m-q/pdb-minavailable/pdb-minavailable.yaml b/other/m-q/pdb-minavailable/pdb-minavailable.yaml index 5427dbf99..ef8c1d896 100644 --- a/other/m-q/pdb-minavailable/pdb-minavailable.yaml +++ b/other/m-q/pdb-minavailable/pdb-minavailable.yaml @@ -32,6 +32,9 @@ spec: value: - CREATE - UPDATE + - key: "{{ request.object.spec.replicas || `1` }}" + operator: GreaterThan + value: 0 context: - name: minavailable apiCall: diff --git a/other/m-q/pdb-minavailable/ss-good.yaml b/other/m-q/pdb-minavailable/ss-good.yaml index 0bcb3a765..a152891da 100644 --- a/other/m-q/pdb-minavailable/ss-good.yaml +++ b/other/m-q/pdb-minavailable/ss-good.yaml @@ -6,12 +6,12 @@ metadata: spec: selector: matchLabels: - app: busybox + app: bb1 replicas: 2 template: metadata: labels: - app: busybox + app: bb1 spec: terminationGracePeriodSeconds: 10 containers: @@ -25,12 +25,12 @@ metadata: spec: selector: matchLabels: - app: busybox + app: bb2 replicas: 1 template: metadata: labels: - app: busybox + app: bb2 spec: terminationGracePeriodSeconds: 10 containers: @@ -45,12 +45,32 @@ metadata: spec: selector: matchLabels: - app: bb + app: bb3 replicas: 1 template: metadata: labels: - app: bb + app: bb3 + spec: + terminationGracePeriodSeconds: 10 + containers: + - name: busbyox + image: busybox:1.35 +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: goodss04 + namespace: pdb-minavailable-ns +spec: + selector: + matchLabels: + app: bb4 + replicas: 0 + template: + metadata: + labels: + app: bb4 spec: terminationGracePeriodSeconds: 10 containers: