Created
September 12, 2022 12:51
-
-
Save sebdoido/69773801dc7414dcd12bcc5f6c5e52db to your computer and use it in GitHub Desktop.
bbc-kyverno-preemptible-to-spot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: kyverno.io/v1 | |
kind: ClusterPolicy | |
metadata: | |
name: add-tolerations | |
spec: | |
rules: | |
- name: volatile-toleration | |
match: | |
any: | |
- resources: | |
kinds: | |
- Pod | |
preconditions: | |
any: | |
- key: "cloud.google.com/gke-preemptible" | |
operator: AnyIn | |
value: "{{ request.object.spec.tolerations[].key || `[]` }}" | |
mutate: | |
patchStrategicMerge: | |
spec: | |
# Add the `affinity`if not already specified. | |
+(affinity): | |
+(nodeAffinity): | |
+(requiredDuringSchedulingIgnoredDuringExecution): | |
nodeSelectorTerms: | |
- matchExpressions: | |
- key: cloud.blabla.io/k8s-volatile | |
operator: Exists | |
tolerations: | |
- effect: NoSchedule | |
key: cloud.blabla.io/k8s-volatile | |
operator: Equal | |
value: "true" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment