mirror of
https://github.com/bitnami/charts.git
synced 2026-03-13 14:57:24 +08:00
228 lines
8.5 KiB
YAML
228 lines
8.5 KiB
YAML
apiVersion: apps/v1beta1
|
|
kind: StatefulSet
|
|
metadata:
|
|
name: {{ template "mysql.master.fullname" . }}
|
|
labels:
|
|
app: "{{ template "mysql.name" . }}"
|
|
chart: {{ template "mysql.chart" . }}
|
|
component: "master"
|
|
release: {{ .Release.Name | quote }}
|
|
heritage: {{ .Release.Service | quote }}
|
|
spec:
|
|
selector:
|
|
matchLabels:
|
|
app: {{ template "mysql.name" . }}
|
|
release: "{{ .Release.Name }}"
|
|
component: "master"
|
|
serviceName: "{{ template "mysql.master.fullname" . }}"
|
|
replicas: 1
|
|
updateStrategy:
|
|
type: {{ .Values.master.updateStrategy.type }}
|
|
{{- if (eq "Recreate" .Values.master.updateStrategy.type) }}
|
|
rollingUpdate: null
|
|
{{- end }}
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: "{{ template "mysql.name" . }}"
|
|
chart: {{ template "mysql.chart" . }}
|
|
component: "master"
|
|
release: {{ .Release.Name | quote }}
|
|
heritage: {{ .Release.Service | quote }}
|
|
{{- if or .Values.master.annotations .Values.metrics.enabled }}
|
|
annotations:
|
|
{{- if .Values.master.annotations }}
|
|
{{ toYaml .Values.master.annotations | indent 8 }}
|
|
{{- end }}
|
|
{{- if .Values.metrics.annotations }}
|
|
{{ toYaml .Values.metrics.annotations | indent 8 }}
|
|
{{- end }}
|
|
{{- end }}
|
|
spec:
|
|
{{- if .Values.securityContext.enabled }}
|
|
securityContext:
|
|
fsGroup: {{ .Values.securityContext.fsGroup }}
|
|
runAsUser: {{ .Values.securityContext.runAsUser }}
|
|
{{- end }}
|
|
{{- if eq .Values.master.antiAffinity "hard" }}
|
|
affinity:
|
|
podAntiAffinity:
|
|
requiredDuringSchedulingIgnoredDuringExecution:
|
|
- topologyKey: "kubernetes.io/hostname"
|
|
labelSelector:
|
|
matchLabels:
|
|
app: "{{ template "mysql.name" . }}"
|
|
release: "{{ .Release.Name }}"
|
|
{{- else if eq .Values.master.antiAffinity "soft" }}
|
|
affinity:
|
|
podAntiAffinity:
|
|
preferredDuringSchedulingIgnoredDuringExecution:
|
|
- weight: 1
|
|
podAffinityTerm:
|
|
topologyKey: kubernetes.io/hostname
|
|
labelSelector:
|
|
matchLabels:
|
|
app: "{{ template "mysql.name" . }}"
|
|
release: "{{ .Release.Name }}"
|
|
{{- end }}
|
|
{{- include "mysql.imagePullSecrets" . | indent 6 }}
|
|
{{- if and .Values.volumePermissions.enabled .Values.master.persistence.enabled }}
|
|
initContainers:
|
|
- name: volume-permissions
|
|
image: "{{ template "mysql.volumePermissions.image" . }}"
|
|
imagePullPolicy: {{ default "" .Values.volumePermissions.image.pullPolicy | quote }}
|
|
command: ["chown", "-R", "{{ .Values.securityContext.runAsUser }}:{{ .Values.securityContext.fsGroup }}", "{{ .Values.master.persistence.mountPath }}"]
|
|
securityContext:
|
|
runAsUser: 0
|
|
resources: {{ toYaml .Values.volumePermissions.resources | nindent 10 }}
|
|
volumeMounts:
|
|
- name: data
|
|
mountPath: "{{ .Values.master.persistence.mountPath }}"
|
|
{{- end }}
|
|
containers:
|
|
- name: "mysql"
|
|
image: {{ template "mysql.image" . }}
|
|
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
|
|
env:
|
|
- name: MYSQL_ROOT_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ template "mysql.fullname" . }}
|
|
key: mysql-root-password
|
|
{{- if .Values.db.user }}
|
|
- name: MYSQL_USER
|
|
value: "{{ .Values.db.user }}"
|
|
- name: MYSQL_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ template "mysql.fullname" . }}
|
|
key: mysql-password
|
|
{{- end }}
|
|
- name: MYSQL_DATABASE
|
|
value: "{{ .Values.db.name }}"
|
|
{{- if .Values.replication.enabled }}
|
|
- name: MYSQL_REPLICATION_MODE
|
|
value: "master"
|
|
- name: MYSQL_REPLICATION_USER
|
|
value: "{{ .Values.replication.user }}"
|
|
- name: MYSQL_REPLICATION_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ template "mysql.fullname" . }}
|
|
key: mysql-replication-password
|
|
{{- end }}
|
|
ports:
|
|
- name: mysql
|
|
containerPort: 3306
|
|
{{- if .Values.master.livenessProbe.enabled }}
|
|
livenessProbe:
|
|
exec:
|
|
command: ["sh", "-c", "exec mysqladmin status -uroot -p$MYSQL_ROOT_PASSWORD"]
|
|
initialDelaySeconds: {{ .Values.master.livenessProbe.initialDelaySeconds }}
|
|
periodSeconds: {{ .Values.master.livenessProbe.periodSeconds }}
|
|
timeoutSeconds: {{ .Values.master.livenessProbe.timeoutSeconds }}
|
|
successThreshold: {{ .Values.master.livenessProbe.successThreshold }}
|
|
failureThreshold: {{ .Values.master.livenessProbe.failureThreshold }}
|
|
{{- end }}
|
|
{{- if .Values.master.readinessProbe.enabled }}
|
|
readinessProbe:
|
|
exec:
|
|
command: ["sh", "-c", "exec mysqladmin status -uroot -p$MYSQL_ROOT_PASSWORD"]
|
|
initialDelaySeconds: {{ .Values.master.readinessProbe.initialDelaySeconds }}
|
|
periodSeconds: {{ .Values.master.readinessProbe.periodSeconds }}
|
|
timeoutSeconds: {{ .Values.master.readinessProbe.timeoutSeconds }}
|
|
successThreshold: {{ .Values.master.readinessProbe.successThreshold }}
|
|
failureThreshold: {{ .Values.master.readinessProbe.failureThreshold }}
|
|
{{- end }}
|
|
resources:
|
|
{{ toYaml .Values.master.resources | indent 10 }}
|
|
volumeMounts:
|
|
{{- if .Values.master.persistence.existingClaim }}
|
|
- name: {{ .Values.master.persistence.existingClaim }}
|
|
{{- else }}
|
|
- name: data
|
|
{{- end }}
|
|
mountPath: {{ .Values.master.persistence.mountPath }}
|
|
{{- if (.Files.Glob "files/docker-entrypoint-initdb.d/*[sh|sql|sql.gz]") }}
|
|
- name: custom-init-scripts
|
|
mountPath: /docker-entrypoint-initdb.d
|
|
{{- end }}
|
|
{{- if .Values.master.config }}
|
|
- name: config
|
|
mountPath: /opt/bitnami/mysql/conf/my.cnf
|
|
subPath: my.cnf
|
|
{{- end }}
|
|
{{- if .Values.metrics.enabled }}
|
|
- name: metrics
|
|
image: {{ template "mysql.metrics.image" . }}
|
|
imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }}
|
|
env:
|
|
- name: MYSQL_ROOT_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ template "mysql.fullname" . }}
|
|
key: mysql-root-password
|
|
command: [ 'sh', '-c', 'DATA_SOURCE_NAME="root:$MYSQL_ROOT_PASSWORD@(localhost:3306)/" /bin/mysqld_exporter' ]
|
|
ports:
|
|
- name: metrics
|
|
containerPort: 9104
|
|
livenessProbe:
|
|
httpGet:
|
|
path: /metrics
|
|
port: metrics
|
|
initialDelaySeconds: 15
|
|
timeoutSeconds: 5
|
|
readinessProbe:
|
|
httpGet:
|
|
path: /metrics
|
|
port: metrics
|
|
initialDelaySeconds: 5
|
|
timeoutSeconds: 1
|
|
resources:
|
|
{{ toYaml .Values.metrics.resources | indent 10 }}
|
|
{{- end }}
|
|
volumes:
|
|
{{- if and .Values.master.persistence.enabled .Values.master.persistence.existingClaim }}
|
|
- name: {{ .Values.master.persistence.existingClaim }}
|
|
persistentVolumeClaim:
|
|
claimName: {{ .Values.master.persistence.existingClaim }}
|
|
{{ end }}
|
|
{{- if .Values.master.config }}
|
|
- name: config
|
|
configMap:
|
|
name: {{ template "mysql.master.fullname" . }}
|
|
{{- end }}
|
|
{{- if (.Files.Glob "files/docker-entrypoint-initdb.d/*[sh|sql|sql.gz]") }}
|
|
- name: custom-init-scripts
|
|
configMap:
|
|
name: {{ template "mysql.master.fullname" . }}-init-scripts
|
|
{{- end }}
|
|
{{- if and .Values.master.persistence.enabled ( not .Values.master.persistence.existingClaim ) }}
|
|
volumeClaimTemplates:
|
|
- metadata:
|
|
name: data
|
|
labels:
|
|
app: "{{ template "mysql.name" . }}"
|
|
component: "master"
|
|
release: {{ .Release.Name | quote }}
|
|
heritage: {{ .Release.Service | quote }}
|
|
spec:
|
|
accessModes:
|
|
{{- range .Values.master.persistence.accessModes }}
|
|
- {{ . | quote }}
|
|
{{- end }}
|
|
resources:
|
|
requests:
|
|
storage: {{ .Values.master.persistence.size | quote }}
|
|
{{- if .Values.master.persistence.storageClass }}
|
|
{{- if (eq "-" .Values.master.persistence.storageClass) }}
|
|
storageClassName: ""
|
|
{{- else }}
|
|
storageClassName: {{ .Values.master.persistence.storageClass | quote }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- else }}
|
|
- name: "data"
|
|
emptyDir: {}
|
|
{{- end }}
|