-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚚 Move constraint templates to the Helm crds directory, for more reli…
…able installs and uninstalls
- Loading branch information
Showing
2 changed files
with
50 additions
and
50 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
apiVersion: templates.gatekeeper.sh/v1beta1 | ||
kind: ConstraintTemplate | ||
metadata: | ||
name: requiredlabels | ||
spec: | ||
crd: | ||
spec: | ||
names: | ||
kind: RequiredLabels | ||
validation: | ||
openAPIV3Schema: | ||
properties: | ||
labels: | ||
type: array | ||
items: string | ||
targets: | ||
- target: admission.k8s.gatekeeper.sh | ||
rego: | | ||
package requiredlabels | ||
violation[{"msg": msg, "details": {"missing_labels": missing}}] { | ||
provided := {label | input.review.object.metadata.labels[label]} | ||
required := {label | label := input.parameters.labels[_]} | ||
missing := required - provided | ||
count(missing) > 0 | ||
msg := sprintf("you must provide labels: %v", [missing]) | ||
} | ||
--- | ||
apiVersion: templates.gatekeeper.sh/v1beta1 | ||
kind: ConstraintTemplate | ||
metadata: | ||
name: deploymentselector | ||
spec: | ||
crd: | ||
spec: | ||
names: | ||
kind: DeploymentSelector | ||
validation: | ||
openAPIV3Schema: | ||
properties: | ||
selector: | ||
type: string | ||
targets: | ||
- target: admission.k8s.gatekeeper.sh | ||
rego: | | ||
package deploymentselector | ||
violation[{"msg": msg, "details": {"missing_selector": missing}}] { | ||
not input.review.object.spec.selector.matchLabels[input.parameters.selector] | ||
missing := input.parameters.selector | ||
msg := sprintf("you must include the deployment label selector: %v", [input.parameters.selector]) | ||
} |
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