RIC-919 Upgrade influxdb helm chart v1.8 > v2.2
[ric-plt/ric-dep.git] / helm / 3rdparty / influxdb / templates / statefulset.yaml
1 apiVersion: apps/v1
2 kind: StatefulSet
3 metadata:
4   name: {{ template "influxdb.fullname" . }}
5   labels:
6     {{- include "influxdb.labels" . | nindent 4 }}
7 spec:
8   replicas: 1
9   selector:
10     matchLabels:
11       {{- include "influxdb.selectorLabels" . | nindent 6 }}
12   serviceName: "{{ include "influxdb.fullname" . }}"
13   template:
14     metadata:
15       labels:
16       {{- include "influxdb.selectorLabels" . | nindent 8 }}
17       {{- if .Values.podLabels }}
18 {{ toYaml .Values.podLabels | indent 8 }}
19       {{- end }}
20       {{- if .Values.podAnnotations }}
21       annotations:
22 {{ toYaml .Values.podAnnotations | indent 8 }}
23       {{- end }}
24     spec:
25       volumes:
26         - name: data
27         {{- if .Values.persistence.enabled }}
28           {{- if not (empty .Values.persistence.name) }}
29           persistentVolumeClaim:
30             claimName: {{ .Values.persistence.name }}
31           {{- else }}
32           persistentVolumeClaim:
33             claimName: {{ template "influxdb.fullname" . }}
34           {{- end }}
35         {{- else }}
36           emptyDir: {}
37         {{- end }}
38         {{- if .Values.initScripts.enabled }}
39         - name: init
40           configMap:
41             name: {{ include "influxdb.fullname" . }}-init
42             defaultMode: 0744
43         {{- end }}
44         {{- if .Values.volumes }}
45           {{- toYaml .Values.volumes | nindent 8 }}
46         {{- end }}
47       serviceAccountName: {{ include "influxdb.serviceAccountName" . }}
48       containers:
49         - name: {{ .Chart.Name }}
50           image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
51           imagePullPolicy: {{ .Values.image.pullPolicy }}
52           ports:
53             - name: {{ .Values.service.portName }}
54               containerPort: 8086
55               protocol: TCP
56           env:
57             # Automated setup will not run if an existing boltdb file is found at the configured path.
58             # This behavior allows for the InfluxDB container to reboot post-setup without encountering "DB is already set up" errors.
59             - name: DOCKER_INFLUXDB_INIT_MODE
60               value: setup
61             # The username to set for the system's initial super-user (Required).
62             - name: DOCKER_INFLUXDB_INIT_USERNAME
63               value: {{ .Values.adminUser.user }}
64             # The password to set for the system's inital super-user (Required).
65             - name: DOCKER_INFLUXDB_INIT_PASSWORD
66               valueFrom:
67                 secretKeyRef:
68                   {{- if .Values.adminUser.existingSecret }}
69                   name: {{ .Values.adminUser.existingSecret -}}
70                   {{ else }}
71                   name: {{ template "influxdb.fullname" . }}-auth
72                   {{- end }}
73                   key: admin-password
74             # The name to set for the system's initial organization (Required).
75             - name: DOCKER_INFLUXDB_INIT_ORG
76               value: {{ .Values.adminUser.organization }}
77             # The name to set for the system's initial bucket (Required).
78             - name: DOCKER_INFLUXDB_INIT_BUCKET
79               value: {{ .Values.adminUser.bucket }}
80             # The duration the system's initial bucket should retain data. If not set, the initial bucket will retain data forever.
81             - name: DOCKER_INFLUXDB_INIT_RETENTION
82               value: {{ .Values.adminUser.retention_policy }}
83             # The authentication token to associate with the system's initial super-user. If not set, a token will be auto-generated by the system.
84             - name: DOCKER_INFLUXDB_INIT_ADMIN_TOKEN
85               valueFrom:
86                 secretKeyRef:
87                   {{- if .Values.adminUser.existingSecret }}
88                   name: {{ .Values.adminUser.existingSecret -}}
89                   {{ else }}
90                   name: {{ template "influxdb.fullname" . }}-auth
91                   {{- end }}
92                   key: admin-token
93             # Path to the BoltDB database.
94             - name: INFLUXD_BOLT_PATH
95               value: {{ .Values.persistence.mountPath }}/influxd.bolt
96             # Path to persistent storage engine files where InfluxDB stores all Time-Structure Merge Tree (TSM) data on disk.
97             - name: INFLUXD_ENGINE_PATH
98               value: {{ .Values.persistence.mountPath }}
99             {{- with .Values.env }}
100             # Extra environment variables from .Values.env
101             {{- toYaml . | nindent 12 }}
102             {{- end }}
103           {{- if .Values.securityContext }}
104           securityContext:
105             {{- toYaml .Values.securityContext | nindent 12 }}
106           {{- end }}
107           livenessProbe:
108             httpGet:
109               path: {{ .Values.livenessProbe.path | default "/health" }}
110               port: http
111               scheme: {{ .Values.livenessProbe.scheme | default "HTTP" }}
112             initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds | default 0 }}
113             periodSeconds: {{ .Values.livenessProbe.periodSeconds | default 10 }}
114             timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds | default 1 }}
115             failureThreshold: {{ .Values.livenessProbe.failureThreshold | default 3 }}
116           readinessProbe:
117             httpGet:
118               path: {{ .Values.readinessProbe.path | default "/health" }}
119               port: http
120               scheme: {{ .Values.readinessProbe.scheme | default "HTTP" }}
121             initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds | default 0 }}
122             periodSeconds: {{ .Values.readinessProbe.periodSeconds | default 10 }}
123             timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds | default 1 }}
124             successThreshold: {{ .Values.readinessProbe.successThreshold | default 1 }}
125             failureThreshold: {{ .Values.readinessProbe.failureThreshold | default 3 }}
126           {{- if .Values.startupProbe.enabled }}
127           startupProbe:
128             httpGet:
129               path: {{ .Values.startupProbe.path | default "/health" }}
130               port: http
131               scheme: {{ .Values.startupProbe.scheme | default "HTTP" }}
132             initialDelaySeconds: {{ .Values.startupProbe.initialDelaySeconds | default 30 }}
133             periodSeconds: {{ .Values.startupProbe.periodSeconds | default 5 }}
134             timeoutSeconds: {{ .Values.startupProbe.timeoutSeconds | default 1 }}
135             failureThreshold: {{ .Values.startupProbe.failureThreshold | default 6 }}
136           {{- end }}
137           volumeMounts:
138           - name: data
139             mountPath: {{ .Values.persistence.mountPath }}
140             subPath: {{ .Values.persistence.subPath }}
141           {{- if .Values.initScripts.enabled }}
142           - name: init
143             mountPath: /docker-entrypoint-initdb.d
144           {{- end }}
145           {{- if .Values.mountPoints }}
146             {{- toYaml .Values.mountPoints | nindent 10 }}
147           {{- end }}
148           resources:
149             {{ .Values.resources | toYaml | nindent 12 | trim }}
150
151       {{- if .Values.securityContext.runAsGroup }}
152       securityContext:
153         fsGroup: {{ .Values.securityContext.runAsGroup }}
154       {{- end }}
155       {{- with .Values.nodeSelector }}
156       nodeSelector:
157         {{ toYaml . | nindent 8 | trim }}
158       {{- end }}
159
160       {{- with .Values.affinity }}
161       affinity:
162         {{ toYaml . | nindent 8 | trim }}
163       {{- end }}
164
165       {{- with .Values.tolerations }}
166       tolerations:
167         {{ toYaml . | nindent 8 | trim }}
168       {{- end }}