Skip to content

PDB example should check labels of pods for evaluation #755

Description

@joyartoun

Regarding https://open-policy-agent.github.io/gatekeeper-library/website/validation/poddisruptionbudget/

When matching labels between a Deployment and a PDB, the pod template labels should be used instead of the Deployment's selector labels. This is more accurate because PDB selectors match pod labels.

- labels := { [label, value] | some label; value := obj.spec.selector.matchLabels[label] }
+ labels := { [label, value] | some label; value := obj.spec.template.metadata.labels[label] }

Reading the official kubernetes documentation, a PDB targets pod labels, not deployments selector labels.

"A label selector .spec.selector to specify the set of pods to which it applies. This field is required."

https://kubernetes.io/docs/tasks/run-application/configure-pdb/#specifying-a-poddisruptionbudget

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions