Kubernetes pod在向前运行端口时显示现有但get-pod not found错误

Kubernetes pod在向前运行端口时显示现有但get-pod not found错误,kubernetes,amazon-eks,Kubernetes,Amazon Eks,当我运行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 Runnin

当我运行
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端口转发-n delivery screenshot-history-7f76489574-wntkf 8000:8000

在访问Pod时尝试放置名称空间

 kubectl port-forward screenshot-history-7f76489574-wntkf 8000:8000 -n delivery
另一个选项是将当前名称空间更改为所需名称空间。然后,您可以直接工作,而无需传递任何名称空间。您可以在此查看更多信息以更改当前名称空间。

试试这些命令

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 &

您需要提供
-n delivery
选项来指定这两个命令中的名称空间。