|
| 1 | +apiVersion: apps/v1 |
| 2 | +kind: Deployment |
| 3 | +metadata: |
| 4 | + name: {{ template "mysql.fullname" . }} |
| 5 | + namespace: {{ .Release.Namespace }} |
| 6 | + labels: |
| 7 | + app: {{ template "mysql.fullname" . }} |
| 8 | + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" |
| 9 | + release: "{{ .Release.Name }}" |
| 10 | + heritage: "{{ .Release.Service }}" |
| 11 | +{{- with .Values.deploymentAnnotations }} |
| 12 | + annotations: |
| 13 | +{{ toYaml . | indent 4 }} |
| 14 | +{{- end }} |
| 15 | + |
| 16 | +spec: |
| 17 | + strategy: |
| 18 | +{{ toYaml .Values.strategy | indent 4 }} |
| 19 | + selector: |
| 20 | + matchLabels: |
| 21 | + app: {{ template "mysql.fullname" . }} |
| 22 | + release: {{ .Release.Name }} |
| 23 | + template: |
| 24 | + metadata: |
| 25 | + labels: |
| 26 | + app: {{ template "mysql.fullname" . }} |
| 27 | + release: {{ .Release.Name }} |
| 28 | +{{- with .Values.podLabels }} |
| 29 | +{{ toYaml . | indent 8 }} |
| 30 | +{{- end }} |
| 31 | +{{- with .Values.podAnnotations }} |
| 32 | + annotations: |
| 33 | +{{ toYaml . | indent 8 }} |
| 34 | +{{- end }} |
| 35 | + spec: |
| 36 | + {{- if .Values.schedulerName }} |
| 37 | + schedulerName: "{{ .Values.schedulerName }}" |
| 38 | + {{- end }} |
| 39 | + {{- if .Values.imagePullSecrets }} |
| 40 | + imagePullSecrets: |
| 41 | +{{ toYaml .Values.imagePullSecrets | indent 8 }} |
| 42 | + {{- end }} |
| 43 | + {{- if .Values.priorityClassName }} |
| 44 | + priorityClassName: "{{ .Values.priorityClassName }}" |
| 45 | + {{- end }} |
| 46 | + {{- if .Values.securityContext.enabled }} |
| 47 | + securityContext: |
| 48 | + fsGroup: {{ .Values.securityContext.fsGroup }} |
| 49 | + runAsUser: {{ .Values.securityContext.runAsUser }} |
| 50 | + {{- end }} |
| 51 | + serviceAccountName: {{ template "mysql.serviceAccountName" . }} |
| 52 | + initContainers: |
| 53 | + - name: "remove-lost-found" |
| 54 | + image: "{{ .Values.busybox.image}}:{{ .Values.busybox.tag }}" |
| 55 | + imagePullPolicy: {{ .Values.imagePullPolicy | quote }} |
| 56 | + resources: |
| 57 | +{{ toYaml .Values.initContainer.resources | indent 10 }} |
| 58 | + command: ["rm", "-fr", "/var/lib/mysql/lost+found"] |
| 59 | + volumeMounts: |
| 60 | + - name: data |
| 61 | + mountPath: /var/lib/mysql |
| 62 | + {{- if .Values.persistence.subPath }} |
| 63 | + subPath: {{ .Values.persistence.subPath }} |
| 64 | + {{- end }} |
| 65 | + {{- if .Values.extraInitContainers }} |
| 66 | +{{ tpl .Values.extraInitContainers . | indent 6 }} |
| 67 | + {{- end }} |
| 68 | + {{- if .Values.nodeSelector }} |
| 69 | + nodeSelector: |
| 70 | +{{ toYaml .Values.nodeSelector | indent 8 }} |
| 71 | + {{- end }} |
| 72 | + {{- if .Values.tolerations }} |
| 73 | + tolerations: |
| 74 | +{{ toYaml .Values.tolerations | indent 8 }} |
| 75 | + {{- end }} |
| 76 | + containers: |
| 77 | + - name: {{ template "mysql.fullname" . }} |
| 78 | + image: "{{ .Values.image }}:{{ .Values.imageTag }}" |
| 79 | + imagePullPolicy: {{ .Values.imagePullPolicy | quote }} |
| 80 | + |
| 81 | + {{- with .Values.args }} |
| 82 | + args: |
| 83 | + {{- range . }} |
| 84 | + - {{ . | quote }} |
| 85 | + {{- end }} |
| 86 | + {{- end }} |
| 87 | + resources: |
| 88 | +{{ toYaml .Values.resources | indent 10 }} |
| 89 | + env: |
| 90 | + {{- if .Values.mysqlAllowEmptyPassword }} |
| 91 | + - name: MYSQL_ALLOW_EMPTY_PASSWORD |
| 92 | + value: "true" |
| 93 | + {{- end }} |
| 94 | + {{- if not (and .Values.allowEmptyRootPassword (not .Values.mysqlRootPassword)) }} |
| 95 | + - name: MYSQL_ROOT_PASSWORD |
| 96 | + valueFrom: |
| 97 | + secretKeyRef: |
| 98 | + name: {{ template "mysql.secretName" . }} |
| 99 | + key: mysql-root-password |
| 100 | + {{- if .Values.mysqlAllowEmptyPassword }} |
| 101 | + optional: true |
| 102 | + {{- end }} |
| 103 | + {{- end }} |
| 104 | + {{- if not (and .Values.allowEmptyRootPassword (not .Values.mysqPassword)) }} |
| 105 | + - name: MYSQL_PASSWORD |
| 106 | + valueFrom: |
| 107 | + secretKeyRef: |
| 108 | + name: {{ template "mysql.secretName" . }} |
| 109 | + key: mysql-password |
| 110 | + {{- if or .Values.mysqlAllowEmptyPassword (empty .Values.mysqlUser) }} |
| 111 | + optional: true |
| 112 | + {{- end }} |
| 113 | + {{- end }} |
| 114 | + - name: MYSQL_USER |
| 115 | + value: {{ default "" .Values.mysqlUser | quote }} |
| 116 | + - name: MYSQL_DATABASE |
| 117 | + value: {{ default "" .Values.mysqlDatabase | quote }} |
| 118 | + {{- if .Values.timezone }} |
| 119 | + - name: TZ |
| 120 | + value: {{ .Values.timezone }} |
| 121 | + {{- end }} |
| 122 | + ports: |
| 123 | + - name: mysql |
| 124 | + containerPort: 3306 |
| 125 | + livenessProbe: |
| 126 | + exec: |
| 127 | + command: |
| 128 | + {{- if .Values.mysqlAllowEmptyPassword }} |
| 129 | + - mysqladmin |
| 130 | + - ping |
| 131 | + {{- else }} |
| 132 | + - sh |
| 133 | + - -c |
| 134 | + - "mysqladmin ping -u root -p${MYSQL_ROOT_PASSWORD}" |
| 135 | + {{- end }} |
| 136 | + initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }} |
| 137 | + periodSeconds: {{ .Values.livenessProbe.periodSeconds }} |
| 138 | + timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }} |
| 139 | + successThreshold: {{ .Values.livenessProbe.successThreshold }} |
| 140 | + failureThreshold: {{ .Values.livenessProbe.failureThreshold }} |
| 141 | + readinessProbe: |
| 142 | + exec: |
| 143 | + command: |
| 144 | + {{- if .Values.mysqlAllowEmptyPassword }} |
| 145 | + - mysqladmin |
| 146 | + - ping |
| 147 | + {{- else }} |
| 148 | + - sh |
| 149 | + - -c |
| 150 | + - "mysqladmin ping -u root -p${MYSQL_ROOT_PASSWORD}" |
| 151 | + {{- end }} |
| 152 | + initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }} |
| 153 | + periodSeconds: {{ .Values.readinessProbe.periodSeconds }} |
| 154 | + timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }} |
| 155 | + successThreshold: {{ .Values.readinessProbe.successThreshold }} |
| 156 | + failureThreshold: {{ .Values.readinessProbe.failureThreshold }} |
| 157 | + volumeMounts: |
| 158 | + - name: data |
| 159 | + mountPath: /var/lib/mysql |
| 160 | + {{- if .Values.persistence.subPath }} |
| 161 | + subPath: {{ .Values.persistence.subPath }} |
| 162 | + {{- end }} |
| 163 | + {{- if .Values.configurationFiles }} |
| 164 | + {{- range $key, $val := .Values.configurationFiles }} |
| 165 | + - name: configurations |
| 166 | + mountPath: {{ $.Values.configurationFilesPath }}{{ $key }} |
| 167 | + subPath: {{ $key }} |
| 168 | + {{- end -}} |
| 169 | + {{- end }} |
| 170 | + {{- if .Values.initializationFiles }} |
| 171 | + - name: migrations |
| 172 | + mountPath: /docker-entrypoint-initdb.d |
| 173 | + {{- end }} |
| 174 | + {{- if .Values.ssl.enabled }} |
| 175 | + - name: certificates |
| 176 | + mountPath: /ssl |
| 177 | + {{- end }} |
| 178 | + {{- if .Values.extraVolumeMounts }} |
| 179 | +{{ tpl .Values.extraVolumeMounts . | indent 8 }} |
| 180 | + {{- end }} |
| 181 | + {{- if .Values.metrics.enabled }} |
| 182 | + - name: metrics |
| 183 | + image: "{{ .Values.metrics.image }}:{{ .Values.metrics.imageTag }}" |
| 184 | + imagePullPolicy: {{ .Values.metrics.imagePullPolicy | quote }} |
| 185 | + {{- if .Values.mysqlAllowEmptyPassword }} |
| 186 | + command: |
| 187 | + - 'sh' |
| 188 | + - '-c' |
| 189 | + - 'DATA_SOURCE_NAME="root@(localhost:3306)/" /bin/mysqld_exporter' |
| 190 | + {{- else }} |
| 191 | + env: |
| 192 | + - name: MYSQL_ROOT_PASSWORD |
| 193 | + valueFrom: |
| 194 | + secretKeyRef: |
| 195 | + name: {{ template "mysql.secretName" . }} |
| 196 | + key: mysql-root-password |
| 197 | + command: |
| 198 | + - 'sh' |
| 199 | + - '-c' |
| 200 | + - 'DATA_SOURCE_NAME="root:$MYSQL_ROOT_PASSWORD@(localhost:3306)/" /bin/mysqld_exporter' |
| 201 | + {{- end }} |
| 202 | + {{- range $f := .Values.metrics.flags }} |
| 203 | + - {{ $f | quote }} |
| 204 | + {{- end }} |
| 205 | + ports: |
| 206 | + - name: metrics |
| 207 | + containerPort: 9104 |
| 208 | + livenessProbe: |
| 209 | + httpGet: |
| 210 | + path: / |
| 211 | + port: metrics |
| 212 | + initialDelaySeconds: {{ .Values.metrics.livenessProbe.initialDelaySeconds }} |
| 213 | + timeoutSeconds: {{ .Values.metrics.livenessProbe.timeoutSeconds }} |
| 214 | + readinessProbe: |
| 215 | + httpGet: |
| 216 | + path: / |
| 217 | + port: metrics |
| 218 | + initialDelaySeconds: {{ .Values.metrics.readinessProbe.initialDelaySeconds }} |
| 219 | + timeoutSeconds: {{ .Values.metrics.readinessProbe.timeoutSeconds }} |
| 220 | + resources: |
| 221 | +{{ toYaml .Values.metrics.resources | indent 10 }} |
| 222 | + {{- end }} |
| 223 | + volumes: |
| 224 | + {{- if .Values.configurationFiles }} |
| 225 | + - name: configurations |
| 226 | + configMap: |
| 227 | + name: {{ template "mysql.fullname" . }}-configuration |
| 228 | + {{- end }} |
| 229 | + {{- if .Values.initializationFiles }} |
| 230 | + - name: migrations |
| 231 | + configMap: |
| 232 | + name: {{ template "mysql.fullname" . }}-initialization |
| 233 | + {{- end }} |
| 234 | + {{- if .Values.ssl.enabled }} |
| 235 | + - name: certificates |
| 236 | + secret: |
| 237 | + secretName: {{ .Values.ssl.secret }} |
| 238 | + {{- end }} |
| 239 | + - name: data |
| 240 | + {{- if .Values.persistence.enabled }} |
| 241 | + persistentVolumeClaim: |
| 242 | + claimName: {{ .Values.persistence.existingClaim | default (include "mysql.fullname" .) }} |
| 243 | + {{- else }} |
| 244 | + emptyDir: {} |
| 245 | + {{- end -}} |
| 246 | + {{- if .Values.extraVolumes }} |
| 247 | +{{ tpl .Values.extraVolumes . | indent 6 }} |
| 248 | + {{- end }} |
0 commit comments