I have a MySql RDS database that is not publicly exposed. I also have a pod that can act as a bastion with kubectl exec
. How would I be able to connect my local MySql Workbench to this RDS database?
Asked
Active
Viewed 204 times
0

Mike
- 961
- 6
- 19
- 43
1 Answers
1
You can connect to your DB from local machine using kubectl port-forward command. If you don't already have a pod running in the cluster, you can create it with the command:
kubectl run ${NAME} --image=alpine/socat -it --tty --rm --expose=true --port=${DB_PORT} tcp-listen:${DB_PORT},fork,reuseaddr tcp-connect:${DB_ENDPOINT}:${DB_PORT}
Once the pod is up and running, use command:
kubectl port-forward service/<NAME> ${DB_PORT}:${DB_PORT}
In your MySql Workbench, replace DB_URL with localhost and connection should be forwarded from your machine to the database, with the pod acting as bastion.

Atif Syed
- 11
- 2