k8s-deployment/kustomizations/kyverno/pvc-patch.yaml

41 lines
1.2 KiB
YAML
Raw Permalink Normal View History

2024-09-28 19:54:31 +00:00
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: replace-storage-class-by-openebs
spec:
rules:
- name: replace-storage-class
match:
any:
- resources:
kinds:
- PersistentVolumeClaim
mutate:
patchStrategicMerge:
metadata:
annotations:
volume.beta.kubernetes.io/storage-class: openebs-hostpath
spec:
storageClassName: openebs-hostpath
accessModes:
- ReadWriteOnce
- name: remove-unwanted-annotations
match:
any:
- resources:
kinds:
- PersistentVolumeClaim
namespaces:
- games
mutate:
patchesJson6902: |-
- path: "/metadata/annotations/volume.beta.kubernetes.io~1storage-class"
op: replace
value: openebs-hostpath
- path: "/metadata/annotations/volume.beta.kubernetes.io~1storage-provisioner"
op: replace
value: openebs.io/local
- path: "/metadata/annotations/volume.kubernetes.io~1storage-provisioner"
op: replace
value: openebs.io/local