Skip to content

Imperative "kubectl scale deploy busybox --replicas=15" command does NOT prevent scaling as per replicalimit OPA GK Policy #17

Discussion options

You must be logged in to vote

Hi @hikkart! A scale request is updating the replicaset associated with the deployment. You'll want to add a rule that checks UPDATE requests on kind: ReplicaSet and compare the request.object.spec.replicas against request.oldObject.spec.replicas. An example AdmissionReview object changing the number of replicas from 3 to 1 would look something like the one below.

 {
    "apiVersion": "admission.k8s.io/v1",
    "kind": "AdmissionReview",
    "request": {
      "dryRun": false,
      "kind": {
        "group": "apps",
        "kind": "ReplicaSet",
        "version": "v1"
      },
      "name": "allowed-deployment-66b6c48dd5",
      "namespace": "default",
      "object": {
        "apiVers…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@hikkart
Comment options

Answer selected by hikkart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment