# Copyright 2020 Crown Copyright # # Licensed 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: {{ template "hdfs.fullname" . }}-datanode labels: {{- include "hdfs.labels" . | nindent 4 }} app.kubernetes.io/component: datanode spec: podManagementPolicy: Parallel replicas: {{ .Values.datanode.nodeCount }} serviceName: {{ template "hdfs.fullname" . }}-datanodes selector: matchLabels: {{- include "hdfs.selectorLabels" . | nindent 6 }} app.kubernetes.io/component: datanode volumeClaimTemplates: # {{- range $vol := until (int .Values.datanode.dataVolumes.count) }} - metadata: # name: data{{$vol}} name: datavol labels: {{- include "hdfs.labels" $ | nindent 8 }} spec: {{- toYaml $.Values.datanode.dataVolumes.pvcTemplateSpec | nindent 6 }} # {{- end }} template: metadata: annotations: checksum/config: {{ include (print $.Template.BasePath "/config.yaml") . | sha256sum }} checksum/secrets: {{ include (print $.Template.BasePath "/secrets.yaml") . | sha256sum }} labels: {{- include "hdfs.labels" . | nindent 8 }} app.kubernetes.io/component: datanode spec: initContainers: - name: wait-for-namenode-startup image: {{ .Values.alpine.repository}}:{{ .Values.alpine.tag }} imagePullPolicy: {{ .Values.alpine.imagePullPolicy }} command: [ "/bin/sh", "-c", 'for i in $(seq 1 300); do nc -z -w3 {{ template "hdfs.fullname" . }}-namenode-0.{{ template "hdfs.fullname" . }}-namenodes:{{ .Values.namenode.ports.serviceRpc }} && exit 0 || sleep 1; done; exit 1' ] - name: volume-permission image: public.ecr.aws/y4g4v0z7/busybox securityContext: runAsUser: 0 # the /fsx/data{$vol} subdir in sync with s3 (data repo in Fsx) command: ["sh", "-c", "chown -R {{ .Values.datanode.securityContext.runAsUser }}:{{ .Values.datanode.securityContext.fsGroup }} /fsx"] volumeMounts: # {{- range $vol := until (int .Values.datanode.dataVolumes.count) }} # - name: data{{$vol}} # mountPath: /fsx/data{{$vol}} # {{- end }} - name: datavol mountPath: /fsx containers: - name: datanode image: {{ .Values.datanode.repository }}:{{ .Values.datanode.tag }} imagePullPolicy: {{ .Values.datanode.imagePullPolicy }} args: - datanode env: - name: HADOOP_CONF_DIR value: {{ .Values.config.path }} {{- range $key, $value := .Values.datanode.extraEnvVars }} - name: {{ $key | upper | replace "." "_" }} value: {{ $value | quote }} {{- end }} volumeMounts: - name: config mountPath: {{ .Values.config.path }} readOnly: true - name: secrets mountPath: {{ .Values.secrets.path }} readOnly: true # {{- range $vol := until (int .Values.datanode.dataVolumes.count) }} # - name: data{{$vol}} # mountPath: /fsx/data{{$vol}} # {{- end }} - name: datavol mountPath: /fsx ports: - name: http containerPort: {{ .Values.datanode.ports.http }} - name: https containerPort: {{ .Values.datanode.ports.https }} - name: data-xfer containerPort: {{ .Values.datanode.ports.data }} - name: ipc containerPort: {{ .Values.datanode.ports.ipc }} livenessProbe: httpGet: scheme: HTTP port: http path: / initialDelaySeconds: 30 readinessProbe: httpGet: scheme: HTTP port: http path: / initialDelaySeconds: 30 resources: {{- toYaml .Values.datanode.resources | nindent 10 }} volumes: - name: config configMap: name: {{ template "hdfs.fullname" . }} optional: false - name: secrets secret: secretName: {{ template "hdfs.fullname" . }} optional: false {{- with .Values.datanode.securityContext }} securityContext: {{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.datanode.affinity }} affinity: {{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.datanode.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.datanode.tolerations }} tolerations: {{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.datanode.imagePullSecrets }} imagePullSecrets: {{- range . }} - name: {{ . }} {{- end }} {{- end }}