when I run kubectl get pods
it shows pod existing and ready, but when run kubectl port-forward
I get pod not foud
error. what's going on here?
(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
Try these commands
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 &
You need to specify the namespace on the port-forward
command too. kubectl port-forward -n delivery screenshot-history-7f76489574-wntkf 8000:8000
Try putting the namespace while accessing the Pod.
kubectl port-forward screenshot-history-7f76489574-wntkf 8000:8000 -n delivery
Another option is change the current namespace to your desired one. Then you can directly work without passing any namespace. You can see more info to change the current namespace from this link.