-
Notifications
You must be signed in to change notification settings - Fork 146
/
Copy pathm-statefulset.yaml
250 lines (250 loc) · 8.91 KB
/
m-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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: master
labels:
role: master
spec:
podManagementPolicy: Parallel
replicas: 1
selector:
matchLabels:
role: master
serviceName: hadoop
template:
metadata:
labels:
role: master
spec:
serviceAccountName: hadoop
containers:
- image: hbase
name: hbase
command:
- /bin/bash
- -c
- |-
# Shell context so we can pull in the environment variables set in the container and
# via the env and envFrom.
# See https://stackoverflow.com/questions/57885828/netty-cannot-access-class-jdk-internal-misc-unsafe
HBASE_CLASSPATH=/etc/hadoop \
HBASE_OPTS=" \
-XX:MaxRAMPercentage=${JVM_HEAP_PERCENTAGE_OF_RESOURCE_LIMIT} \
-XX:InitialRAMPercentage=${JVM_HEAP_PERCENTAGE_OF_RESOURCE_LIMIT} \
-javaagent:${JMX_PROMETHEUS_JAR}=7000:/tmp/scratch/jmxexporter.yaml \
-Djava.security.properties=/tmp/scratch/java.security \
-Djava.library.path=${HADOOP_HOME}/lib/native --add-opens java.base/jdk.internal.misc=ALL-UNNAMED \
-Djava.util.logging.config.file=${HBASE_CONF_DIR}/logging.properties \
-Dio.netty.tryReflectionSetAccessible=true \
-Xlog:gc:${HBASE_LOG_DIR}/gc.log:time,uptime:filecount=10,filesize=100M" \
hbase-daemon.sh --config /etc/hbase foreground_start master \
${FAILOVER_PROXY_PROVIDER}
# For now, just fetch local /jmx
# Says kubelet only exposes failures, not success: https://stackoverflow.com/questions/34455040/kubernetes-liveness-probe-logging
# TODO: Use https://hbase.apache.org/devapidocs/org/apache/hadoop/hbase/HealthChecker.html
livenessProbe:
httpGet:
path: /jmx?qry=java.lang:type=OperatingSystem
port: 16010
initialDelaySeconds: 10
periodSeconds: 10
failureThreshold: 3
readinessProbe:
httpGet:
path: /jmx?qry=java.lang:type=OperatingSystem
port: 16010
initialDelaySeconds: 10
periodSeconds: 10
failureThreshold: 3
startupProbe:
httpGet:
path: /jmx?qry=java.lang:type=OperatingSystem
port: 16010
initialDelaySeconds: 10
failureThreshold: 30
periodSeconds: 10
resources:
requests:
memory: "1.5Gi"
cpu: "0.1"
limits:
memory: "2Gi"
cpu: "1.0"
envFrom:
- configMapRef:
name: environment
- configMapRef:
name: zookeeper-quorum
- configMapRef:
name: jaegertracing
optional: true
- configMapRef:
name: xraytracing
optional: true
env:
# not honored by opentelemetry-java/v1.0.1
# - name: OTEL_EXPERIMENTAL_SDK_ENABLED
# # flip this switch to disable tracing
# value: "true"
# not honored by opentelemetry-java/v1.0.1
# - name: OTEL_SERVICE_NAME
# value: "hbase-master"
# - name: OTEL_RESOURCE_ATTRIBUTES
# value: "service.name=hbase-master"
# - name: HBASE_TRACE_OPTS
# value: "true"
# - name: HBASE_SHELL_OPTS
# # it appears that system properties override environment variables, so naming the shell
# # can via system property will override the master name provided by environment variable
# value: "-Dotel.resource.attributes=service.name=hbase-shell"
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
ports:
- containerPort: 16010
name: http
- containerPort: 16000
name: rpc
volumeMounts:
- name: hbase-configuration
mountPath: /etc/hbase
readOnly: true
- name: hbck2-configuration
mountPath: /etc/hbck2
readOnly: true
- mountPath: /etc/hadoop
name: hadoop-configuration
- mountPath: /var/log/hbase
name: hbase-logs
- mountPath: /tmp/scratch
name: scratch
- mountPath: /tmp/scripts
name: scripts
initContainers:
- image: hbase
name: bootstrapper
imagePullPolicy: IfNotPresent
command:
- /bin/bash
- -c
- |-
set -ex
env | sort
# Currently, waits till NNs and all DNs are up. Waiting on all DNs is extreme
# but will do for now; could just wait on 5 or 10 or so.
/tmp/scripts/jmxping.sh namenode ${HADOOP_SERVICE}
# TODO: Should we check if ha and if so, if a NN active... get a report on health?
/tmp/scripts/jmxping.sh datanode ${HADOOP_SERVICE} 3
cp /tmp/global-files/* /tmp/scratch/
# Write the USER hbase is running as into temporary file for use by next init container
echo ${USER} > /tmp/scratch/hbaseuser.txt
# Ditto for the location of the hbase dir.
hbase org.apache.hadoop.hbase.util.HBaseConfTool hbase.rootdir > /tmp/scratch/hbaserootdir.txt
cat /tmp/scratch/hbaserootdir.txt
securityContext:
# Run bootstrapper as root so can set ${USER} owner on data volume
allowPrivilegeEscalation: false
runAsUser: 0
resources:
requests:
cpu: '0.2'
memory: 256Mi
limits:
cpu: '0.5'
memory: 512Mi
envFrom:
- configMapRef:
name: environment
volumeMounts:
- mountPath: /tmp/scripts
name: scripts
# Scratch dir is a location where init containers place items for later use
# by the main containers when they run.
- mountPath: /tmp/scratch
name: scratch
- mountPath: /tmp/global-files
name: global-files
- name: hbase-configuration
mountPath: /etc/hbase
readOnly: true
- image: hadoop
name: prepare-hdfs-for-hbase
command:
- /bin/bash
- -c
- |-
set -ex
# This container runs as the HDFS ${USER}/super-user.
# Make sure that this image is the same as that of the cluster hbase is to
# run on (else below will fail w/ permissions issues).
HBASE_USER=$(cat /tmp/scratch/hbaseuser.txt)
HBASE_ROOTDIR=$(cat /tmp/scratch/hbaserootdir.txt)
hdfs --config /etc/hadoop dfs -mkdir ${HBASE_ROOTDIR} || echo $?
hdfs --config /etc/hadoop dfs -chown -R ${HBASE_USER} ${HBASE_ROOTDIR}
resources:
requests:
cpu: '0.2'
memory: 256Mi
limits:
cpu: '0.5'
memory: 512Mi
envFrom:
- configMapRef:
name: environment
env:
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
volumeMounts:
# Scratch dir is a location where init containers place items for later use
# by the main containers when they run.
- mountPath: /tmp/scratch
name: scratch
- mountPath: /etc/hadoop
name: hadoop-configuration
- mountPath: /var/log/hadoop
name: hadoop-logs
restartPolicy: Always
volumes:
- name: hbase-configuration
configMap:
name: hbase-configuration
- name: hbck2-configuration
configMap:
name: hbck2-configuration
- configMap:
name: hadoop-configuration
name: hadoop-configuration
- configMap:
name: global-files
name: global-files
- emptyDir: {}
name: hbase-logs
- emptyDir: {}
name: hadoop-logs
- configMap:
name: scripts
defaultMode: 0555
name: scripts
# Scratch dir is a location where init containers place items for later use
# by the main containers when they run.
- emptyDir: {}
name: scratch