This commit is contained in:
26
使用文档/使用Kubectl-Proxy访问Pod.md
Normal file
26
使用文档/使用Kubectl-Proxy访问Pod.md
Normal file
@@ -0,0 +1,26 @@
|
||||
> 本文作者:丁辉
|
||||
|
||||
# 使用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/
|
||||
```
|
||||
Reference in New Issue
Block a user