forked from anishnath/kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
validating-webhook.yaml
33 lines (32 loc) · 994 Bytes
/
validating-webhook.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
KUBE_CA=$(kubectl config view --minify=true --flatten -o json | jq '.clusters[0].cluster."certificate-authority-data"' -r)
cat > validating-webhook.yaml <<EOF
apiVersion: admissionregistration.k8s.io/v1beta1
kind: ValidatingWebhookConfiguration
metadata:
name: anchore-admmission-anchore-admission-controller.admission.anchore.io
webhooks:
- name: anchore-admmission-anchore-admission-controller.admission.anchore.io
clientConfig:
service:
namespace: default
name: kubernetes
path: /apis/admission.anchore.io/v1beta1/imagechecks
caBundle: $KUBE_CA
rules:
- operations:
- CREATE
apiGroups:
- ""
apiVersions:
- "*"
resources:
- pods
failurePolicy: Fail
# Uncomment this and customize to exclude specific namespaces from the validation requirement
# namespaceSelector:
# matchExpressions:
# - key: exclude.admission.anchore.io
# operator: NotIn
# values: ["true"]
EOF
kubectl apply -f validating-webhook.yaml