Vinyeh's picture
Add pinned source: gatekeeper-library (part 7)
df0899b verified
Raw History Blame Contribute Delete
1.79 kB
apiVersion: templates.gatekeeper.sh/v1
kind: ConstraintTemplate
metadata:
name: k8scontainerlimits
annotations:
metadata.gatekeeper.sh/title: "Container Limits"
metadata.gatekeeper.sh/version: 1.1.0
description: >-
Requires containers to have memory and CPU limits set and constrains
limits to be within the specified maximum values.
https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
spec:
crd:
spec:
names:
kind: K8sContainerLimits
validation:
# Schema for the `parameters` field
openAPIV3Schema:
type: object
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
cpu:
description: "The maximum allowed cpu limit on a Pod, exclusive. Set to -1 to disable."
type: string
memory:
description: "The maximum allowed memory limit on a Pod, exclusive."
type: string
targets:
- target: admission.k8s.gatekeeper.sh
rego: |
{{ file.Read "src/general/containerlimits/src.rego" | strings.Indent 8 | strings.TrimSuffix "\n" }}
libs:
- |
{{ file.Read "src/general/containerlimits/lib_exempt_container.rego" | strings.Indent 10 | strings.TrimSuffix "\n" }}