1d3f7577ba091547a88b3a741f3903db159be986
[demo.git] / vnfs / DAaaS / applications / sample-horovod-app / templates / statefulset.yaml
1 apiVersion: apps/v1beta2
2 kind: StatefulSet
3 metadata:
4   name: {{ template "horovod.fullname" . }}
5   labels:
6     app: {{ template "horovod.name" . }}
7     chart: {{ template "horovod.chart" . }}
8     release: {{ .Release.Name }}
9     heritage: {{ .Release.Service }}
10     role: worker
11 spec:
12   selector:
13     matchLabels:
14       app: {{ template "horovod.name" . }}
15       release: {{ .Release.Name }}
16       heritage: {{ .Release.Service }}
17       role: worker
18   serviceName: {{ template "horovod.fullname" . }}
19   podManagementPolicy: {{ .Values.worker.podManagementPolicy }}
20   replicas: {{.Values.worker.number}}
21   template:
22     metadata:
23       labels:
24         app: {{ template "horovod.name" . }}
25         chart: {{ template "horovod.chart" . }}
26         release: {{ .Release.Name }}
27         heritage: {{ .Release.Service }}
28         role: worker
29     spec:
30       selector:
31         matchLabels:
32           app: {{ template "horovod.name" . }}
33           release: {{ .Release.Name }}
34           role: worker
35       {{- if .Values.useHostNetwork }}
36       hostNetwork: {{ .Values.useHostNetwork }}
37       dnsPolicy: ClusterFirstWithHostNet
38       {{- end }}
39       {{- if .Values.useHostPID }}
40       hostPID: {{ .Values.useHostPID }}
41       {{- end }}
42       volumes:
43       - name: {{ template "horovod.fullname" . }}-cm
44         configMap:
45           name: {{ template "horovod.fullname" . }}
46           items:
47           - key: hostfile.config
48             path: hostfile
49             mode: 438
50           - key: ssh.readiness
51             path: check.sh
52             mode: 365
53           - key: worker.run
54             path: run.sh
55             mode: 365
56       {{- if .Values.ssh.useSecrets }}
57       - name: {{ template "horovod.fullname" . }}-secret
58         secret:
59           secretName: {{ template "horovod.fullname" . }}
60           defaultMode: 448
61           items:
62           - key: host-key
63             path: id_rsa
64           - key: host-key-pub
65             path: authorized_keys
66       {{- end }}
67 {{- if .Values.volumes }}
68 {{ toYaml .Values.volumes | indent  6 }}
69 {{- end }}
70       containers:
71       - name: worker
72         image: "{{ .Values.worker.image.repository }}:{{ .Values.worker.image.tag }}"
73         imagePullPolicy: {{ .Values.worker.image.pullPolicy }}
74         env:
75         - name: SSHPORT
76           value: "{{ .Values.ssh.port }}"
77        {{- if .Values.ssh.useSecrets }}
78         - name: USESECRETS
79           value: "{{ .Values.ssh.useSecrets }}"
80        {{- end }}
81        {{- if .Values.master.env }}
82        {{- range $key, $value := .Values.master.env }}
83         - name: "{{ $key }}"
84           value: "{{ $value }}"
85        {{- end }}
86        {{- end }}
87 {{- if .Values.worker.privileged }}
88         securityContext:
89           privileged: true
90 {{- end }}
91         ports:
92         - containerPort: {{ .Values.ssh.port }}
93         volumeMounts:
94         - name: {{ template "horovod.fullname" . }}-cm
95           mountPath: /horovod/generated
96         {{- if .Values.ssh.useSecrets }}
97         - name: {{ template "horovod.fullname" . }}-secret
98           readOnly: true
99           mountPath: "/etc/secret-volume"
100         {{- end }}
101 {{- if .Values.volumeMounts }}
102 {{ toYaml .Values.volumeMounts | indent 8 }}
103 {{- end }}
104         command:
105         - /horovod/generated/run.sh
106 {{- if .Values.ssh.useSecrets }}
107         readinessProbe:
108           exec:
109             command:
110             - /horovod/generated/check.sh
111           initialDelaySeconds: 1
112           periodSeconds: 2
113 {{- end }}
114         resources:
115 {{ toYaml .Values.resources | indent 10 }}