|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- apiVersion: apps/v1
- kind: Deployment
- metadata:
- name: {{ template "mysql.fullname" . }}
- namespace: {{ .Release.Namespace }}
- labels:
- app: {{ template "mysql.fullname" . }}
- chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
- release: "{{ .Release.Name }}"
- heritage: "{{ .Release.Service }}"
- {{- with .Values.deploymentAnnotations }}
- annotations:
- {{ toYaml . | indent 4 }}
- {{- end }}
-
- spec:
- strategy:
- {{ toYaml .Values.strategy | indent 4 }}
- selector:
- matchLabels:
- app: {{ template "mysql.fullname" . }}
- release: {{ .Release.Name }}
- template:
- metadata:
- labels:
- app: {{ template "mysql.fullname" . }}
- release: {{ .Release.Name }}
- {{- with .Values.podLabels }}
- {{ toYaml . | indent 8 }}
- {{- end }}
- {{- with .Values.podAnnotations }}
- annotations:
- {{ toYaml . | indent 8 }}
- {{- end }}
- spec:
- {{- if .Values.schedulerName }}
- schedulerName: "{{ .Values.schedulerName }}"
- {{- end }}
- {{- if .Values.imagePullSecrets }}
- imagePullSecrets:
- {{ toYaml .Values.imagePullSecrets | indent 8 }}
- {{- end }}
- {{- if .Values.priorityClassName }}
- priorityClassName: "{{ .Values.priorityClassName }}"
- {{- end }}
- {{- if .Values.securityContext.enabled }}
- securityContext:
- fsGroup: {{ .Values.securityContext.fsGroup }}
- runAsUser: {{ .Values.securityContext.runAsUser }}
- {{- end }}
- serviceAccountName: {{ template "mysql.serviceAccountName" . }}
- initContainers:
- - name: "remove-lost-found"
- image: "{{ .Values.busybox.image}}:{{ .Values.busybox.tag }}"
- imagePullPolicy: {{ .Values.imagePullPolicy | quote }}
- resources:
- {{ toYaml .Values.initContainer.resources | indent 10 }}
- command: ["rm", "-fr", "/var/lib/mysql/lost+found"]
- volumeMounts:
- - name: data
- mountPath: /var/lib/mysql
- {{- if .Values.persistence.subPath }}
- subPath: {{ .Values.persistence.subPath }}
- {{- end }}
- {{- if .Values.extraInitContainers }}
- {{ tpl .Values.extraInitContainers . | indent 6 }}
- {{- end }}
- {{- if .Values.nodeSelector }}
- nodeSelector:
- {{ toYaml .Values.nodeSelector | indent 8 }}
- {{- end }}
- {{- if .Values.affinity }}
- affinity:
- {{ toYaml .Values.affinity | indent 8 }}
- {{- end }}
- {{- if .Values.tolerations }}
- tolerations:
- {{ toYaml .Values.tolerations | indent 8 }}
- {{- end }}
- containers:
- - name: {{ template "mysql.fullname" . }}
- image: "{{ .Values.image }}:{{ .Values.imageTag }}"
- imagePullPolicy: {{ .Values.imagePullPolicy | quote }}
-
- {{- with .Values.args }}
- args:
- {{- range . }}
- - {{ . | quote }}
- {{- end }}
- {{- end }}
- resources:
- {{ toYaml .Values.resources | indent 10 }}
- env:
- {{- if .Values.mysqlAllowEmptyPassword }}
- - name: MYSQL_ALLOW_EMPTY_PASSWORD
- value: "true"
- {{- end }}
- {{- if not (and .Values.allowEmptyRootPassword (not .Values.mysqlRootPassword)) }}
- - name: MYSQL_ROOT_PASSWORD
- valueFrom:
- secretKeyRef:
- name: {{ template "mysql.secretName" . }}
- key: mysql-root-password
- {{- if .Values.mysqlAllowEmptyPassword }}
- optional: true
- {{- end }}
- {{- end }}
- {{- if not (and .Values.allowEmptyRootPassword (not .Values.mysqlPassword)) }}
- - name: MYSQL_PASSWORD
- valueFrom:
- secretKeyRef:
- name: {{ template "mysql.secretName" . }}
- key: mysql-password
- {{- if or .Values.mysqlAllowEmptyPassword (empty .Values.mysqlUser) }}
- optional: true
- {{- end }}
- {{- end }}
- - name: MYSQL_USER
- value: {{ default "" .Values.mysqlUser | quote }}
- - name: MYSQL_DATABASE
- value: {{ default "" .Values.mysqlDatabase | quote }}
- {{- if .Values.timezone }}
- - name: TZ
- value: {{ .Values.timezone }}
- {{- end }}
- {{- if .Values.extraEnvVars }}
- {{ tpl .Values.extraEnvVars . | indent 8 }}
- {{- end }}
- ports:
- - name: mysql
- containerPort: 3306
- {{- if .Values.mysqlx.port.enabled }}
- - name: mysqlx
- port: 33060
- {{- end }}
- livenessProbe:
- exec:
- command:
- {{- if .Values.mysqlAllowEmptyPassword }}
- - mysqladmin
- - ping
- {{- else }}
- - sh
- - -c
- - "mysqladmin ping -u root -p${MYSQL_ROOT_PASSWORD}"
- {{- end }}
- initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
- periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
- timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
- successThreshold: {{ .Values.livenessProbe.successThreshold }}
- failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
- readinessProbe:
- exec:
- command:
- {{- if .Values.mysqlAllowEmptyPassword }}
- - mysqladmin
- - ping
- {{- else }}
- - sh
- - -c
- - "mysqladmin ping -u root -p${MYSQL_ROOT_PASSWORD}"
- {{- end }}
- initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
- periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
- timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
- successThreshold: {{ .Values.readinessProbe.successThreshold }}
- failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
- volumeMounts:
- - name: data
- mountPath: /var/lib/mysql
- {{- if .Values.persistence.subPath }}
- subPath: {{ .Values.persistence.subPath }}
- {{- end }}
- {{- if .Values.configurationFiles }}
- {{- range $key, $val := .Values.configurationFiles }}
- - name: configurations
- mountPath: {{ $.Values.configurationFilesPath }}{{ $key }}
- subPath: {{ $key }}
- {{- end -}}
- {{- end }}
- {{- if .Values.initializationFiles }}
- - name: migrations
- mountPath: /docker-entrypoint-initdb.d
- {{- end }}
- {{- if .Values.ssl.enabled }}
- - name: certificates
- mountPath: /ssl
- {{- end }}
- {{- if .Values.extraVolumeMounts }}
- {{ tpl .Values.extraVolumeMounts . | indent 8 }}
- {{- end }}
- {{- if .Values.metrics.enabled }}
- - name: metrics
- image: "{{ .Values.metrics.image }}:{{ .Values.metrics.imageTag }}"
- imagePullPolicy: {{ .Values.metrics.imagePullPolicy | quote }}
- {{- if .Values.mysqlAllowEmptyPassword }}
- command:
- - 'sh'
- - '-c'
- - 'DATA_SOURCE_NAME="root@(localhost:3306)/" /bin/mysqld_exporter'
- {{- else }}
- env:
- - name: MYSQL_ROOT_PASSWORD
- valueFrom:
- secretKeyRef:
- name: {{ template "mysql.secretName" . }}
- key: mysql-root-password
- command:
- - 'sh'
- - '-c'
- - 'DATA_SOURCE_NAME="root:$MYSQL_ROOT_PASSWORD@(localhost:3306)/" /bin/mysqld_exporter'
- {{- end }}
- {{- range $f := .Values.metrics.flags }}
- - {{ $f | quote }}
- {{- end }}
- ports:
- - name: metrics
- containerPort: 9104
- livenessProbe:
- httpGet:
- path: /
- port: metrics
- initialDelaySeconds: {{ .Values.metrics.livenessProbe.initialDelaySeconds }}
- timeoutSeconds: {{ .Values.metrics.livenessProbe.timeoutSeconds }}
- readinessProbe:
- httpGet:
- path: /
- port: metrics
- initialDelaySeconds: {{ .Values.metrics.readinessProbe.initialDelaySeconds }}
- timeoutSeconds: {{ .Values.metrics.readinessProbe.timeoutSeconds }}
- resources:
- {{ toYaml .Values.metrics.resources | indent 10 }}
- {{- end }}
- volumes:
- {{- if .Values.configurationFiles }}
- - name: configurations
- configMap:
- name: {{ template "mysql.fullname" . }}-configuration
- {{- end }}
- {{- if .Values.initializationFiles }}
- - name: migrations
- configMap:
- name: {{ template "mysql.fullname" . }}-initialization
- {{- end }}
- {{- if .Values.ssl.enabled }}
- - name: certificates
- secret:
- secretName: {{ .Values.ssl.secret }}
- {{- end }}
- - name: data
- {{- if .Values.persistence.enabled }}
- persistentVolumeClaim:
- claimName: {{ .Values.persistence.existingClaim | default (include "mysql.fullname" .) }}
- {{- else }}
- emptyDir: {}
- {{- end -}}
- {{- if .Values.extraVolumes }}
- {{ tpl .Values.extraVolumes . | indent 6 }}
- {{- end }}
|