apiVersion: v1 kind: Service metadata: name: mysql namespace: monica spec: ports: - name: mysql port: 3306 selector: app: mysql --- apiVersion: apps/v1 kind: StatefulSet metadata: name: mysql namespace: monica spec: selector: matchLabels: app: mysql serviceName: mysql replicas: 1 template: metadata: labels: app: mysql spec: containers: - image: docker.io/library/mysql:5.7 name: mysql resources: {} ports: - name: mysql containerPort: 3306 volumeMounts: - name: storage mountPath: /var/lib/mysql env: - name: MYSQL_DATABASE value: monica - name: MYSQL_USER value: monica - name: MYSQL_ROOT_PASSWORD value: "true" envFrom: - secretRef: name: mysql volumeClaimTemplates: - metadata: name: storage spec: accessModes: ["ReadWriteOnce"] resources: requests: storage: 1Gi