kubectl needs a config file to connect to the api-server. It is typically stored at ~/.kube/config

I have a pod in my cluster. It has the kubectl binary

# ls -al /usr/local/bin/kubectl

-rwxr-xr-x    1 root     root      43115328 Apr  8 18:38 ./usr/local/bin/kubectl

and also these 3 files:

# cd /run/secrets/kubernetes.io/serviceaccount 

# ls -al
lrwxrwxrwx    1 root     root            13 May 15 22:45 ca.crt -> ..data/ca.crt
lrwxrwxrwx    1 root     root            16 May 15 22:45 namespace -> ..data/namespace
lrwxrwxrwx    1 root     root            12 May 15 22:45 token -> ..data/token

Can I contruct a config file from the ca.crt, namespace, token files that can be used by the kubectl commandline to talk to the API server?

Thank you.

  • What are you trying to accomplish? – soandos May 24 at 16:50
  • I am trying to get kubectl working in the container so it can contact the api-server. – user674669 May 25 at 5:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.