Refactor Distributed Analytics project structure
[demo.git] / vnfs / DAaaS / deploy / training-core / charts / kubernetes-HDFS / charts / hdfs-journalnode-k8s / templates / journalnode-statefulset.yaml
1 # A headless service to create DNS records.
2 apiVersion: v1
3 kind: Service
4 metadata:
5   name: {{ template "hdfs-k8s.journalnode.fullname" . }}
6   labels:
7     app: {{ template "hdfs-k8s.journalnode.name" . }}
8     chart: {{ template "hdfs-k8s.subchart" . }}
9     release: {{ .Release.Name }}
10   annotations:
11     # TODO: Deprecated. Replace tolerate-unready-endpoints with
12     # v1.Service.PublishNotReadyAddresses.
13     service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
14 spec:
15   ports:
16   - port: 8485
17     name: jn
18   - port: 8480
19     name: http
20   clusterIP: None
21   selector:
22     app: {{ template "hdfs-k8s.journalnode.name" . }}
23     release: {{ .Release.Name }}
24 ---
25 apiVersion: policy/v1beta1
26 kind: PodDisruptionBudget
27 metadata:
28   name: {{ template "hdfs-k8s.journalnode.fullname" . }}
29   labels:
30     app: {{ template "hdfs-k8s.journalnode.name" . }}
31     chart: {{ template "hdfs-k8s.subchart" . }}
32     release: {{ .Release.Name }}
33 spec:
34   selector:
35     matchLabels:
36       app: {{ template "hdfs-k8s.journalnode.name" . }}
37       release: {{ .Release.Name }}
38   minAvailable: {{ div .Values.global.journalnodeQuorumSize 2 | add1 }}
39 ---
40 apiVersion: apps/v1beta1
41 kind: StatefulSet
42 metadata:
43   name: {{ template "hdfs-k8s.journalnode.fullname" . }}
44   labels:
45     app: {{ template "hdfs-k8s.journalnode.name" . }}
46     chart: {{ template "hdfs-k8s.subchart" . }}
47     release: {{ .Release.Name }}
48 spec:
49   serviceName: {{ template "hdfs-k8s.journalnode.fullname" . }}
50   replicas: {{ .Values.global.journalnodeQuorumSize }}
51   template:
52     metadata:
53       labels:
54         app: {{ template "hdfs-k8s.journalnode.name" . }}
55         release: {{ .Release.Name }}
56       {{- if .Values.podAnnotations }}
57       annotations:
58 {{ toYaml .Values.podAnnotations | indent 8 }}
59       {{- end }}
60     spec:
61       {{- if .Values.affinity }}
62       affinity:
63 {{ toYaml .Values.affinity | indent 8 }}
64       {{- else if .Values.global.defaultAffinityEnabled }}
65       affinity:
66         podAntiAffinity:
67           requiredDuringSchedulingIgnoredDuringExecution:
68             - labelSelector:
69                 matchExpressions:
70                   - key: "app"
71                     operator: In
72                     values:
73                       - {{ template "hdfs-k8s.journalnode.name" . }}
74                   - key: "release"
75                     operator: In
76                     values:
77                       - {{ .Release.Name }}
78               topologyKey: "kubernetes.io/hostname"
79       {{- end }}
80       {{- if .Values.nodeSelector }}
81       nodeSelector:
82 {{ toYaml .Values.nodeSelector | indent 8 }}
83       {{- end }}
84       {{- if .Values.tolerations }}
85       tolerations:
86 {{ toYaml .Values.tolerations | indent 8 }}
87       {{- end }}
88       containers:
89         - name: hdfs-journalnode
90           image: uhopper/hadoop-namenode:2.7.2
91           env:
92             - name: HADOOP_CUSTOM_CONF_DIR
93               value: /etc/hadoop-custom-conf
94           command: ["/entrypoint.sh"]
95           args: ["/opt/hadoop-2.7.2/bin/hdfs", "--config", "/etc/hadoop", "journalnode"]
96           ports:
97           - containerPort: 8485
98             name: jn
99           - containerPort: 8480
100             name: http
101           volumeMounts:
102             # Mount a subpath of the volume so that the journal subdir would be
103             # a brand new empty dir. This way, we won't get affected by
104             # existing files in the volume top dir.
105             - name: editdir
106               mountPath: /hadoop/dfs/journal
107               subPath: journal
108             - name: editdir
109               mountPath: /hadoop/dfs/name
110               subPath: name
111             - name: hdfs-config
112               mountPath: /etc/hadoop-custom-conf
113               readOnly: true
114            {{- if .Values.global.kerberosEnabled }}
115             - name: kerberos-config
116               mountPath: /etc/krb5.conf
117               subPath: {{ .Values.global.kerberosConfigFileName }}
118               readOnly: true
119             - name: kerberos-keytab-copy
120               mountPath: /etc/security/
121               readOnly: true
122             {{- end }}
123      {{- if .Values.global.kerberosEnabled }}
124       initContainers:
125         - name: copy-kerberos-keytab
126           image: busybox:1.27.1
127           command: ['sh', '-c']
128           args:
129             - cp /kerberos-keytabs/${MY_KERBEROS_NAME}*.keytab /kerberos-keytab-copy/hdfs.keytab
130           env:
131             - name: MY_KERBEROS_NAME
132               valueFrom:
133                 fieldRef:
134                   fieldPath: metadata.name
135           volumeMounts:
136             - name: kerberos-keytabs
137               mountPath: /kerberos-keytabs
138             - name: kerberos-keytab-copy
139               mountPath: /kerberos-keytab-copy
140       {{- end }}
141       restartPolicy: Always
142       volumes:
143         - name: hdfs-config
144           configMap:
145             name: {{ template "hdfs-k8s.config.fullname" . }}
146         {{- if .Values.global.kerberosEnabled }}
147         - name: kerberos-config
148           configMap:
149             name: {{ template "krb5-configmap" . }}
150         - name: kerberos-keytabs
151           secret:
152             secretName: {{ template "krb5-keytabs-secret" . }}
153         - name: kerberos-keytab-copy
154           emptyDir: {}
155         {{- end }}
156       {{- if .Values.global.podSecurityContext.enabled }}
157       securityContext:
158         runAsUser: {{ .Values.global.podSecurityContext.runAsUser }}
159         fsGroup: {{ .Values.global.podSecurityContext.fsGroup }}
160       {{- end }}
161   volumeClaimTemplates:
162     - metadata:
163         name: editdir
164       spec:
165         accessModes:
166           - {{ .Values.persistence.accessMode | quote }}
167         resources:
168           requests:
169             storage: {{ .Values.persistence.size | quote }}
170       {{- if .Values.persistence.storageClass }}
171         {{- if (eq "-" .Values.persistence.storageClass) }}
172         storageClassName: ""
173         {{- else }}
174         storageClassName: "{{ .Values.persistence.storageClass }}"
175         {{- end }}
176       {{- end }}
177       {{- if .Values.persistence.selector }}
178         selector:
179 {{ toYaml .Values.persistence.selector | indent 10 }}
180       {{- end }}