Search code examples
kuberneteskubectlkubernetes-pod

Kubernetes - kubectl get pods being called from node


Would like to know if anyone has experienced the point of need to call kubectl commands from the node?

What i'm trying to do for this example is to access the master from the node and get some valuable information.

 bafontainha ~ kubectl get pods --server https://localhost:6443 --insecure-skip-tls-verify=true 
               Please enter Username: service-account
               Please enter Password: error: the server doesn't have a resource type "pods"

Solution

  • kubectl need either a bearer token passed inline or a kubeconfig file with a token or a certificate to authenticate the client to the Kubernetes API Server.

    By giving --insecure-skip-tls-verify=true kubectl will not verify the API Server endpoints authenticity but that does not mean that you can call Kubernetes API without a valid bearer token or a client certificate which essentially proves the identity of the client calling the API Server.

    I think the easiest option would be just copy the working kubeconfig file to the node VM into .kube/config location and execute kubectl get pods