kubernetes localhost:8080 was refused with context kubernetes localhost:8080 was refused with context kubernetes kubernetes

kubernetes localhost:8080 was refused with context


I figured it out, what i noticed when i execute the command

kubectl config view

The cluster is showing as empty

- context:    cluster: ""    namespace: dev    user: user1

To fix this issues added the --cluster information and modified the set-context

root@kube-master:/home/ansible# kubectl config set-context dev --cluster=kubernetes --namespace=dev --user=user1Context "dev" modified.

and the context is set properly

contexts:- context:    cluster: kubernetes    namespace: dev    user: user1  name: dev

and i got desired results when looking up the pods with --context=dev

root@kube-master:/home/ansible# kubectl --context=dev get podsNo resources found.Error from server (Forbidden): pods is forbidden: User "system:anonymous" cannot list pods in the namespace "dev"