<p>following steps have been done:-
1. I have created a persistent volume claim and used that in my deployment for mysql
2. created a generic secret in configuration and set that in env for deployment</p>

<pre><code>        env:
      - name: MYSQL_ROOT_PASSWORD
        valueFrom:
            secretKeyRef:
              name: my-db-pass
              key: password
</code></pre>

<p>3. using following cmd to connect to my instance 
    mysql --host= --user=root -p
after which the following error occurred- </p>

<pre><code>ERROR 1045 (28000): Access denied for user 'root'@'10.128.0.18' (using password: YES)
</code></pre>

<p>kubectl pod logs for mysql are - </p>

<pre><code>2020-04-05 19:49:47+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.19-1debian10 started.
2020-04-05 19:49:47+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2020-04-05 19:49:47+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.19-1debian10 started.
2020-04-05T19:49:48.139557Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2020-04-05T19:49:48.139759Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.19) starting as process 1
2020-04-05T19:49:50.599641Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2020-04-05T19:49:50.606508Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2020-04-05T19:49:50.850478Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.19'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.
2020-04-05T19:49:50.894674Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060
2020-04-05T20:01:09.664184Z 17 [Warning] [MY-013360] [Server] Plugin sha256_password reported: ''sha256_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instead'
</code></pre>

<p>yaml file for mysql-deployment is also provided</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql
  labels:
    app: mysql
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mysql
  template:
    metadata:
      labels:
        app: mysql
    spec:
      containers:
      - name: mysql
        image: mysql:8
        args:
          - "--default-authentication-plugin=mysql_native_password"
        env:
          - name: MYSQL_ROOT_PASSWORD
            valueFrom:
                secretKeyRef:
                  name: my-db-pass
                  key: password
        ports:
          - containerPort: 3306
            name: mysql
        volumeMounts:
          - name: mysql-persistent-storage
            mountPath: /var/lib/mysql
      volumes:
        - name: mysql-persistent-storage
          persistentVolumeClaim:
            claimName: mysql-volumeclaim
</code></pre>

iron_man
<p>While connecting to the mysql service, pLease specify the same port on which you have  exposed the service.</p>

<p><a href="https://i.stack.imgur.com/JzTvE.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JzTvE.jpg" alt="enter image description here"></a></p>
