apiVersion: templates.gatekeeper.sh/v1 kind: ConstraintTemplate metadata: name: k8sdisallowinteractivetty annotations: metadata.gatekeeper.sh/title: "Disallow Interactive TTY Containers" metadata.gatekeeper.sh/version: 1.0.0 description: >- Requires that objects have the fields `spec.tty` and `spec.stdin` set to false or unset. spec: crd: spec: names: kind: K8sDisallowInteractiveTTY validation: # Schema for the `parameters` field openAPIV3Schema: type: object description: >- Controls use of fields related to gaining an interactive session. Corresponds to the `tty` and `stdin` fields in the Pod `spec.containers`, `spec.ephemeralContainers`, and `spec.initContainers`. properties: exemptImages: description: >- Any container that uses an image that matches an entry in this list will be excluded from enforcement. Prefix-matching can be signified with `*`. For example: `my-image-*`. It is recommended that users use the fully-qualified Docker image name (e.g. start with a domain name) in order to avoid unexpectedly exempting images from an untrusted repository. type: array items: type: string targets: - target: admission.k8s.gatekeeper.sh rego: | {{ file.Read "src/general/disallowinteractive/src.rego" | strings.Indent 8 | strings.TrimSuffix "\n" }} libs: - | {{ file.Read "src/general/disallowinteractive/lib_exempt_container.rego" | strings.Indent 8 | strings.TrimSuffix "\n" }}