Skip to content

poddisruptionbudget ConstraintTemplate is not working with .spec.minAvailable == .spec.replicas to block pdb #630

@agoel0912

Description

@agoel0912

We are trying to in place the Pod Disruption Budget ConstraintTemplate, following this doc:
https://open-policy-agent.github.io/gatekeeper-library/website/validation/poddisruptionbudget/
But PDB rule is not blocked with the constraint template above when we set .spec.minAvailable == .spec.replicas.

This is my sample pdb template:

`apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: pdb-gatekeeper-dex-eks-sample-test
namespace: eks-sample-app
labels:
app: pdb-gatekeeper-dex-eks-sample-test
owner: akhil
app.kubernetes.io/component: dex-server
app.kubernetes.io/name: pdb-gatekeeper-dex-eks-sample-test
app.kubernetes.io/part-of: gatekeeper
environment: dev-01
app.kubernetes.io/instance: pdb-gatekeeper-dex-eks-sample-test
app.kubernetes.io/version: v1.0
spec:
minAvailable: 1
selector:
matchLabels:
app.kubernetes.io/name: pdb-gatekeeper-dex-eks-sample-test
app.kubernetes.io/instance: pdb-gatekeeper-dex-eks-sample-test

`

`apiVersion: apps/v1
kind: Deployment
metadata:
name: pdb-gatekeeper-dex-eks-sample-test
namespace: eks-sample-app
labels:
owner: akhil
app.kubernetes.io/component: dex-server
app.kubernetes.io/name: pdb-gatekeeper-dex-eks-sample-test
app.kubernetes.io/part-of: gatekeeper
environment: dev-01
app.kubernetes.io/instance: pdb-gatekeeper-dex-eks-sample-test
app.kubernetes.io/version: v1.0
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: pdb-gatekeeper-dex-eks-sample-test
app.kubernetes.io/instance: pdb-gatekeeper-dex-eks-sample-test
template:
metadata:
labels:
app.kubernetes.io/name: pdb-gatekeeper-dex-eks-sample-test
app.kubernetes.io/instance: pdb-gatekeeper-dex-eks-sample-test
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/arch
operator: In
values:
- amd64
- arm64
containers:
- name: nginx
image: public.ecr.aws/nginx/nginx:1.23
ports:
- name: http
containerPort: 80
imagePullPolicy: IfNotPresent
nodeSelector:
kubernetes.io/os: linux

`
Let me know what I am missing, to have this template to block pdb for below match condition?:

  1. Deployment of PodDisruptionBudgets with .spec.minAvailable == .spec.replicas of the resource with replica subresource This will prevent PodDisruptionBudgets from blocking voluntary disruptions such as node draining.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions