<p>I am using k8s in mac-docker-desktop. I deploy a mysql pod with below config. </p>

<p>run with: <code>kubectl apply -f mysql.yaml</code></p>

<pre><code># secret
apiVersion: v1 
kind: Secret
metadata:
  name: mysql
type: Opaque
data:
  # root
  mysql-root-password: cm9vdAo=
---
# configMap
apiVersion: v1
kind: ConfigMap
metadata:
  name: mysql-conf
data:
  database: app
---
apiVersion: apps/v1
kind: Deployment 
metadata:
  name: mysql
  labels:
    app: mysql
spec:
  selector:
    matchLabels:
      app: mysql
  strategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: mysql
    spec:
      volumes:
      - name: mysql
        persistentVolumeClaim:
          claimName: mysql
      containers:
        - image: mysql:5.6
          name: mysql
          env:
            - name: MYSQL_ROOT_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: mysql
                  key: mysql-root-password
            - name: MYSQL_DATABASE
              valueFrom:
                configMapKeyRef:
                  name: mysql-conf
                  key: database
          ports:
            - containerPort: 3306
              name: mysql
          volumeMounts:
            - name: mysql
              mountPath: /var/lib/mysql
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mysql
  labels:
    app: mysql
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
---
# services
apiVersion: v1
kind: Service 
metadata:
  name: mysql
  labels:
    app: mysql
spec:
  selector:
    app: mysql
  ports:
    - port: 3306  
      targetPort: 3306 

</code></pre>

<p>After that. it shows ok . and then, I want to connect the mysql server with node ip, but failed. then I exec in the pod, and got failed either.</p>

<p>I execute in the pod and can't login.</p>

<pre><code>

☁  gogs-k8s  kubectl get pods           
NAME                     READY     STATUS    RESTARTS   AGE
blog-59fb8cbd44-frmtx    1/1       Running   0          37m
blog-59fb8cbd44-gdskp    1/1       Running   0          37m
blog-59fb8cbd44-qrs8f    1/1       Running   0          37m
mysql-6c794ccb7b-dz9f4   1/1       Running   0          31s
☁  gogs-k8s  kubectl exec mysql-6c794ccb7b-dz9f4 -it bash 
root@mysql-6c794ccb7b-dz9f4:/# ls
bin  boot  dev  docker-entrypoint-initdb.d  entrypoint.sh  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
root@mysql-6c794ccb7b-dz9f4:/# mysql -u root -p 
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
root@mysql-6c794ccb7b-dz9f4:/# echo $MYSQL_ROOT_PASSWORD
root
root@mysql-6c794ccb7b-dz9f4:/# mysql -u root -p 
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

</code></pre>

<p>It there any problems with my config file ? </p>

<p>Probably you have invalid base64 encoded password. Try this one:</p>

<pre><code>data:
  pass: cm9vdA==
</code></pre>
