Created
July 14, 2023 01:31
-
-
Save aceat64/f34823ffd654d7594e7a34b7987ecdd8 to your computer and use it in GitHub Desktop.
ValidatingAdmissionPolicy to prevent use of :latest or :edge container images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: admissionregistration.k8s.io/v1alpha1 | |
kind: ValidatingAdmissionPolicy | |
metadata: | |
name: "reject-lastest-and-edge" | |
spec: | |
failurePolicy: Fail | |
matchConstraints: | |
resourceRules: | |
- apiGroups: ["apps"] | |
apiVersions: ["v1"] | |
operations: ["CREATE", "UPDATE"] | |
resources: ["deployments"] | |
- apiGroups: ["batch"] | |
apiVersions: ["v1"] | |
operations: ["CREATE", "UPDATE"] | |
resources: ["jobs"] | |
validations: | |
- expression: "object.spec.template.spec.containers.all(c, !c.image.endsWith(':edge'))" | |
message: "containers images can not be :latest tag" | |
- expression: "object.spec.template.spec.containers.all(c, !c.image.endsWith(':edge'))" | |
message: "containers images can not be :edge tag" | |
--- | |
apiVersion: admissionregistration.k8s.io/v1alpha1 | |
kind: ValidatingAdmissionPolicyBinding | |
metadata: | |
name: "reject-lastest-and-edge-binding" | |
spec: | |
policyName: "reject-lastest-and-edge" | |
matchResources: | |
namespaceSelector: {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment