mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-31 03:45:17 +00:00
* fix: account for error rules in mutation webhook Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * add test Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
29 lines
848 B
YAML
29 lines
848 B
YAML
apiVersion: kyverno.io/v1
|
|
kind: ClusterPolicy
|
|
metadata:
|
|
name: propagate-cost-labels-from-namespace
|
|
spec:
|
|
failurePolicy: Ignore
|
|
rules:
|
|
- name: add-cost-labels
|
|
context:
|
|
- name: namespaceLabels
|
|
apiCall:
|
|
urlPath: "/api/v1/namespaces/{{request.namespace}}"
|
|
jmesPath: metadata.labels
|
|
match:
|
|
any:
|
|
- resources:
|
|
kinds:
|
|
- Pod
|
|
- Deployment
|
|
- StatefulSet
|
|
- DaemonSet
|
|
- Job
|
|
- CronJob
|
|
mutate:
|
|
patchStrategicMerge:
|
|
metadata:
|
|
labels:
|
|
cost.starfleet.evtech/project: "{{namespaceLabels.\"cost.starfleet.evtech/project\"}}"
|
|
cost.starfleet.evtech/application: "{{request.object.metadata.labels.\"cost.starfleet.evtech/application\" || namespaceLabels.\"cost.starfleet.evtech/application\"}}"
|