Create a MySQL Server using Kubernetes

Create base64 password and users:

echo -n "rootpassword" | base64
echo -n "nonrootuser" | base64
echo -n "nonrootpassword" | base64
apiVersion: v1
kind: Secret
metadata:
  name: mysql-credentials
  namespace: zalaxy
  labels:
    "zalaxy.com": lamp
type: Opaque
data:
  # MySQL root password
  rootpw: cm9vdHBhc3N3b3Jk
  # MySQL nonroot user
  user: bm9ucm9vdHVzZXI=
  # MySQL password for php user
  password: bm9ucm9vdHBhc3N3b3Jk
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mysql-storage
  namespace: zalaxy
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 5Gi

apiVersion: v1
kind: Service
metadata:
  name: mysql
  namespace: zalaxy
  labels:
    "zalaxy.com": lamp
spec:
  type: ClusterIP
  ports:
  - port: 3306
    protocol: TCP
  selector:
    app: mysql
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: mysql
  namespace: zalaxy
  labels:
    "zalaxy.com": lamp
spec:
  replicas: 1
  revisionHistoryLimit: 5
  selector:
    matchLabels:
      app: mysql
  template:
    metadata:
      labels:
        app: mysql
    spec:
      containers:
      - name: mysql
        image: mysql
        resources:
          requests:
            memory: 1Gi
            #cpu: 1
        env:
          - name: MYSQL_ROOT_PASSWORD
            valueFrom:
              secretKeyRef:
                name: mysql-credentials
                key: rootpw
          - name: MYSQL_USER
            valueFrom:
              secretKeyRef:
                name: mysql-credentials
                key: user
          - name: MYSQL_PASSOWRD
            valueFrom:
              secretKeyRef:
                name: mysql-credentials
                key: password
          - name: MYSQL_DATABASE
            value: zalaxy
        livenessProbe:
          tcpSocket:
            port: 3306
        ports:
          - containerPort: 3306
            name: mysql
        volumeMounts:
          - mountPath: /var/lib/mysql
            subPath: data
            name: database
      volumes:
      - name: database
        persistentVolumeClaim:
          claimName: mysql-storage
$ kubectl exec -it mysql-74d75f6c48-ffkm7 -- mysql -uroot -prootpassword zalaxy < /Users/joelg/prod/gcp/zalaxy/mysql/sql/zalaxy-schema.sql
$ kubectl exec -it mysql-74d75f6c48-ffkm7 -- mysql -uroot -prootpassword zalaxy < /Users/joelg/prod/gcp/zalaxy/mysql/sql/zalaxy-database.sql