如何将Shell连接到kubernetes pod

问题描述 投票:1回答:1

我使用kubectl创建了一个pod。

我想连接此pod的端点。如何使用kubectl做到这一点?

kubernetes kubectl
1个回答
0
投票

您可以进行端口转发以从本地系统访问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/

© www.soinside.com 2019 - 2024. All rights reserved.