apiVersion: apps/v1 kind: Deployment metadata: name: mysql labels: app: mysql spec: replicas: 1 selector: matchLabels: app: mysql strategy: type: Recreate template: metadata: labels: app: mysql spec: containers: - name: mysql image: mysql:8 imagePullPolicy: IfNotPresent env: - name: MYSQL_ROOT_PASSWORD value: "Huawei@123" ports: - containerPort: 3306 volumeMounts: - name: data-volume mountPath: /var/lib/mysql - name: init-sql mountPath: /docker-entrypoint-initdb.d - name: mysql-utf8-config mountPath: /etc/mysql/conf.d volumes: - name: data-volume hostPath: path: /opt/data-mate/data/mysql type: DirectoryOrCreate - name: init-sql configMap: name: init-sql - name: mysql-utf8-config configMap: name: mysql-utf8-config --- apiVersion: v1 kind: Service metadata: name: mysql labels: app: mysql spec: type: ClusterIP ports: - port: 3306 targetPort: 3306 protocol: TCP selector: app: mysql