Access MySQL Kubernetes Deployment in MySQL Workbench

10/5/2020

I deployed a MySQL pod with the example from the kubernetes website: https://kubernetes.io/docs/tasks/run-application/run-single-instance-stateful-application/

I can access the pod from the pod network but not from outside the cluster, how can I achieve this? I would want to access the service via MySQL Workbench for easier editing of the Database.

I already tried to setup a NodePort service like this:

apiVersion: v1
kind: Service
metadata:
  name: mysql
spec:
  ports:
  - port: 3306
    targetPort: 3006
    nodePort: 30003
  selector:
    app: mysql
  type: NodePort

with the goal to access the service at <master-ip>:30003 but that does not work.

-- Herry
kubernetes
mysql

1 Answer

10/6/2020
apiVersion: v1
kind: Service
metadata:
  name: mysql
spec:
  ports:
  - port: 3306
    targetPort: 3006
    nodePort: 30003
  selector:
    app: mysql
  type: NodePort

the targetPort is 3006 instead of 3306, it was a typo.

-- Herry
Source: StackOverflow