1

For example when I use kubectl get pods the response is:

No resources found in default namespace.

But when I use sudo kubectl get pods the result is:

E1211 12:01:15.409201   50965 memcache.go:238] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
E1211 12:01:15.409569   50965 memcache.go:238] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
E1211 12:01:15.411086   50965 memcache.go:238] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
E1211 12:01:15.412633   50965 memcache.go:238] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
E1211 12:01:15.414189   50965 memcache.go:238] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
The connection to the server localhost:8080 was refused - did you specify the right host or port?

PS: From my previous knowledge I think when I use kubectl without sudo, it refers to 192.168.1.2:6443 but with the sudo word it is looking for localhost:8080. I don't know why?

1 Answer 1

1

I think you haven't configured kubeconfig in root user.

The sudo command allows you to run programs with the security privileges of another user.

When you run sudo kubectl you're running kubectl with root user and most probably you might have not configured kubeconfig for root user.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.