Created
June 18, 2024 11:51
-
-
Save squeed/54763c7b21e6ce107913fb279239ad30 to your computer and use it in GitHub Desktop.
CEL: require default-allow policies
This file contains hidden or 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/v1 | |
kind: ValidatingAdmissionPolicy | |
metadata: | |
name: "only-allow-ccnp-default-allow" | |
spec: | |
failurePolicy: Fail | |
matchConstraints: | |
resourceRules: | |
- apiGroups: ["cilium.io"] | |
apiVersions: ["v2"] | |
resources: ["ciliumclusterwidenetworkpolicies"] | |
operations: ["CREATE", "UPDATE"] | |
validations: | |
- expression: >- | |
!( has(object.spec.ingress) || has(object.spec.ingressDeny) ) || | |
( has(object.spec.enableDefaultDeny.ingress) && object.spec.enableDefaultDeny.ingress == false) | |
message: "CCNPs must explicitly disallow ingress default-deny" | |
- expression: >- | |
!( has(object.spec.egress) || has(object.spec.egressDeny) ) || | |
( has(object.spec.enableDefaultDeny.egress) && object.spec.enableDefaultDeny.egress == false) | |
message: "CCNPs must explicitly disallow egress default-deny" | |
--- | |
apiVersion: admissionregistration.k8s.io/v1 | |
kind: ValidatingAdmissionPolicyBinding | |
metadata: | |
name: "only-allow-ccnp-default-allow" | |
spec: | |
policyName: "only-allow-ccnp-default-allow" | |
validationActions: [Deny] | |
matchResources: | |
resourceRules: | |
- apiGroups: ["cilium.io"] | |
apiVersions: ["v2"] | |
resources: ["ciliumclusterwidenetworkpolicies"] | |
operations: ["CREATE", "UPDATE"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment