1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-07 08:26:53 +00:00
kyverno/test/cli/test-fail/invalid-ns/policy.yaml
Anushka Mittal df4d7ae26c
Broken exclude any all (#2990)
* added check for any/all

Signed-off-by: anushkamittal20 <anumittal4641@gmail.com>

* minor corrections

Signed-off-by: anushkamittal20 <anumittal4641@gmail.com>

* corrected return check for rbac info

Signed-off-by: anushkamittal20 <anumittal4641@gmail.com>

* added cli test

Signed-off-by: anushkamittal20 <anumittal4641@gmail.com>

Co-authored-by: Jim Bugwadia <jim@nirmata.com>
2022-01-20 08:29:16 +00:00

35 lines
No EOL
1.2 KiB
YAML

apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: restrict-labels
labels:
policy.schiff.telekom.de: enforced
annotations:
policies.kyverno.io/title: Restrict Labels on Namespaces
policies.kyverno.io/category: Labels
policies.kyverno.io/minversion: 1.3.0
policies.kyverno.io/description: >-
This policy prevents the use of an label beginning with a common
key name (in this case "platform.das-schiff.telekom.de/owner | owner"). This can be useful to ensure users either
don't set reserved labels or to force them to
use a newer version of an label.
spec:
validationFailureAction: enforce
background: false
rules:
- name: restrict-labels
match:
resources:
kinds:
- Namespace
exclude:
clusterRoles:
- cluster-admin
validate:
message: 'Every namespace has to have `platform.das-schiff.telekom.de/owner` label. It must not have value `das-schiff` which is reserved for system namespaces'
pattern:
metadata:
labels:
platform.das-schiff.telekom.de/owner: "!das-schiff"
# For forward compatibility
=(schiff.telekom.de/owner): "!schiff"