Initial commit

This commit is contained in:
Joel Kamp
2024-05-23 10:19:55 -05:00
committed by GitHub
commit 3d0519f92a
36 changed files with 1738 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
apiVersion: templates.gatekeeper.sh/v1
kind: ConstraintTemplate
metadata:
name: k8sexternaldatavalidation
spec:
crd:
spec:
names:
kind: K8sExternalDataValidation
targets:
- target: admission.k8s.gatekeeper.sh
rego: |
package k8sexternaldata
violation[{"msg": msg}] {
# build a list of keys containing images
images := [img | img = input.review.object.spec.containers[_].image]
# send external data request
response := external_data({"provider": "external-data-provider", "keys": images})
response_with_error(response)
msg := sprintf("invalid response: %v", [response])
}
response_with_error(response) {
count(response.errors) > 0
errs := response.errors[_]
contains(errs[1], "_invalid")
}
response_with_error(response) {
count(response.system_error) > 0
}

View File

@@ -0,0 +1,10 @@
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: K8sExternalDataValidation
metadata:
name: deny-images-with-invalid-suffix
spec:
enforcementAction: deny
match:
kinds:
- apiGroups: ["*"]
kinds: ["Pod"]