<p>I have deployed my application on Google <code>gcloud</code> container engine. My application required <code>MySQL</code>. Application is running fine and connecting to <code>MySQL</code> correctly.
But I want to connect <code>MySQL</code> database from my local machine using <code>MySQL</code> Client (<code>Workbench</code>, or command line), Can some one help me how to expose this to local machine? and how can I open <code>MySQL</code> command line on <code>gcloud</code> shell ?</p>
<p>I have run below command but external ip is not there  :</p>
<pre><code>$ kubectl get deployment
NAME        DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
app-mysql   1         1         1            1           2m
$ kubectl get pods
NAME                         READY     STATUS             RESTARTS   AGE
app-mysql-3323704556-nce3w   1/1       Running            0          2m
$ kubectl get service
NAME        CLUSTER-IP    EXTERNAL-IP       PORT(S)    AGE
app-mysql   11.2.145.79   &lt;none&gt;            3306/TCP   23h
</code></pre>
<p><strong>EDIT</strong></p>
<p>I am using below <code>yml</code> file:</p>
<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: app-mysql
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: app-mysql
    spec:
      volumes:
      - name: data
        emptyDir: {}
      containers:
      - name: mysql
        image: mysql:5.6.22
        env:
        - name: MYSQL_USER
          value: root
        - name: MYSQL_DATABASE
          value: appdb
        ports:
        - containerPort: 3306
        volumeMounts:
        - name: data
          mountPath: /var/lib/mysql/
---
apiVersion: v1
kind: Service
metadata:
  name: app-mysql
spec:
  selector:
    app: app-mysql
  ports:
  - port: 3306
</code></pre>

Anchit Pancholi
<p>Try the <code>kubectl port-forward</code> command.</p>
<p>In your case; <code>kubectl port-forward app-mysql-3323704556-nce3w 3306:3306</code></p>
<p>See <a href="https://kubernetes.io/docs/user-guide/kubectl/kubectl_port-forward" rel="noreferrer">The documentation</a> for all available options.</p>
