0

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 :30003 but that does not work.

2
  • 1
    Hi, can you confirm that you requested <NodeIP>:30003 to connect the the service? Also what k8s cluster is this? Minikube has different approach for this as an example. Commented Oct 5, 2020 at 15:26
  • I actually had a typo in my configuration, emberrasing. In the snippet above, the targetPort is 3006 instead of 3306, thank you for the comment, it pushed me in the right direction :) Commented Oct 6, 2020 at 10:17

1 Answer 1

1
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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.