13eda03d39177568da05db2d888a0d533cf3d5c6
[ric-plt/ric-dep.git] / helm / 3rdparty / influxdb / templates / statefulset.yaml
1 apiVersion: apps/v1
2 kind: StatefulSet
3 metadata:
4   name: {{ include "influxdb.fullname" . }}
5   labels:
6     {{- include "influxdb.labels" . | nindent 4 }}
7 spec:
8   {{- if .Values.enterprise.enabled }}
9   replicas: {{ .Values.enterprise.clusterSize }}
10   {{ else }}
11   replicas: 1
12   {{- end}}
13   selector:
14     matchLabels:
15       {{- include "influxdb.selectorLabels" . | nindent 6 }}
16   serviceName: "{{ include "influxdb.fullname" . }}"
17   template:
18     metadata:
19       labels:
20         {{- include "influxdb.selectorLabels" . | nindent 8 }}
21       {{- if .Values.podAnnotations }}
22       annotations:
23 {{ toYaml .Values.podAnnotations | indent 8 }}
24       {{- end }}
25     spec:
26       {{- if .Values.schedulerName }}
27       schedulerName: "{{ .Values.schedulerName }}"
28       {{- end }}
29       {{- if .Values.nodeSelector }}
30       nodeSelector:
31 {{ toYaml .Values.nodeSelector | indent 8 }}
32       {{- end -}}
33       {{- if .Values.affinity }}
34       affinity:
35 {{ toYaml .Values.affinity | indent 8 }}
36       {{- end }}
37       {{- if .Values.tolerations }}
38       tolerations:
39 {{ toYaml .Values.tolerations | indent 8 }}
40       {{- end }}
41       {{- if .Values.securityContext }}
42       securityContext:
43 {{ toYaml .Values.securityContext | indent 8 }}
44       {{- end }}
45       {{- if .Values.image.pullSecrets }}
46       imagePullSecrets:
47       {{- range .Values.image.pullSecrets }}
48         - name: {{ . }}
49       {{- end}}
50       {{- end }}
51       serviceAccountName: {{ include "influxdb.serviceAccountName" . }}
52       containers:
53       - name: {{ include "influxdb.fullname" . }}
54         image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
55         imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
56         resources:
57 {{ toYaml .Values.resources | indent 10 }}
58         ports:
59         - name: api
60           containerPort: {{ .Values.config.http.bind_address | default 8086 }}
61         {{- if .Values.config.graphite.enabled }}
62         - name: graphite
63           containerPort: {{ .Values.config.graphite.bind_address | default 2003 }}
64         {{- end }}
65         {{- if .Values.config.collectd.enabled }}
66         - name: collectd
67           containerPort: {{ .Values.config.collectd.bind_address |  default 25826 }}
68           protocol: UDP
69         {{- end }}
70         {{- if .Values.config.udp.enabled }}
71         - name: udp
72           containerPort: {{ .Values.config.udp.bind_address | default 8089 }}
73           protocol: UDP
74         {{- end }}
75         {{- if .Values.config.opentsdb.enabled }}
76         - name: opentsdb
77           containerPort: {{ .Values.config.opentsdb.bind_address |  default 4242 }}
78         {{- end }}
79         - name: rpc
80           containerPort: {{ .Values.config.rpc.bind_address | default 8088 }}
81         {{- if .Values.enterprise.enabled }}
82         - name: meta
83           containerPort: {{ .Values.config.meta.bind_address | default 8091 }}
84         {{- end }}
85         {{- if .Values.env }}
86         env:
87 {{ toYaml .Values.env | indent 10 }}
88         {{- if .Values.enterprise.enabled }}
89           - name: INFLUXDB_HOSTNAME # Values.env's HOSTNAME isn't fundamentally different from $HOSTNAME, but this way weg get a distinguished name at runtime.
90             value: "$(_HOSTNAME).{{ include "influxdb.fullname" . }}"
91         {{- end }}
92         {{- end }}
93         {{- if .Values.envFromSecret }}
94         envFrom:
95         - secretRef:
96             name: {{ .Values.envFromSecret }}
97         {{- end }}
98         livenessProbe:
99           httpGet:
100             path: {{ .Values.livenessProbe.path | default "/ping" }}
101             port: api
102             scheme: {{ .Values.livenessProbe.scheme | default "HTTP" }}
103           initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds | default 30 }}
104           timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds | default 5 }}
105         readinessProbe:
106           httpGet:
107             path: {{ .Values.readinessProbe.path | default "/ping" }}
108             port: api
109             scheme: {{ .Values.readinessProbe.scheme | default "HTTP" }}
110           initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds | default 5 }}
111           timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds | default 1 }}
112         {{- if .Values.startupProbe.enabled }}
113         startupProbe:
114           httpGet:
115             path: {{ .Values.startupProbe.path | default "/ping" }}
116             port: api
117             scheme: {{ .Values.startupProbe.scheme | default "HTTP" }}
118           failureThreshold: {{ .Values.startupProbe.failureThreshold | default 6 }}
119           periodSeconds: {{ .Values.startupProbe.periodSeconds | default 5 }}
120         {{- end }}
121         volumeMounts:
122         - name: {{ include "influxdb.fullname" . }}-data
123           mountPath: /var/lib/influxdb
124         - name: config
125           mountPath: /etc/influxdb
126         {{- if .Values.initScripts.enabled }}
127         - name: init
128           mountPath: /docker-entrypoint-initdb.d
129         {{- end }}
130         {{- if .Values.mountPoints }}
131 {{ toYaml .Values.mountPoints | indent 8 }}
132         {{- end }}
133       {{- if .Values.extraContainers }}
134 {{ toYaml .Values.extraContainers | indent 6}}
135       {{- end }}
136       volumes:
137       - name: config
138         configMap:
139           name: {{ include "influxdb.fullname" . }}
140       {{- if .Values.initScripts.enabled }}
141       - name: init
142         configMap:
143           name: {{ include "influxdb.fullname" . }}-init
144       {{- end }}
145       {{- if (not .Values.persistence.enabled ) }}
146       - name: {{ include "influxdb.fullname" . }}-data
147         emptyDir: {}
148       {{- end }}
149       # Cannot use existing claim in enterprise mode
150       {{- if and .Values.persistence.enabled .Values.persistence.existingClaim (not .Values.enterprise.enabled) }}
151       - name: {{ include "influxdb.fullname" . }}-data
152         persistentVolumeClaim:
153           claimName: {{ .Values.persistence.existingClaim }}
154       {{- end }}
155       {{- if .Values.volumes }}
156 {{ toYaml .Values.volumes | indent 6 }}
157       {{- end }}
158   # Must use volume claim template in enterprise mode
159   {{- if and .Values.persistence.enabled (or (not .Values.persistence.existingClaim) .Values.enterprise.enabled) }}
160   volumeClaimTemplates:
161     - metadata:
162         name: {{ include "influxdb.fullname" . }}-data
163         annotations:
164         {{- range $key, $value := .Values.persistence.annotations }}
165           {{ $key }}: "{{ $value }}"
166         {{- end }}
167       spec:
168         accessModes:
169           - {{ .Values.persistence.accessMode | quote}}
170         resources:
171           requests:
172             storage: {{ .Values.persistence.size | quote }}
173       {{- if .Values.persistence.storageClass }}
174       {{- if (eq "-" .Values.persistence.storageClass) }}
175         storageClassName: ""
176       {{- else }}
177         storageClassName: "{{ .Values.persistence.storageClass }}"
178       {{- end }}
179       {{- end }}
180   {{- end }}