namenode.yaml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. # Copyright 2020 Crown Copyright
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. apiVersion: apps/v1
  15. kind: StatefulSet
  16. metadata:
  17. name: {{ template "hdfs.fullname" . }}-namenode
  18. labels:
  19. {{- include "hdfs.labels" . | nindent 4 }}
  20. app.kubernetes.io/component: namenode
  21. spec:
  22. podManagementPolicy: Parallel
  23. replicas: 1
  24. serviceName: {{ template "hdfs.fullname" . }}-namenodes
  25. selector:
  26. matchLabels:
  27. {{- include "hdfs.selectorLabels" . | nindent 6 }}
  28. app.kubernetes.io/component: namenode
  29. volumeClaimTemplates:
  30. {{- range $k, $v := until (int .Values.namenode.dataVolumes.count) }}
  31. - metadata:
  32. name: data{{$v}}
  33. labels:
  34. {{- include "hdfs.labels" $ | nindent 8 }}
  35. spec:
  36. {{- toYaml $.Values.namenode.dataVolumes.pvcTemplateSpec | nindent 6 }}
  37. {{- end }}
  38. template:
  39. metadata:
  40. annotations:
  41. checksum/config: {{ include (print $.Template.BasePath "/config.yaml") . | sha256sum }}
  42. checksum/secrets: {{ include (print $.Template.BasePath "/secrets.yaml") . | sha256sum }}
  43. labels:
  44. {{- include "hdfs.labels" . | nindent 8 }}
  45. app.kubernetes.io/component: namenode
  46. spec:
  47. {{- if and .Values.config.rackAwareness .Values.config.rackAwareness.nodeTopologyLabel }}
  48. serviceAccountName: {{ template "hdfs.namenodeServiceAccountName" . }}
  49. {{- end }}
  50. containers:
  51. - name: namenode
  52. image: {{ .Values.namenode.repository }}:{{ .Values.namenode.tag }}
  53. imagePullPolicy: {{ .Values.namenode.imagePullPolicy }}
  54. args:
  55. - namenode
  56. env:
  57. - name: HADOOP_CONF_DIR
  58. value: {{ .Values.config.path }}
  59. {{- range $key, $value := .Values.namenode.extraEnvVars }}
  60. - name: {{ $key | upper | replace "." "_" }}
  61. value: {{ $value | quote }}
  62. {{- end }}
  63. volumeMounts:
  64. - name: temp-volume
  65. mountPath: /var/log/hadoop
  66. - name: config
  67. mountPath: {{ .Values.config.path }}
  68. readOnly: true
  69. - name: secrets
  70. mountPath: {{ .Values.secrets.path }}
  71. readOnly: true
  72. {{- if and .Values.config.rackAwareness .Values.config.rackAwareness.nodeTopologyLabel }}
  73. - name: rack-awareness
  74. mountPath: /scripts/resolve-rack.sh
  75. subPath: resolve-rack.sh
  76. {{- end }}
  77. {{- range $k, $v := until (int .Values.namenode.dataVolumes.count) }}
  78. - name: data{{$v}}
  79. mountPath: /data{{$v}}
  80. {{- end }}
  81. ports:
  82. - name: http
  83. containerPort: {{ .Values.namenode.ports.http }}
  84. - name: https
  85. containerPort: {{ .Values.namenode.ports.https }}
  86. - name: client-rpc
  87. containerPort: {{ .Values.namenode.ports.clientRpc }}
  88. - name: service-rpc
  89. containerPort: {{ .Values.namenode.ports.serviceRpc }}
  90. - name: lifeline-rpc
  91. containerPort: {{ .Values.namenode.ports.lifelineRpc }}
  92. livenessProbe:
  93. exec:
  94. command:
  95. - /bin/bash
  96. - -c
  97. - hdfs dfsadmin -fs hdfs://localhost -safemode get
  98. initialDelaySeconds: 30
  99. periodSeconds: 30
  100. timeoutSeconds: 30
  101. successThreshold: 1
  102. failureThreshold: 2
  103. resources:
  104. {{- toYaml .Values.namenode.resources | nindent 10 }}
  105. volumes:
  106. - name: temp-volume
  107. emptyDir: {}
  108. - name: config
  109. configMap:
  110. name: {{ template "hdfs.fullname" . }}
  111. optional: false
  112. - name: secrets
  113. secret:
  114. secretName: {{ template "hdfs.fullname" . }}
  115. optional: false
  116. {{- if .Values.config.rackAwareness }}
  117. {{- if .Values.config.rackAwareness.nodeTopologyLabel }}
  118. - name: rack-awareness
  119. configMap:
  120. name: {{ template "hdfs.fullname" . }}-rack-awareness
  121. defaultMode: 0755
  122. {{- end }}
  123. {{- end }}
  124. {{- with .Values.datanode.securityContext }}
  125. securityContext:
  126. {{- toYaml . | nindent 8 }}
  127. {{- end }}
  128. {{- with .Values.namenode.affinity }}
  129. affinity:
  130. {{- toYaml . | nindent 8 }}
  131. {{- end }}
  132. {{- with .Values.namenode.nodeSelector }}
  133. nodeSelector:
  134. {{- toYaml . | nindent 8 }}
  135. {{- end }}
  136. {{- with .Values.namenode.tolerations }}
  137. tolerations:
  138. {{- toYaml . | nindent 8 }}
  139. {{- end }}
  140. {{- with .Values.namenode.imagePullSecrets }}
  141. imagePullSecrets:
  142. {{- range . }}
  143. - name: {{ . }}
  144. {{- end }}
  145. {{- end }}