Files
charts/bitnami/consul/templates/statefulset.yaml
Juan Ariza Toledano eed0bb0914 [bitnami/consul] Create pods in parallel (#1943)
Signed-off-by: juan131 <juan@bitnami.com>
2020-02-18 14:19:51 +01:00

247 lines
9.6 KiB
YAML

apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ template "consul.fullname" . }}
labels: {{- include "consul.labels" . | nindent 4 }}
spec:
selector:
matchLabels: {{- include "consul.matchLabels" . | nindent 6 }}
serviceName: {{ template "consul.fullname" . }}
replicas: {{ .Values.replicas }}
podManagementPolicy: Parallel
updateStrategy:
type: {{ .Values.updateStrategy.type }}
{{- if (eq "Recreate" .Values.updateStrategy.type) }}
rollingUpdate: null
{{- end }}
template:
metadata:
labels: {{- include "consul.labels" . | nindent 8 }}
{{- if or .Values.podAnnotations (and .Values.metrics.enabled .Values.metrics.podAnnotations) }}
annotations:
{{- if .Values.podAnnotations }}
{{- toYaml .Values.podAnnotations | nindent 8 }}
{{- end }}
{{- if .Values.metrics.podAnnotations }}
{{- toYaml .Values.metrics.podAnnotations | nindent 8 }}
{{- end }}
{{- end }}
spec:
{{- include "consul.imagePullSecrets" . | indent 6 }}
{{- if .Values.affinity }}
affinity: {{- include "consul.tplValue" (dict "value" .Values.affinity "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.nodeSelector }}
nodeSelector: {{- include "consul.tplValue" (dict "value" .Values.nodeSelector "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.tolerations }}
tolerations: {{- include "consul.tplValue" (dict "value" .Values.tolerations "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.securityContext.enabled }}
securityContext:
fsGroup: {{ .Values.securityContext.fsGroup }}
runAsUser: {{ .Values.securityContext.runAsUser }}
{{- end }}
{{- if and .Values.volumePermissions.enabled .Values.persistence.enabled }}
initContainers:
- name: volume-permissions
image: {{ include "consul.volumePermissions.image" . }}
imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }}
command:
- /bin/bash
- -ec
- |
chown -R {{ .Values.securityContext.runAsUser }}:{{ .Values.securityContext.fsGroup }} /bitnami/consul
securityContext:
runAsUser: 0
{{- if .Values.volumePermissions.resources }}
resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }}
{{- end }}
volumeMounts:
- name: data
mountPath: /bitnami/consul
{{- end }}
containers:
- name: consul
image: {{ include "consul.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
- name: rpc
containerPort: {{ .Values.service.rpcPort }}
- name: serflan-tcp
protocol: "TCP"
containerPort: {{ .Values.service.serflanPort }}
- name: serflan-udp
protocol: "UDP"
containerPort: {{ .Values.service.serflanPort }}
- name: server
containerPort: {{ .Values.service.serverPort }}
- name: consuldns-tcp
containerPort: {{ .Values.service.consulDnsPort }}
- name: consuldns-udp
protocol: "UDP"
containerPort: {{ .Values.service.consulDnsPort }}
{{- if .Values.resources }}
resources: {{- toYaml .Values.resources | nindent 12 }}
{{- end }}
env:
{{- $consulFullName := include "consul.fullname" . }}
{{- $consulHeadlessSvcName := include "consul.fullname" . }}
{{- $clusterDomain := .Values.clusterDomain }}
- name: BITNAMI_DEBUG
value: {{ ternary "true" "false" .Values.image.debug | quote }}
- name: CONSUL_RETRY_JOIN
value: {{ printf "%s-0.%s.%s.svc.%s" $consulFullName $consulHeadlessSvcName .Release.Namespace $clusterDomain | quote }}
- name: CONSUL_DISABLE_KEYRING_FILE
value: "true"
- name: CONSUL_BOOTSTRAP_EXPECT
value: {{ default 3 .Values.replicas | quote }}
- name: CONSUL_BOOTSTRAP_EXPECT
value: {{ .Values.replicas | quote }}
- name: CONSUL_RAFT_MULTIPLIER
value: {{ .Values.raftMultiplier | quote }}
- name: CONSUL_DOMAIN
value: "{{ .Values.domain }}"
- name: CONSUL_DATACENTER
value: "{{ .Values.datacenterName }}"
{{- if .Values.gossipKey }}
- name: CONSUL_GOSSIP_ENCRYPTION_KEY
valueFrom:
secretKeyRef:
name: {{ template "consul.fullname" . }}-gossip-key
key: gossip-key
{{- end }}
{{- if .Values.localConfig }}
- name: CONSUL_LOCAL_CONFIG
value: |- {{- .Values.localConfig | nindent 12 }}
{{- end }}
- name: CONSUL_UI
value: "{{ .Values.ui.service.enabled }}"
- name: CONSUL_HTTP_PORT_NUMBER
value: {{ .Values.service.port | quote}}
- name: CONSUL_DNS_PORT_NUMBER
value: {{ .Values.service.consulDnsPort | quote }}
- name: CONSUL_RPC_PORT_NUMBER
value: {{ .Values.service.serverPort | quote }}
- name: CONSUL_SERF_LAN_PORT_NUMBER
value: {{ .Values.service.serflanPort | quote }}
{{- if .Values.livenessProbe.enabled }}
livenessProbe:
exec:
command:
- consul
- operator
- raft
- list-peers
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
successThreshold: {{ .Values.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
{{- end }}
{{- if .Values.readinessProbe.enabled }}
readinessProbe:
exec:
command:
- consul
- members
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
successThreshold: {{ .Values.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
{{- end }}
lifecycle:
preStop:
exec:
command:
- consul
- leave
volumeMounts:
{{- if .Values.tlsEncryptionSecretName }}
- name: consul-tls-certs
mountPath: "/opt/bitnami/consul/certificates/"
readOnly: true
{{- end }}
{{- if .Values.persistence.enabled }}
- name: data
mountPath: /bitnami/consul
{{- end }}
{{- if .Values.configmap }}
- name: consul-config
mountPath: /opt/bitnami/consul/conf/config.json
subPath: config.json
- name: consul-config
mountPath: /opt/bitnami/consul/conf/connection.json
subPath: connection.json
{{- end }}
{{- if .Values.metrics.enabled }}
- name: metrics
image: "{{ template "consul.metrics.image" . }}"
imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }}
command:
- /bin/consul_exporter
- --consul.server={{ template "consul.fullname" . }}:{{ .Values.service.port }}
ports:
- name: metrics
containerPort: 9107
livenessProbe:
httpGet:
path: /metrics
port: metrics
initialDelaySeconds: 15
timeoutSeconds: 5
readinessProbe:
httpGet:
path: /metrics
port: metrics
initialDelaySeconds: 5
timeoutSeconds: 1
{{- if .Values.metrics.resources }}
resources: {{- toYaml .Values.metrics.resources | nindent 12 }}
{{- end }}
{{- end }}
{{- if or .Values.configmap .Values.tlsEncryptionSecretName (not .Values.persistence.enabled) }}
volumes:
{{- end }}
{{- if .Values.configmap }}
- name: consul-config
configMap:
name: {{ template "consul.fullname" . }}-configuration
{{- end }}
{{- if .Values.tlsEncryptionSecretName }}
- name: consul-tls-certs
secret:
secretName: {{ .Values.tlsEncryptionSecretName }}
items:
- key: ca.pem
path: ca.pem
- key: consul.pem
path: consul.pem
- key: consul-key.pem
path: consul.key.pem
{{- end }}
{{- if not .Values.persistence.enabled }}
- name: data
emptyDir: {}
{{- else }}
volumeClaimTemplates:
- metadata:
name: data
annotations:
{{- range $key, $value := .Values.persistence.annotations }}
{{ $key }}: {{ $value }}
{{- end }}
spec:
accessModes:
{{- range .Values.persistence.accessModes }}
- {{ . | quote }}
{{- end }}
resources:
requests:
storage: {{ .Values.persistence.size | quote }}
{{ include "consul.storageClass" . }}
{{- end }}