<p>Hi I've deployed single MySQL db instance in Azure via the YAML file in Azure Kubernetes service. I can get into the container via CLI when I'm inside my cluster. I would like to connect with db instance via external client like MySQL Workbench or Sqlelectron or others, outside the cluster. As I found out it's possible via correctly exposing DB instance by Service configuration.</p>
<p>My deployment of single instance MySQL DB instance is:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
    name: mysql-db-testing-service
    namespace: testing
spec:
    type: ClusterIP
    ports:
    - port: 3306
      #targetPort: 3306
    selector:
        app: mysql-db-testing
---
apiVersion: apps/v1
kind: Deployment
metadata:
    name: mysql-db-testing
    namespace: testing
spec:
    selector:
        matchLabels:
            app: mysql-db-testing
    replicas: 1
    strategy:
        type: Recreate
    template:
        metadata:
            labels:
                app: mysql-db-testing
        spec:
            containers: 
            - name: mysql-db-container-testing 
              image: mysql:8.0.31
              env: 
              - name: MYSQL_ROOT_PASSWORD
                value: test12345
              ports:
              - containerPort: 3306
                name: mysql-port
              volumeMounts:
              - mountPath: &quot;/var/lib/mysql&quot;
                name: mysql-persistent-storage
            volumes:
            - name: mysql-persistent-storage
              persistentVolumeClaim:
                claimName: azure-managed-disk-pvc-mysql-testing
            nodeSelector:
                env: preprod 
</code></pre>
<p>As I've mentioned I can get to the container via CLI:</p>
<p><a href="https://i.stack.imgur.com/TDQtX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TDQtX.png" alt="enter image description here" /></a></p>
<p>Console output regarding the working pod with db looks like:
<a href="https://i.stack.imgur.com/Cz7vj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Cz7vj.png" alt="enter image description here" /></a></p>
<p>Console output regarding the service:</p>
<p><a href="https://i.stack.imgur.com/BIBad.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BIBad.png" alt="v" /></a></p>
<p>Is there something missing in my deployment YAML file or maybe there are missing some fields? How can I expose db to the outside world? I would be grateful for help.</p>

<p>You are using ClusterIP service(line 7). The kubernetes ClusterIP service is not made to allow you to access a pod outside of the cluster. ClusterIP just provide a way to have a not changing IP for other internal services to access your pod.
You should use instead Loadbalanacer.
Cf <a href="https://stackoverflow.com/a/48281728/8398523">https://stackoverflow.com/a/48281728/8398523</a> for differences</p>
