This repository has been archived by the owner on Dec 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathzookeeper.yaml
157 lines (153 loc) · 3.65 KB
/
zookeeper.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
# @author Alejandro Galue <agalue@opennms.org>
#
# WARNING:
# - Full FQDNs are required for ZOO_SERVERS; otherwise, the leader election fails.
# - The zookeeper user (uid: 1000, gid: 1000) cannot be used in OpenShift by default.
apiVersion: v1
kind: Service
metadata:
name: zookeeper
namespace: opennms
labels:
app: zk
spec:
ports:
- port: 2181
name: client
- port: 2888
name: server
- port: 3888
name: leader-election
- port: 9998
name: jmx
clusterIP: None
selector:
app: zk
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: zk-pdb
spec:
maxUnavailable: 1
selector:
matchLabels:
app: zk
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: zk
namespace: opennms
labels:
app: zk
spec:
serviceName: zookeeper
replicas: 3 # The solution is designed for 3 instances
updateStrategy:
type: RollingUpdate
podManagementPolicy: OrderedReady
selector:
matchLabels:
app: zk
template:
metadata:
labels:
app: zk
spec:
terminationGracePeriodSeconds: 300
securityContext:
runAsUser: 1000
fsGroup: 1000
initContainers:
- name: generate-zooid
image: busybox
command:
- sh
- -c
- ORD=${HOSTNAME##*-}; MYID=$((ORD+1)); echo $MYID > /data/myid
volumeMounts:
- name: data
mountPath: /data
containers:
- name: zk
image: zookeeper:3.5
imagePullPolicy: IfNotPresent
env:
- name: TZ
valueFrom:
configMapKeyRef:
key: TIMEZONE
name: common-settings
- name: ZOO_SERVERS # Must be consistent with the replicas
value: server.1=zk-0.zookeeper.opennms.svc.cluster.local:2888:3888;2181 server.2=zk-1.zookeeper.opennms.svc.cluster.local:2888:3888;2181 server.3=zk-2.zookeeper.opennms.svc.cluster.local:2888:3888;2181
- name: ZOO_STANDALONE_ENABLED
value: 'false'
- name: ZOO_4LW_COMMANDS_WHITELIST
value: '*'
- name: ZOO_TICK_TIME
value: '2000'
- name: ZOO_INIT_LIMIT
value: '10'
- name: ZOO_SYNC_LIMIT
value: '5'
- name: JMXLOCALONLY
value: 'false'
- name: JMXDISABLE
value: 'false'
- name: JMXPORT
value: '9998'
- name: JMXAUTH
value: 'false'
- name: JMXSSL
value: 'false'
- name: MEM_TOTAL_MB
valueFrom:
resourceFieldRef:
resource: requests.memory
divisor: 1Mi
- name: JVMFLAGS
value: -Xms$(MEM_TOTAL_MB)m -Xmx$(MEM_TOTAL_MB)m
ports:
- containerPort: 2181
name: client
- containerPort: 2888
name: server
- containerPort: 3888
name: leader-election
- containerPort: 8080
name: admin
- containerPort: 9998
name: jmx
volumeMounts:
- name: data
mountPath: /data
resources:
limits:
memory: 512Mi
cpu: 200m
requests:
memory: 256Mi
cpu: 100m
readinessProbe:
exec:
command:
- sh
- -c
- '[ "imok" = "$(echo ruok | nc 127.0.0.1 2181)" ]'
initialDelaySeconds: 10
periodSeconds: 10
livenessProbe:
tcpSocket:
port: client
initialDelaySeconds: 30
periodSeconds: 60
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 4Gi