如何将shell连接到Kubernetes pod



我已经使用kubectl创建了一个pod。

我想连接到这个吊舱的端点。如何使用kubectl?

您可以通过端口转发从本地系统访问pod

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

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

或者你可以在运行的容器中得到一个外壳

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

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

最新更新