Skip to content

Instantly share code, notes, and snippets.

@hustshawn
Last active June 21, 2023 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hustshawn/525745c5ce99d55111d7b64b6197a581 to your computer and use it in GitHub Desktop.
Save hustshawn/525745c5ce99d55111d7b64b6197a581 to your computer and use it in GitHub Desktop.
A Kyverno policy to mutate any daemonset to avoid trying to deploy to Fargate instances.
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: add-daemonset-fargate-anti-affinity
spec:
validationFailureAction: Enforce
background: false
rules:
- name: add-node-anti-affinity
match:
resources:
kinds:
- DaemonSet
mutate:
patchStrategicMerge:
spec:
template:
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: eks.amazonaws.com/compute-type
operator: NotIn
values:
- fargate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment