blob: 09445ed006fbe92f05cd6c9e725c41150bca8c52 (
plain)
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
|
# Provides datanode helper scripts.
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "hdfs-k8s.datanode.fullname" . }}-scripts
labels:
app: {{ template "hdfs-k8s.datanode.name" . }}
chart: {{ template "hdfs-k8s.subchart" . }}
release: {{ .Release.Name }}
data:
check-status.sh: |
#!/usr/bin/env bash
# Exit on error. Append "|| true" if you expect an error.
set -o errexit
# Exit on error inside any functions or subshells.
set -o errtrace
# Do not allow use of undefined vars. Use ${VAR:-} to use an undefined VAR
set -o nounset
# Catch an error in command pipes. e.g. mysqldump fails (but gzip succeeds)
# in `mysqldump |gzip`
set -o pipefail
# Turn on traces, useful while debugging.
set -o xtrace
# Check if datanode registered with the namenode and got non-null cluster ID.
_PORTS="50075 1006"
_URL_PATH="jmx?qry=Hadoop:service=DataNode,name=DataNodeInfo"
_CLUSTER_ID=""
for _PORT in $_PORTS; do
_CLUSTER_ID+=$(curl -s http://localhost:${_PORT}/$_URL_PATH | \
grep ClusterId) || true
done
echo $_CLUSTER_ID | grep -q -v null
---
# Deleting a daemonset may need some trick. See
# https://github.com/kubernetes/kubernetes/issues/33245#issuecomment-261250489
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: {{ template "hdfs-k8s.datanode.fullname" . }}
labels:
app: {{ template "hdfs-k8s.datanode.name" . }}
chart: {{ template "hdfs-k8s.subchart" . }}
release: {{ .Release.Name }}
spec:
template:
metadata:
labels:
app: {{ template "hdfs-k8s.datanode.name" . }}
release: {{ .Release.Name }}
{{- if .Values.podAnnotations }}
annotations:
{{ toYaml .Values.podAnnotations | indent 8 }}
{{- end }}
spec:
{{- if .Values.affinity }}
affinity:
{{ toYaml .Values.affinity | indent 8 }}
{{- else if .Values.global.defaultAffinityEnabled }}
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: {{ template "hdfs-k8s.datanode.fullname" . }}-exclude
operator: DoesNotExist
{{- end }}
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
{{- if .Values.tolerations }}
tolerations:
{{ toYaml .Values.tolerations | indent 8 }}
{{- end }}
hostNetwork: true
hostPID: true
dnsPolicy: ClusterFirstWithHostNet
containers:
- name: datanode
image: uhopper/hadoop-datanode:2.7.2
env:
- name: HADOOP_CUSTOM_CONF_DIR
value: /etc/hadoop-custom-conf
- name: MULTIHOMED_NETWORK
value: "0"
{{- if and .Values.global.kerberosEnabled .Values.global.jsvcEnabled }}
- name: HADOOP_SECURE_DN_USER
value: root
- name: JSVC_OUTFILE
value: /dev/stdout
- name: JSVC_ERRFILE
value: /dev/stderr
- name: JSVC_HOME
value: /jsvc-home
{{- end }}
livenessProbe:
exec:
command:
- /dn-scripts/check-status.sh
initialDelaySeconds: 60
periodSeconds: 30
readinessProbe:
exec:
command:
- /dn-scripts/check-status.sh
initialDelaySeconds: 60
periodSeconds: 30
securityContext:
privileged: true
volumeMounts:
- name: dn-scripts
mountPath: /dn-scripts
readOnly: true
- name: hdfs-config
mountPath: /etc/hadoop-custom-conf
readOnly: true
{{- range $index, $path := .Values.global.dataNodeHostPath }}
- name: hdfs-data-{{ $index }}
mountPath: /hadoop/dfs/data/{{ $index }}
{{- end }}
{{- if .Values.global.kerberosEnabled }}
- name: kerberos-config
mountPath: /etc/krb5.conf
subPath: {{ .Values.global.kerberosConfigFileName }}
readOnly: true
- name: kerberos-keytab-copy
mountPath: /etc/security/
readOnly: true
{{- if .Values.global.jsvcEnabled }}
- name: jsvc-home
mountPath: /jsvc-home
{{- end }}
{{- end }}
{{- if .Values.global.kerberosEnabled }}
initContainers:
- name: copy-kerberos-keytab
image: busybox:1.27.1
command: ['sh', '-c']
args:
- cp /kerberos-keytabs/$MY_NODE_NAME.keytab /kerberos-keytab-copy/hdfs.keytab
env:
- name: MY_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
volumeMounts:
- name: kerberos-keytabs
mountPath: /kerberos-keytabs
- name: kerberos-keytab-copy
mountPath: /kerberos-keytab-copy
{{- if .Values.global.jsvcEnabled }}
- name: copy-jsvc
# Pull by digest because the image doesn't have tags to pin.
image: mschlimb/jsvc@sha256:bf20eb9a319e9a2f87473d8da7418d21503a97528b932800b6b8417cd31e30ef
command: ['sh', '-c']
args:
- cp /usr/bin/jsvc /jsvc-home/jsvc
volumeMounts:
- name: jsvc-home
mountPath: /jsvc-home
{{- end }}
{{- end }}
restartPolicy: Always
volumes:
- name: dn-scripts
configMap:
name: {{ template "hdfs-k8s.datanode.fullname" . }}-scripts
defaultMode: 0744
{{- range $index, $path := .Values.global.dataNodeHostPath }}
- name: hdfs-data-{{ $index }}
hostPath:
path: {{ $path }}
{{- end }}
- name: hdfs-config
configMap:
name: {{ template "hdfs-k8s.config.fullname" . }}
{{- if .Values.global.kerberosEnabled }}
- name: kerberos-config
configMap:
name: {{ template "krb5-configmap" . }}
- name: kerberos-keytabs
secret:
secretName: {{ template "krb5-keytabs-secret" . }}
- name: kerberos-keytab-copy
emptyDir: {}
{{- if .Values.global.jsvcEnabled }}
- name: jsvc-home
emptyDir: {}
{{- end }}
{{- end }}
|