Skip to content

Commit 51df08c

Browse files
Add PodMutation custom resource example
1 parent b83d926 commit 51df08c

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# castai-pod-mutator helm chart installs Kubernetes Custom Resource Definition (CRD) for the kind 'PodMutation'.
2+
# Pod mutation rules can then be added to a cluster as plain Kubernetes object of this kind.
3+
#
4+
# You should use a name that is _not_ shared by a mutation created via Cast AI console because.
5+
# In such cases, custom resource mutation will be shadowed by the mutation created via the console.
6+
7+
resource "kubernetes_manifest" "test_pod_mutation" {
8+
manifest = {
9+
apiVersion = "pod-mutations.cast.ai/v1"
10+
kind = "PodMutation"
11+
metadata = {
12+
name = "test-pod-mutation"
13+
}
14+
spec = {
15+
filter = {
16+
# Filter values can be plain strings of regexes.
17+
workload = {
18+
namespaces = ["production", "staging"]
19+
names = ["^frontend-.*$", "^backend-.*$"]
20+
kinds = ["Pod", "Deployment", "ReplicaSet"]
21+
}
22+
pod = {
23+
# labelsOperator can be "and" or "or"
24+
labelsOperator = "and"
25+
labelsFilter = [
26+
{
27+
key = "app.kubernetes.io/part-of"
28+
value = "platform"
29+
},
30+
{
31+
key = "tier"
32+
value = "frontend"
33+
}
34+
]
35+
}
36+
}
37+
restartPolicy = "deferred"
38+
patches = [
39+
{
40+
op = "add"
41+
path = "/metadata/annotations/mutated-by-pod-mutator"
42+
value = "true"
43+
}
44+
]
45+
spotConfig = {
46+
# mode can be "optional-spot", "only-spot", or "preferred-spot"
47+
mode = "optional-spot"
48+
distributionPercentage = 50
49+
}
50+
}
51+
}
52+
}

0 commit comments

Comments
 (0)