Files
Kubernetes/使用文档/使用Kubectl-Proxy访问Pod.md
offends 8a87b699ba
All checks were successful
continuous-integration/drone Build is passing
first commit
2025-12-13 18:06:23 +08:00

26 lines
565 B
Markdown

> 本文作者:丁辉
# 使用Kubectl-Proxy访问Pod
[官方文档](https://kubernetes.io/zh-cn/docs/tutorials/kubernetes-basics/deploy-app/deploy-intro/#%E6%9F%A5%E7%9C%8B%E5%BA%94%E7%94%A8)
1. 开启代理
```bash
kubectl proxy
```
2. 验证
```bash
curl http://localhost:8001/version
```
3. 通过代理的 API 访问 Pod
- 更换 `$NAMESPACES` 为所需访问的命名空间
- 更换 `$POD_NAME` 为所需访问的容器名
```bash
curl http://localhost:8001/api/v1/namespaces/$NAMESPACES/pods/$POD_NAME:80/proxy/
```