How to connect to shell to Kubernetes pod

4/13/2020

I have created a pod using kubectl.

I want to connect to the endpoint of this pod. How to do that using kubectl?

--
kubectl
kubernetes

1 Answer

4/13/2020

You can do port forward to access the pod from your local system

kubectl port-forward pods/redis-master-765d459796-258hz 7000:6379

https://kubernetes.io/docs/tasks/access-application-cluster/port-forward-access-application-cluster/

Or You can get a shell in the running container

kubectl exec -it pods/shell-demo -- /bin/bash

https://kubernetes.io/docs/tasks/debug-application-cluster/get-shell-running-container/

-- Arghya Sadhu
Source: StackOverflow