Skip to content

Commit

Permalink
fix background-false
Browse files Browse the repository at this point in the history
Signed-off-by: ShutingZhao <[email protected]>
  • Loading branch information
realshuting committed Dec 20, 2023
1 parent 357caa7 commit 98c0ae5
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,36 +1,4 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
apiVersion: v1
kind: Namespace
metadata:
annotations:
kyverno.io/kubernetes-version: "1.24"
kyverno.io/kyverno-version: 1.8.0
policies.kyverno.io/category: Pod Security Admission
policies.kyverno.io/description: 'When Pod Security Admission is configured with
a cluster-wide AdmissionConfiguration file which sets either baseline or restricted,
for example in many PaaS CIS profiles, it may be necessary to relax this to
privileged on a per-Namespace basis so that more granular control can be provided.
This policy labels new and existing Namespaces, except that of kube-system,
with the `pod-security.kubernetes.io/enforce: privileged` label. '
policies.kyverno.io/minversion: 1.7.0
policies.kyverno.io/severity: medium
policies.kyverno.io/subject: Namespace
policies.kyverno.io/title: Add Privileged Label to Existing Namespaces
name: add-privileged-existing-namespaces
spec:
background: false
mutateExistingOnPolicyUpdate: true
rules:
- match:
any:
- resources:
kinds:
- Namespace
mutate:
patchStrategicMerge:
metadata:
labels:
foo: bar
targets:
- apiVersion: v1
kind: Namespace
name: label-privileged-namespaces
name: background-false-ns
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
annotations:
kyverno.io/kubernetes-version: "1.24"
kyverno.io/kyverno-version: 1.8.0
policies.kyverno.io/category: Pod Security Admission
policies.kyverno.io/description: 'When Pod Security Admission is configured with
a cluster-wide AdmissionConfiguration file which sets either baseline or restricted,
for example in many PaaS CIS profiles, it may be necessary to relax this to
privileged on a per-Namespace basis so that more granular control can be provided.
This policy labels new and existing Namespaces, except that of kube-system,
with the `pod-security.kubernetes.io/enforce: privileged` label. '
policies.kyverno.io/minversion: 1.7.0
policies.kyverno.io/severity: medium
policies.kyverno.io/subject: Namespace
policies.kyverno.io/title: Add Privileged Label to Existing Namespaces
name: add-privileged-existing-namespaces
spec:
background: false
mutateExistingOnPolicyUpdate: true
rules:
- match:
any:
- resources:
kinds:
- Namespace
names:
- background-false-ns
mutate:
patchStrategicMerge:
metadata:
labels:
foo: bar
targets:
- apiVersion: v1
kind: Namespace
name: background-false-ns
name: label-privileged-namespaces
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v1
kind: Namespace
metadata:
name: background-false-ns
labels:
foo: bar
name: default
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ spec:
try:
- apply:
file: chainsaw-step-01-apply-1-1.yaml
- apply:
file: chainsaw-step-01-apply-1-2.yaml
- assert:
file: chainsaw-step-01-assert-1-1.yaml
- name: step-03
try:
- assert:
file: chainsaw-step-03-assert-1-1.yaml
timeout: 1m30s

0 comments on commit 98c0ae5

Please sign in to comment.