This repository has been archived by the owner on Feb 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 837
/
statefulset.yaml
200 lines (200 loc) · 6.85 KB
/
statefulset.yaml
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
{{- if .Capabilities.APIVersions.Has "apps/v1" }}
apiVersion: apps/v1
{{- else }}
apiVersion: apps/v1beta1
{{- end }}
kind: StatefulSet
metadata:
name: {{ template "cp-zookeeper.fullname" . }}
labels:
app: {{ template "cp-zookeeper.name" . }}
chart: {{ template "cp-zookeeper.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
{{- if .Capabilities.APIVersions.Has "apps/v1" }}
selector:
matchLabels:
app: {{ template "cp-zookeeper.name" . }}
release: {{ .Release.Name }}
{{- end }}
serviceName: {{ template "cp-zookeeper.fullname" . }}-headless
podManagementPolicy: {{ .Values.podManagementPolicy }}
replicas: {{ default 3 .Values.servers }}
updateStrategy:
type: {{ .Values.updateStrategy }}
template:
metadata:
labels:
app: {{ template "cp-zookeeper.name" . }}
release: {{ .Release.Name }}
{{- if or .Values.podAnnotations .Values.prometheus.jmx.enabled }}
annotations:
{{- range $key, $value := .Values.podAnnotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- if .Values.prometheus.jmx.enabled }}
prometheus.io/scrape: "true"
prometheus.io/port: {{ .Values.prometheus.jmx.port | quote }}
{{- end }}
{{- end }}
spec:
affinity:
{{- if .Values.affinity }}
{{ toYaml .Values.affinity | indent 8 }}
{{- else }}
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
podAffinityTerm:
labelSelector:
matchExpressions:
- key: "app"
operator: In
values:
- {{ template "cp-zookeeper.name" . }}
- key: "release"
operator: In
values:
- {{ .Release.Name }}
topologyKey: "kubernetes.io/hostname"
{{- end }}
containers:
{{- if .Values.prometheus.jmx.enabled }}
- name: prometheus-jmx-exporter
image: "{{ .Values.prometheus.jmx.image }}:{{ .Values.prometheus.jmx.imageTag }}"
imagePullPolicy: "{{ .Values.prometheus.jmx.imagePullPolicy }}"
command:
- java
- -XX:+UnlockExperimentalVMOptions
- -XX:+UseCGroupMemoryLimitForHeap
- -XX:MaxRAMFraction=1
- -XshowSettings:vm
- -jar
- jmx_prometheus_httpserver.jar
- {{ .Values.prometheus.jmx.port | quote }}
- /etc/jmx-zookeeper/jmx-zookeeper-prometheus.yml
ports:
- containerPort: {{ .Values.prometheus.jmx.port }}
resources:
{{ toYaml .Values.prometheus.jmx.resources | indent 10 }}
volumeMounts:
- name: jmx-config
mountPath: /etc/jmx-zookeeper
{{- end }}
- name: {{ template "cp-zookeeper.name" . }}-server
image: "{{ .Values.image }}:{{ .Values.imageTag }}"
imagePullPolicy: "{{ .Values.imagePullPolicy }}"
{{- if .Values.securityContext }}
securityContext: {{- toYaml .Values.securityContext | nindent 10 }}
{{- end }}
ports:
- containerPort: {{ .Values.clientPort }}
name: client
- containerPort: {{ .Values.serverPort }}
name: server
- containerPort: {{ .Values.leaderElectionPort }}
name: leader-election
{{- if .Values.prometheus.jmx.enabled }}
- containerPort: {{ .Values.jmx.port }}
name: jmx
{{- end }}
resources:
{{ toYaml .Values.resources | indent 10 }}
env:
- name : KAFKA_HEAP_OPTS
value: "{{ .Values.heapOptions }}"
{{- if .Values.jmx.port }}
- name : KAFKA_JMX_PORT
value: "{{ .Values.jmx.port }}"
{{- end }}
- name : ZOOKEEPER_TICK_TIME
value: "{{ .Values.tickTime }}"
- name : ZOOKEEPER_SYNC_LIMIT
value: "{{ .Values.syncLimit }}"
- name : ZOOKEEPER_INIT_LIMIT
value: "{{ .Values.initLimit }}"
- name : ZOOKEEPER_MAX_CLIENT_CNXNS
value: "{{ .Values.maxClientCnxns }}"
- name : ZOOKEEPER_AUTOPURGE_SNAP_RETAIN_COUNT
value: "{{ .Values.autoPurgeSnapRetainCount}}"
- name : ZOOKEEPER_AUTOPURGE_PURGE_INTERVAL
value: "{{ .Values.autoPurgePurgeInterval}}"
- name: ZOOKEEPER_CLIENT_PORT
value: "{{ .Values.clientPort }}"
- name : ZOOKEEPER_SERVERS
value: {{ template "cp-zookeeper.serverlist" . }}
# ZOOKEEPER_SERVER_ID is required just to pass cp-zookeeper ensure script for env check,
# the value(metadata.mame) is not used and will be overwritten in command part
- name: ZOOKEEPER_SERVER_ID
valueFrom:
fieldRef:
fieldPath: metadata.name
command:
- "bash"
- "-c"
- |
ZK_FIX_HOST_REGEX="s/${HOSTNAME}\.[^:]*:/0.0.0.0:/g"
ZOOKEEPER_SERVER_ID=$((${HOSTNAME##*-}+1)) \
ZOOKEEPER_SERVERS=`echo $ZOOKEEPER_SERVERS | sed -e "$ZK_FIX_HOST_REGEX"` \
/etc/confluent/docker/run
volumeMounts:
- name: datadir
mountPath: /var/lib/zookeeper/data
- name: datalogdir
mountPath: /var/lib/zookeeper/log
{{- if .Values.imagePullSecrets }}
imagePullSecrets:
{{ toYaml .Values.imagePullSecrets | indent 8 }}
{{- end }}
volumes:
{{ if not .Values.persistence.enabled }}
- name: datadir
emptyDir: {}
- name: datalogdir
emptyDir: {}
{{- end }}
{{- if .Values.prometheus.jmx.enabled }}
- name: jmx-config
configMap:
name: {{ template "cp-zookeeper.fullname" . }}-jmx-configmap
{{- end }}
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
{{- if .Values.tolerations }}
tolerations:
{{ toYaml .Values.tolerations | indent 8 }}
{{- end }}
{{- if .Values.persistence.enabled }}
volumeClaimTemplates:
- metadata:
name: datadir
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: "{{ .Values.persistence.dataDirSize }}"
{{- if .Values.persistence.dataDirStorageClass }}
{{- if (eq "-" .Values.persistence.dataDirStorageClass) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.persistence.dataDirStorageClass }}"
{{- end }}
{{- end }}
- metadata:
name: datalogdir
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: "{{ .Values.persistence.dataLogDirSize }}"
{{- if .Values.persistence.dataLogDirStorageClass }}
{{- if (eq "-" .Values.persistence.dataLogDirStorageClass) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.persistence.dataLogDirStorageClass }}"
{{- end }}
{{- end }}
{{- end }}