2023-09-15 16:47:51 +02:00
|
|
|
---
|
2023-09-11 23:53:34 +02:00
|
|
|
apiVersion: kyverno.io/v1
|
|
|
|
kind: ClusterPolicy
|
|
|
|
metadata:
|
|
|
|
annotations:
|
|
|
|
policies.kyverno.io/category: Hardening
|
2023-09-15 16:47:51 +02:00
|
|
|
policies.kyverno.io/description: Restrict modification of platform owned roles
|
|
|
|
to admins only
|
2023-09-11 23:53:34 +02:00
|
|
|
policies.kyverno.io/severity: medium
|
|
|
|
policies.kyverno.io/subject: Role
|
2023-09-15 16:47:51 +02:00
|
|
|
policies.kyverno.io/title: Deny Modification of platform owned roles
|
|
|
|
name: deny-modify-platform-label
|
2023-09-11 23:53:34 +02:00
|
|
|
spec:
|
2023-09-15 16:47:51 +02:00
|
|
|
admission: true
|
2023-09-11 23:53:34 +02:00
|
|
|
background: false
|
|
|
|
rules:
|
2023-09-15 16:47:51 +02:00
|
|
|
- match:
|
|
|
|
any:
|
|
|
|
- resources:
|
|
|
|
kinds:
|
|
|
|
- Role
|
|
|
|
name: deny-modify-platform-role
|
|
|
|
preconditions:
|
|
|
|
all:
|
|
|
|
- key: '{{ request.operation }}'
|
|
|
|
operator: AnyIn
|
|
|
|
value:
|
|
|
|
- UPDATE
|
|
|
|
- DELETE
|
|
|
|
- key: '{{ request.userInfo.groups }}'
|
|
|
|
operator: AllNotIn
|
|
|
|
value:
|
|
|
|
- system:masters
|
|
|
|
validate:
|
|
|
|
deny: {}
|
|
|
|
message: Roles owned by platform team (ones with label hpedevops.net/platform=true)
|
|
|
|
should not be modified by non-admin users.
|
2024-08-27 23:07:57 +03:00
|
|
|
failureAction: Audit
|