OPA Gatekeeper is not enforcing deployment replicas using oc or kubectl scale
Issue
-
When I create a policy to limit the maximum number of replicas of a Deployment,
oc/kubectl scaleis not working, as it does not enforce a maximum number of replicas. -
I'm using replicalimits template to limit the number of replicas of a deployment, but it's not working. Gatekeeper should reject the scale like this:
$ kubectl scale deployment hello --replicas=3 Error from server ([maxreplicas] Review - Deployment 3 pods is higher than the maximum allowed of 2): admission webhook "validation.gatekeeper.sh" denied the request: [maxreplicas] Review - Deployment 3 pods is higher than the maximum allowed of 2
Environment
- Red Hat Openshift Container Plataform 4.X
- Gatekeeper 0.2.2
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.