-
Notifications
You must be signed in to change notification settings - Fork 634
Expand file tree
/
Copy pathstatefulset.yaml
More file actions
87 lines (86 loc) · 2.61 KB
/
statefulset.yaml
File metadata and controls
87 lines (86 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
{{$HostNetworkMode := DefaultParam .CL2_USE_HOST_NETWORK_PODS false}}
{{$EnablePVs := DefaultParam .CL2_ENABLE_PVS true}}
{{$RUN_ON_ARM_NODES := DefaultParam .CL2_RUN_ON_ARM_NODES false}}
{{$TOLERATION := DefaultParam .CL2_TOLERATION ""}}
{{$podPayloadSize := DefaultParam .CL2_STATEFULSET_POD_PAYLOAD_SIZE 0}}
{{$Image := DefaultParam .Image "registry.k8s.io/pause:3.9"}}
{{$RuntimeClassName := DefaultParam .CL2_RUNTIME_CLASS_NAME nil}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{.Name}}
labels:
group: load
spec:
podManagementPolicy: Parallel
selector:
matchLabels:
group: load
name: {{.Name}}
serviceName: {{.Name}}
replicas: {{RandIntRange .ReplicasMin .ReplicasMax}}
template:
metadata:
labels:
group: load
name: {{.Name}}
spec:
{{if $RuntimeClassName}}
runtimeClassName: {{$RuntimeClassName}}
{{end}}
hostNetwork: {{$HostNetworkMode}}
containers:
- name: {{.Name}}
image: {{$Image}}
env:
- name: ENV_VAR
value: {{RandDataWithSeed $podPayloadSize .Name}}
ports:
- containerPort: 80
name: web
resources:
# Keep the CpuRequest/MemoryRequest request equal percentage of 1-core, 4GB node.
# For now we're setting it to 0.5%.
requests:
cpu: 5m
memory: "20M"
{{if $EnablePVs}}
volumeMounts:
- name: pv
mountPath: /var/pv
{{end}}
terminationGracePeriodSeconds: 1
# Add not-ready/unreachable tolerations for 15 minutes so that node
# failure doesn't trigger pod deletion.
tolerations:
- key: "node.kubernetes.io/not-ready"
operator: "Exists"
effect: "NoExecute"
tolerationSeconds: 900
- key: "node.kubernetes.io/unreachable"
operator: "Exists"
effect: "NoExecute"
tolerationSeconds: 900
{{if $RUN_ON_ARM_NODES}}
- key: "kubernetes.io/arch"
operator: Equal
value: arm64
effect: NoSchedule
{{end}}
{{if $TOLERATION}}
- key: {{$TOLERATION}}
operator: Exists
effect: NoSchedule
{{end}}
{{if $EnablePVs}}
# NOTE: PVs created this way should be cleaned-up manually, as deleting the StatefulSet doesn't automatically delete PVs.
# To avoid deleting all the PVs at once during namespace deletion, they should be deleted explicitly via Phase.
volumeClaimTemplates:
- metadata:
name: pv
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 100Mi
{{end}}