当 运行 port-forward 时,pod 显示现有但找不到 pod 错误
pod shows existing but get pod not found error when running port-forward
当我 运行 kubectl get pods
它显示 pod 存在并准备就绪,但是当 运行 kubectl port-forward
我得到 pod not foud
错误。这是怎么回事?
(base):~ zwang$ k get pods -n delivery
NAME READY STATUS RESTARTS AGE
screenshot-history-7f76489574-wntkf 1/1 Running 86 7h18m
(base):~ zwang$ k port-forward screenshot-history-7f76489574-wntkf 8000:8000
Error from server (NotFound): pods "screenshot-history-7f76489574-wntkf" not found
您还需要在 port-forward
命令中指定命名空间。 kubectl port-forward -n delivery screenshot-history-7f76489574-wntkf 8000:8000
尝试在访问 Pod 时放置命名空间。
kubectl port-forward screenshot-history-7f76489574-wntkf 8000:8000 -n delivery
另一种选择是将当前名称空间更改为您想要的名称空间。然后你可以直接工作而不需要传递任何命名空间。您可以从此 link.
查看更多信息以更改当前命名空间
试试这些命令
k config set-context --current --namespace=delivery
k port-forward screenshot-history-7f76489574-wntkf 8000:8000 &
OR
k -n delivery port-forward screenshot-history-7f76489574-wntkf 8000:8000 &
当我 运行 kubectl get pods
它显示 pod 存在并准备就绪,但是当 运行 kubectl port-forward
我得到 pod not foud
错误。这是怎么回事?
(base):~ zwang$ k get pods -n delivery
NAME READY STATUS RESTARTS AGE
screenshot-history-7f76489574-wntkf 1/1 Running 86 7h18m
(base):~ zwang$ k port-forward screenshot-history-7f76489574-wntkf 8000:8000
Error from server (NotFound): pods "screenshot-history-7f76489574-wntkf" not found
您还需要在 port-forward
命令中指定命名空间。 kubectl port-forward -n delivery screenshot-history-7f76489574-wntkf 8000:8000
尝试在访问 Pod 时放置命名空间。
kubectl port-forward screenshot-history-7f76489574-wntkf 8000:8000 -n delivery
另一种选择是将当前名称空间更改为您想要的名称空间。然后你可以直接工作而不需要传递任何命名空间。您可以从此 link.
查看更多信息以更改当前命名空间试试这些命令
k config set-context --current --namespace=delivery
k port-forward screenshot-history-7f76489574-wntkf 8000:8000 &
OR
k -n delivery port-forward screenshot-history-7f76489574-wntkf 8000:8000 &