I have a single master, multinode kubernetes going. It works great. However I want to allow kubectl commands to be run from outside the master server. How do I run kubectl get node from my laptop for example?
If I install kubectl on my laptop I get the following error: error: client-key-data or client-key must be specified for kubernetes-admin to use the clientCert authentication method
How do I go about this. I have read through the kubernetes authorisation documentation but I must say it's a bit greek to me. I am running version 1.10.2.
Thank you.
From your master copy /root/.kube directory to your laptop C:\Users\.kube location.
kubectl will pickup the certificate from config file automatically.
To extend @sfgroups answer:
Configurations of all Kubernetes clusters you are managing are stored in $HOME/.kube/config file. If you have that file on the master node, the easy way is to copy it to $HOME/.kube/config file on a local machine. You can choose other places, and then specify the location by environment value KUBECONFIG
:
export KUBECONFIG=/etc/kubernetes/config
or use --kubeconfig
command line parameter instead.
Cloud providers often give you a possibility to download config to local machine from the web interface or by the cloud management command.
For GCP:
gcloud container clusters get-credentials NAME [--region=REGION | --zone=ZONE, -z ZONE] [GCLOUD_WIDE_FLAG …]
For Azure:
az login -u yourazureaccount -p yourpassword
az acs kubernetes get-credentials --resource-group=<cluster-resource-group> --name=<cluster-name>
If the cluster was created using Kops utility, you could get the config file by:
kops export kubeconfig ${CLUSTER_NAME}