'Kubernetes - Admission webhook - validate scale operatoin in deployments
I would like to validate deployments based on custom logic before scale. I created an admission webhook to do that, but unfortunately the scale operation is undetected by the webook.
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
name: deployment-validator
webhooks:
- admissionReviewVersions:
- v1
clientConfig:
service:
name: example-name
namespace: example-namespace
path: /validate-deployment
port: 9443
failurePolicy: Ignore
matchPolicy: Equivalent
name: validation.deploy.example-domain.com
namespaceSelector: {}
objectSelector: {}
rules:
- apiGroups:
- apps
apiVersions:
- v1
operations:
- '*'
resources:
- deployment
scope: '*'
sideEffects: None
timeoutSeconds: 10
If I CREATE or UPDATE the deployment, the action is detected by the webhook server, also if I PATCH (kubectl patch ...). Unfortunately if I use kubectl scale ..., the webhook server does not detect the action, and I'm unable to validate the request.
How can I resolve this issue?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
