MySQL access from Kubernetes pods¶
To access a MySQL database instance from within a Kubernetes cluster, administrators often utilize the kubectl port-forward command^[400-devops-06-kubernetes-k8s-mysql-readme.md]. This method forwards a local port to the port on a specific Pod, allowing direct interaction with the database service.
Execution¶
The command requires specifying the target Pod name and the port mapping, typically 3306:3306 for MySQL^[400-devops-06-kubernetes-k8s-mysql-readme.md].
[kubectl port-forward](<./kubectl-port-forward.md>) mysql-dp-8dfb795cf-2hkgm 3306:3306 --address 0.0.0.0
Additionally, to locate the exact name of the target Pod, kubectl get pods -A can be used to list all pods across all namespaces^[400-devops-06-kubernetes-k8s-mysql-readme.md].
Sources¶
400-devops-06-kubernetes-k8s-mysql-readme.md