OPA Gatekeeper is not enforcing deployment replicas using oc or kubectl scale

Solution In Progress - Updated -

Issue

  • When I create a policy to limit the maximum number of replicas of a Deployment, oc/kubectl scale is 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.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content