-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Fredrik Klingenberg <[email protected]>
- Loading branch information
Showing
5 changed files
with
68 additions
and
3 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
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,11 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
namespace: demo-pods | ||
labels: | ||
run: failing-demo | ||
name: failing-demo | ||
spec: | ||
containers: | ||
- image: nginx | ||
name: failing-demo |
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,4 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: demo-pods |
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,31 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: require-labels | ||
annotations: | ||
policies.kyverno.io/title: Require Labels | ||
policies.kyverno.io/category: Best Practices | ||
policies.kyverno.io/minversion: 1.6.0 | ||
policies.kyverno.io/severity: medium | ||
policies.kyverno.io/subject: Pod, Label | ||
policies.kyverno.io/description: >- | ||
Define and use labels that identify semantic attributes of your application or Deployment. | ||
A common set of labels allows tools to work collaboratively, describing objects in a common manner that | ||
all tools can understand. The recommended labels describe applications in a way that can be | ||
queried. This policy validates that the label `app.kubernetes.io/name` is specified with some value. | ||
spec: | ||
validationFailureAction: Enforce | ||
background: true | ||
rules: | ||
- name: check-for-labels | ||
match: | ||
any: | ||
- resources: | ||
kinds: | ||
- Pod | ||
validate: | ||
message: "The label `tech-lead` is required." | ||
pattern: | ||
metadata: | ||
labels: | ||
tech-lead: "?*" |