Skip to content

Instantly share code, notes, and snippets.

@romilbhardwaj
Created August 21, 2024 21:26
Show Gist options
  • Save romilbhardwaj/ce7780bd2c0450ed4a9225e217aeca63 to your computer and use it in GitHub Desktop.
Save romilbhardwaj/ce7780bd2c0450ed4a9225e217aeca63 to your computer and use it in GitHub Desktop.
Kyverno Policy for removing smarter-devices/fuse resource when running on DWS.
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: mutate-dws-pod-template
annotations:
policies.kyverno.io/title: Remove incompatible resources from PodTemplates
policies.kyverno.io/category: Other
policies.kyverno.io/severity: low
kyverno.io/kyverno-version: 1.10.1
policies.kyverno.io/minversion: 1.6.0
kyverno.io/kubernetes-version: "1.23"
policies.kyverno.io/subject: PodTemplate
policies.kyverno.io/description: >-
Removes unsupported resource requests from PodTemplate manifests to allow submission to DWS queue.
spec:
mutateExistingOnPolicyUpdate: false
background: false
failurePolicy: Ignore
rules:
- name: mutate-remove-unsupported-resources
match:
resources:
kinds:
- PodTemplate
namespaceSelector:
matchExpressions:
- key: role
operator: In
values:
- kueue-jobs
mutate:
foreach:
- list: "request.object.template.spec.containers"
patchesJson6902: |-
- path: /template/spec/containers/{{elementIndex}}/resources/requests/smarter-devices~1fuse
op: remove
- path: /template/spec/containers/{{elementIndex}}/resources/limits/smarter-devices~1fuse
op: remove
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment