Say, I have two namespaces k8s-app1 and k8s-app2
I can list all pods from specific namespace using the below command
kubectl get pods -n
npm install -g k8ss
k8ss switch --namespace=your_namespace
kubectl get pods
There is a npm package called k8ss
which stands for K8S Switching between clusters and namespaces
.
The full usage is
k8ss switch --cluster=your_new_cluster --namespace=your_new_namespace
As in your case, you only need to switch namespace, so you can use the command without any configuration (as you already put a config file in the ~/.kube/config
).
If you need to switch between different clusters then you need to put multiple config files in your home directory. In this case you can go to the package README to learn more.