-
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.
* PAAS validations * Add 'role=paas' label for PAAS pods * Validate account and role labels are correct for PAAS pods * Validate PAAS account is valid
- Loading branch information
Showing
14 changed files
with
419 additions
and
4 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,25 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: add-role | ||
spec: | ||
validationFailureAction: Enforce | ||
background: true | ||
rules: | ||
- name: paas-add-role | ||
match: | ||
any: | ||
- resources: | ||
kinds: | ||
- Pod | ||
namespaceSelector: | ||
matchExpressions: | ||
- key: osc.edu/role | ||
operator: In | ||
values: | ||
- paas | ||
mutate: | ||
patchStrategicMerge: | ||
metadata: | ||
labels: | ||
role: paas |
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
26 changes: 26 additions & 0 deletions
26
charts/kyverno-policies/templates/pod-role-validation.yaml
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,26 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: pod-role-validation | ||
spec: | ||
background: false | ||
validationFailureAction: Enforce | ||
rules: | ||
- name: paas-require-role | ||
match: | ||
any: | ||
- resources: | ||
kinds: | ||
- Pod | ||
namespaceSelector: | ||
matchExpressions: | ||
- key: osc.edu/role | ||
operator: In | ||
values: | ||
- paas | ||
validate: | ||
message: "role label must be set to 'paas'" | ||
pattern: | ||
metadata: | ||
labels: | ||
role: "paas" |
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,22 @@ | ||
--- | ||
name: add-role | ||
policies: | ||
- policy.yaml | ||
resources: | ||
- resources.yaml | ||
variables: variables.yaml | ||
results: | ||
- policy: add-role | ||
rule: paas-add-role | ||
resources: | ||
- test-paas | ||
patchedResource: test-paas-mutated.yaml | ||
kind: Pod | ||
result: pass | ||
- policy: add-role | ||
rule: paas-add-role | ||
resources: | ||
- test-skip | ||
- test-skip-webservice | ||
kind: Pod | ||
result: skip |
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,30 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: test-paas | ||
namespace: paas | ||
spec: | ||
containers: | ||
- name: nginx | ||
image: nginx:latest | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: test-skip | ||
namespace: user-test | ||
spec: | ||
containers: | ||
- name: nginx | ||
image: nginx:latest | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: test-skip-webservice | ||
namespace: webservice | ||
spec: | ||
containers: | ||
- name: nginx | ||
image: nginx:latest |
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,12 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: test-paas | ||
namespace: paas | ||
labels: | ||
role: paas | ||
spec: | ||
containers: | ||
- name: nginx | ||
image: nginx:latest |
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,18 @@ | ||
policies: | ||
- name: add-role | ||
rules: | ||
- name: paas-add-role | ||
values: | ||
role: test | ||
namespaceSelector: | ||
- name: user-test | ||
labels: | ||
foo: bar | ||
- name: webservice | ||
labels: | ||
osc.edu/role: webservice | ||
- name: paas | ||
labels: | ||
osc.edu/role: paas | ||
osc.edu/service-account: test | ||
account: test |
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
Oops, something went wrong.