Helm charts for supporting clustering in ODL
[integration/packaging.git] / helm / opendaylight / templates / statefulset.yaml
1 {{/*
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2021 The Linux Foundation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11 */}}
12
13 apiVersion: apps/v1
14 kind: StatefulSet
15 metadata:
16   name: {{ include "opendaylight.fullname" . }}
17 spec:
18   {{- if not .Values.autoscaling.enabled }}
19   replicas: {{ .Values.replicaCount }}
20   {{- end }}
21   podManagementPolicy: Parallel
22   serviceName: {{ include "opendaylight.fullname" . }}
23   selector:
24     matchLabels:
25       {{- include "opendaylight.selectorLabels" . | nindent 6 }}
26   template:
27     metadata:
28       {{- with .Values.podAnnotations }}
29       annotations:
30         {{- toYaml . | nindent 8 }}
31       {{- end }}
32       labels:
33         {{- include "opendaylight.selectorLabels" . | nindent 8 }}
34     spec:
35       {{- with .Values.imagePullSecrets }}
36       imagePullSecrets:
37         {{- toYaml . | nindent 8 }}
38       {{- end }}
39       serviceAccountName: {{ include "opendaylight.serviceAccountName" . }}
40       securityContext:
41         {{- toYaml .Values.podSecurityContext | nindent 8 }}
42       initContainers:
43         - name: updatevolperm
44           image: busybox
45           command: ['chown','8181','/data']
46           volumeMounts:
47           - name: {{ .Values.persistence.volName }}
48             mountPath: {{ .Values.persistence.mountPath }}
49         {{- if .Values.config.isClusterDeployment }}
50         - name: inject-cluster-related-conf
51           image: busybox
52           command: ["/bin/sh"]
53           args: ["-c", "cp /config-input/akka.conf /config/akka.conf"]
54           volumeMounts:
55             - mountPath: /config-input/akka.conf
56               name: config-input
57               subPath: akka.conf
58             - mountPath: /config
59               name: update-conf
60         {{- end }}
61       containers:
62         - name: {{ .Chart.Name }}
63           securityContext:
64             {{- toYaml .Values.securityContext | nindent 12 }}
65           image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
66           imagePullPolicy: {{ .Values.image.pullPolicy }}
67           command: ['bash','-c','bash -x /scripts/startodl.sh']
68           env:
69           - name: FEATURES
70             value: "{{ .Values.config.features }}"
71           - name: JAVA_HOME
72             value: "{{ .Values.config.javaHome}}"
73           - name: JAVA_OPTS
74             value: "-Xms{{.Values.config.javaOptions.minMemory}} -Xmx{{.Values.config.javaOptions.maxMemory}}"
75           - name: EXTRA_JAVA_OPTS
76             value: "-XX:+UseG1GC -XX:MaxGCPauseMillis={{.Values.config.javaOptions.maxGCPauseMillis}} -XX:ParallelGCThreads={{.Values.config.javaOptions.parallelGCThreads}} -XX:+ParallelRefProcEnabled -XX:+UseStringDeduplication {{.Values.config.javaOptions.gcLogOptions}}"
77           - name: ODL_REPLICAS
78             value: "{{ .Values.replicaCount }}"
79           - name: IS_CLUSTER_ENABLED
80             value: "{{ .Values.config.isClusterDeployment }}"
81           ports:
82             - name: http
83               containerPort: {{ .Values.service.port }}
84               protocol: TCP
85             {{- if .Values.config.isClusterDeployment }}
86             - name: cluster
87               containerPort: {{ .Values.service.clusterPort }}
88               protocol: TCP
89             {{- end }}
90           readinessProbe:
91             tcpSocket:
92               port: {{ .Values.service.port }}
93             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
94             periodSeconds: {{ .Values.readiness.periodSeconds }}
95           resources:
96             {{- toYaml .Values.resources | nindent 12 }}
97           volumeMounts:
98           - name: {{ .Values.persistence.volName }}
99             mountPath: {{ .Values.persistence.mountPath }}
100           - name: scripts
101             mountPath: /scripts
102           {{- if .Values.config.isClusterDeployment }}
103           - mountPath: {{ .Values.cluster.salConfigDir }}/{{ .Values.cluster.salConfigVersion}}/sal-clustering-config-{{ .Values.cluster.salConfigVersion}}-akkaconf.xml
104             name: update-conf
105             subPath: akka.conf
106           {{- end }}
107       {{- with .Values.nodeSelector }}
108       nodeSelector:
109         {{- toYaml . | nindent 8 }}
110       {{- end }}
111       {{- with .Values.affinity }}
112       affinity:
113         {{- toYaml . | nindent 8 }}
114       {{- end }}
115       {{- with .Values.tolerations }}
116       tolerations:
117         {{- toYaml . | nindent 8 }}
118       {{- end }}
119       volumes:
120         - name: scripts
121           configMap:
122             name: {{ include "opendaylight.fullname" . }}-scripts
123         {{- if .Values.config.isClusterDeployment }}
124         - name: config-input
125           configMap:
126             name: {{ include "opendaylight.fullname" . }}-conf
127             defaultMode: 0755
128         - name: update-conf
129           emptyDir:
130             medium: Memory
131         {{- end }}
132   {{ if not .Values.persistence.enabled }}
133         - name: {{ .Values.persistence.volName }} 
134           emptyDir: {}
135   {{ else }}
136   volumeClaimTemplates:
137   - metadata:
138       name: {{ .Values.persistence.volName }} 
139     spec:
140       accessModes:
141       - {{ .Values.persistence.accessMode }}
142       storageClassName: {{ .Values.persistence.storageClass }}
143       resources:
144         requests:
145           storage: {{ .Values.persistence.size }}
146   {{- end }}