Merge "Ensure sdnctl user/schema created on master MySQL"
[oom.git] / kubernetes / sdnc / templates / statefulset.yaml
1 # Copyright © 2017 Amdocs, Bell Canada
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
15 apiVersion: apps/v1beta1
16 kind: StatefulSet
17 metadata:
18   name: {{ include "common.fullname" . }}
19   namespace: {{ include "common.namespace" . }}
20   labels:
21     app: {{ include "common.name" . }}
22     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
23     release: {{ .Release.Name }}
24     heritage: {{ .Release.Service }}
25 spec:
26   serviceName: "{{ .Values.service.name }}-cluster"
27   replicas: {{ .Values.replicaCount }}
28   podManagementPolicy: Parallel
29   template:
30     metadata:
31       labels:
32         app: {{ include "common.name" . }}
33         release: {{ .Release.Name }}
34     spec:
35       initContainers:
36       - command:
37         - /root/ready.py
38         args:
39         - --container-name
40         - {{ .Values.mysql.nameOverride }}
41         env:
42         - name: NAMESPACE
43           valueFrom:
44             fieldRef:
45               apiVersion: v1
46               fieldPath: metadata.namespace
47         image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
48         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
49         name: {{ include "common.name" . }}-readiness
50       containers:
51         - name: {{ include "common.name" . }}
52           image: "{{ .Values.global.repository | default .Values.repository }}/{{ .Values.image }}"
53           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
54           command: ["/bin/bash"]
55           args: ["-c", "/opt/sdnc/bin/startODL.sh"]
56           ports:
57           - containerPort: {{ .Values.service.internalPort }}
58           - containerPort: {{ .Values.service.internalPort2 }}
59           - containerPort: {{ .Values.service.internalPort3 }}
60           - containerPort: {{ .Values.service.clusterPort }}
61           readinessProbe:
62             tcpSocket:
63               port: {{ .Values.service.internalPort }}
64             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
65             periodSeconds: {{ .Values.readiness.periodSeconds }}
66           env:
67             - name: MYSQL_ROOT_PASSWORD
68               valueFrom:
69                 secretKeyRef:
70                   name: {{ template "common.fullname" . }}
71                   key: db-root-password
72             - name: SDNC_CONFIG_DIR
73               value: "{{ .Values.config.configDir }}"
74             - name: ENABLE_ODL_CLUSTER
75               value: "{{ .Values.config.enableClustering }}"
76             - name: SDNC_REPLICAS
77               value: "{{ .Values.replicaCount }}"
78             - name: MYSQL_HOST
79               value: "{{.Release.Name}}-{{.Values.mysql.nameOverride}}-0.{{.Values.mysql.service.name}}.{{.Release.Namespace}}"
80           volumeMounts:
81           - mountPath: /etc/localtime
82             name: localtime
83             readOnly: true
84           - mountPath: /opt/opendaylight/current/etc/org.ops4j.pax.logging.cfg
85             name: sdnc-logging-cfg-config
86             subPath: org.ops4j.pax.logging.cfg
87           - mountPath: /opt/onap/sdnc/bin/startODL.sh
88             name: startodl
89             subPath: startODL.sh
90           - mountPath: /opt/onap/sdnc/bin/installSdncDb.sh
91             name: installsdncdb
92             subPath: installSdncDb.sh
93           - mountPath: /opt/onap/sdnc/data/properties/aaiclient.properties
94             name: aaiclient-conf
95             subPath: aaiclient.properties
96           - mountPath: /opt/onap/sdnc/data/properties/dblib.properties
97             name: sdnc-dblib-properties
98             subPath: dblib.properties
99           - mountPath: /opt/onap/sdnc/data/properties/svclogic.properties
100             name: sdnc-svclogic-config
101             subPath: svclogic.properties
102           - mountPath: /opt/onap/sdnc/svclogic/config/svclogic.properties
103             name: onap-sdnc-svclogic-config
104             subPath: svclogic.properties
105           - mountPath: /var/log/onap
106             name: logs
107           resources:
108 {{ toYaml .Values.resources | indent 12 }}
109         {{- if .Values.nodeSelector }}
110         nodeSelector:
111 {{ toYaml .Values.nodeSelector | indent 10 }}
112         {{- end -}}
113         {{- if .Values.affinity }}
114         affinity:
115 {{ toYaml .Values.affinity | indent 10 }}
116         {{- end }}
117
118         # side car containers
119         - name: filebeat-onap
120           image: "{{ .Values.global.loggingRepository }}/{{ .Values.global.loggingImage }}"
121           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
122           volumeMounts:
123           - mountPath: /usr/share/filebeat/filebeat.yml
124             name: filebeat-conf
125             subPath: filebeat.yml
126           - mountPath: /var/log/onap
127             name: logs
128           - mountPath: /usr/share/filebeat/data
129             name: data-filebeat
130       volumes:
131         - name: localtime
132           hostPath:
133             path: /etc/localtime
134         - name: logs
135           emptyDir: {}
136         - name: data-filebeat
137           emptyDir: {}
138         - name: filebeat-conf
139           configMap:
140             name: {{ include "common.fullname" . }}-filebeat-configmap
141         - name: sdnc-logging-cfg-config
142           configMap:
143             name: {{ include "common.fullname" . }}-log-configmap
144         - name: startodl
145           configMap:
146             name: {{ include "common.fullname" . }}-startodl
147             items:
148             - key: startODL.sh
149               path: startODL.sh
150               mode: 0755
151         - name: installsdncdb
152           configMap:
153             name: {{ include "common.fullname" . }}-installsdncdb
154             items:
155             - key: installSdncDb.sh
156               path: installSdncDb.sh
157               mode: 0755
158         - name: aaiclient-conf
159           configMap:
160             name: {{ include "common.fullname" . }}-aaiclient-properties
161             items:
162             - key: aaiclient.properties
163               path: aaiclient.properties
164               mode: 0644
165         - name: sdnc-dblib-properties
166           configMap:
167             name: {{ include "common.fullname" . }}-dblib-properties
168             items:
169             - key: dblib.properties
170               path: dblib.properties
171               mode: 0644
172         - name: sdnc-svclogic-config
173           configMap:
174             name: {{ include "common.fullname" . }}-svclogic-config
175             items:
176             - key: svclogic.properties
177               path: svclogic.properties
178               mode: 0644
179         - name: onap-sdnc-svclogic-config
180           configMap:
181             name: {{ include "common.fullname" . }}-onap-sdnc-svclogic-config
182             items:
183             - key: svclogic.properties
184               path: svclogic.properties
185               mode: 0644
186
187       imagePullSecrets:
188       - name: "{{ include "common.namespace" . }}-docker-registry-key"