blob: 6c19f0abb7d0cc245f96665828d8844e80248b21 [file] [log] [blame]
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
{{- if .Values.components.mysql }}
{{- if not .Values.external.mysql.enabled }}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ template "inlong.fullname" . }}-{{ .Values.mysql.component }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "inlong.commonLabels" . | nindent 4 }}
component: {{ .Values.mysql.component }}
spec:
serviceName: {{ template "inlong.fullname" . }}-{{ .Values.mysql.component }}
replicas: {{ .Values.mysql.replicas }}
selector:
matchLabels:
{{- include "inlong.matchLabels" . | nindent 6 }}
component: {{ .Values.mysql.component }}
updateStrategy:
type: {{ .Values.mysql.updateStrategy.type | quote }}
podManagementPolicy: {{ .Values.mysql.podManagementPolicy | quote }}
template:
metadata:
labels:
{{- include "inlong.template.labels" . | nindent 8 }}
component: {{ .Values.mysql.component }}
{{- if .Values.mysql.annotations }}
annotations:
{{- toYaml .Values.mysql.annotations | nindent 8 }}
{{- end }}
spec:
{{- if .Values.mysql.tolerations }}
tolerations:
{{- toYaml .Values.mysql.tolerations | nindent 8 }}
{{- end }}
{{- if .Values.mysql.nodeSelector }}
nodeSelector:
{{- toYaml .Values.mysql.nodeSelector | nindent 8 }}
{{- end }}
{{- if .Values.mysql.affinity }}
affinity:
{{- toYaml .Values.mysql.affinity | nindent 8 }}
{{- end }}
terminationGracePeriodSeconds: {{ .Values.mysql.terminationGracePeriodSeconds }}
containers:
- name: {{ template "inlong.fullname" . }}-{{ .Values.mysql.component }}
image: {{ .Values.images.mysql.repository }}:{{ .Values.images.mysql.tag }}
imagePullPolicy: {{ .Values.images.pullPolicy }}
{{- if .Values.mysql.resources }}
resources:
{{- toYaml .Values.mysql.resources | nindent 12 }}
{{- end }}
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "inlong.fullname" . }}-{{ .Values.mysql.component }}
key: mysql-password
- name: TZ
value: {{ .Values.timezone }}
ports:
- name: {{ .Values.mysql.component }}-port
containerPort: 3306
volumeMounts:
- name: data
mountPath: /var/lib/mysql
- name: sql
mountPath: /docker-entrypoint-initdb.d
- name: config
mountPath: /etc/mysql/conf.d/custom.cnf
subPath: custom.cnf
volumes:
- name: data
{{- if .Values.mysql.volumes.persistence }}
persistentVolumeClaim:
claimName: {{ template "inlong.fullname" . }}-{{ .Values.mysql.component }}-{{ .Values.mysql.volumes.name }}
{{- else }}
emptyDir: {}
{{- end }}
- name: sql
{{- if .Values.mysql.volumes.persistence }}
persistentVolumeClaim:
claimName: {{ template "inlong.fullname" . }}-{{ .Values.mysql.component }}-{{ .Values.mysql.volumes.name }}
{{- else }}
emptyDir: {}
{{- end }}
- name: config
configMap:
name: {{ template "inlong.fullname" . }}-{{ .Values.mysql.component }}
items:
- key: custom.cnf
path: custom.cnf
defaultMode: 420
restartPolicy: Always
{{- end }}
{{- end }}