Merge "Add OOM chart for SDNC ansible server pod"
[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: {{ include "common.servicename" . }}-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: "{{ include "common.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: ODL_ADMIN_PASSWORD
73               valueFrom:
74                 secretKeyRef:
75                   name: {{ template "common.fullname" . }}-odl
76                   key: odl-password
77             - name: SDNC_CONFIG_DIR
78               value: "{{ .Values.config.configDir }}"
79             - name: ENABLE_ODL_CLUSTER
80               value: "{{ .Values.config.enableClustering }}"
81             - name: SDNC_REPLICAS
82               value: "{{ .Values.replicaCount }}"
83             - name: MYSQL_HOST
84               value: "{{.Values.mysql.service.name}}.{{.Release.Namespace}}"
85           volumeMounts:
86           - mountPath: /etc/localtime
87             name: localtime
88             readOnly: true
89           - mountPath: /opt/opendaylight/current/etc/org.ops4j.pax.logging.cfg
90             name: sdnc-logging-cfg-config
91             subPath: org.ops4j.pax.logging.cfg
92           - mountPath: {{ .Values.config.binDir }}/startODL.sh
93             name: bin
94             subPath: startODL.sh
95           - mountPath: {{ .Values.config.binDir }}/installSdncDb.sh
96             name: bin
97             subPath: installSdncDb.sh
98           - mountPath: {{ .Values.config.configDir }}/aaiclient.properties
99             name: properties
100             subPath: aaiclient.properties
101           - mountPath: {{ .Values.config.configDir }}/dblib.properties
102             name: properties
103             subPath: dblib.properties
104           - mountPath: {{ .Values.config.configDir }}/lcm-dg.properties
105             name: properties
106             subPath: lcm-dg.properties
107           - mountPath: {{ .Values.config.configDir }}/svclogic.properties
108             name: properties
109             subPath: svclogic.properties
110           - mountPath: /opt/onap/sdnc/svclogic/config/svclogic.properties
111             name: properties
112             subPath: svclogic.properties
113           - mountPath: {{ .Values.persistence.mdsalPath }}
114             name: {{ include "common.fullname" . }}-data
115           - mountPath: /var/log/onap
116             name: logs
117           resources:
118 {{ toYaml .Values.resources | indent 12 }}
119         {{- if .Values.nodeSelector }}
120         nodeSelector:
121 {{ toYaml .Values.nodeSelector | indent 10 }}
122         {{- end -}}
123         {{- if .Values.affinity }}
124         affinity:
125 {{ toYaml .Values.affinity | indent 10 }}
126         {{- end }}
127
128         # side car containers
129         - name: filebeat-onap
130           image: "{{ .Values.global.loggingRepository }}/{{ .Values.global.loggingImage }}"
131           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
132           volumeMounts:
133           - mountPath: /usr/share/filebeat/filebeat.yml
134             name: filebeat-conf
135             subPath: filebeat.yml
136           - mountPath: /var/log/onap
137             name: logs
138           - mountPath: /usr/share/filebeat/data
139             name: data-filebeat
140       imagePullSecrets:
141       - name: "{{ include "common.namespace" . }}-docker-registry-key"
142       volumes:
143         - name: localtime
144           hostPath:
145             path: /etc/localtime
146         - name: logs
147           emptyDir: {}
148         - name: data-filebeat
149           emptyDir: {}
150         - name: filebeat-conf
151           configMap:
152             name: {{ include "common.fullname" . }}-filebeat-configmap
153         - name: sdnc-logging-cfg-config
154           configMap:
155             name: {{ include "common.fullname" . }}-log-configmap
156         - name: bin
157           configMap:
158             name: {{ include "common.fullname" . }}-bin
159             defaultMode: 0755
160         - name: properties
161           configMap:
162             name: {{ include "common.fullname" . }}-properties
163             defaultMode: 0644
164   {{ if not .Values.persistence.enabled }}
165         - name: {{ include "common.fullname" . }}-data
166           emptyDir: {}
167   {{ else }}
168   volumeClaimTemplates:
169   - metadata:
170       name: {{ include "common.fullname" . }}-data
171       labels:
172         name: {{ include "common.fullname" . }}
173     spec:
174       accessModes: [ {{ .Values.persistence.accessMode }} ]
175       storageClassName: {{ include "common.fullname" . }}-data
176       resources:
177         requests:
178           storage: {{ .Values.persistence.size }}
179   {{ end }}