Skip to content

Instantly share code, notes, and snippets.

@identw
Created January 31, 2024 22:17
Show Gist options
  • Save identw/a9d9492c843ae85cc46d27cbc1614ca3 to your computer and use it in GitHub Desktop.
Save identw/a9d9492c843ae85cc46d27cbc1614ca3 to your computer and use it in GitHub Desktop.
apiVersion: templates.gatekeeper.sh/v1beta1
kind: ConstraintTemplate
metadata:
name: k8spsphostnamespace
annotations:
description: Controls usage of host namespaces.
spec:
crd:
spec:
names:
kind: K8sPSPHostNamespace
targets:
- target: admission.k8s.gatekeeper.sh
rego: |
package k8spsphostnamespace
violation[{"msg": msg, "details": {}}] {
input_share_hostnamespace(input.review.object)
msg := sprintf("Sharing the host namespace is not allowed: %v", [input.review.object.metadata.name])
}
input_share_hostnamespace(o) {
o.spec.hostPID
}
input_share_hostnamespace(o) {
o.spec.hostIPC
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment