In this lab you will generate a kubeconfig file for the kubectl command line utility based on the admin user credentials.
Run the commands in this lab from the same directory used to generate the admin client certificates.
Each kubeconfig requires a Kubernetes API Server to connect to. To support high availability the IP address assigned to the external load balancer fronting the Kubernetes API Servers will be used.
Retrieve the kubernetes-the-hard-way static IP address:
KUBERNETES_PUBLIC_ADDRESS=$(az network public-ip show -g kubernetes \
-n kubernetes-pip --query ipAddress -otsv)Generate a kubeconfig file suitable for authenticating as the admin user:
kubectl config set-cluster kubernetes-the-hard-way \
--certificate-authority=ca.pem \
--embed-certs=true \
--server=https://${KUBERNETES_PUBLIC_ADDRESS}:6443kubectl config set-credentials admin \
--client-certificate=admin.pem \
--client-key=admin-key.pemkubectl config set-context kubernetes-the-hard-way \
--cluster=kubernetes-the-hard-way \
--user=adminkubectl config use-context kubernetes-the-hard-wayCheck the health of the remote Kubernetes cluster:
kubectl get componentstatusesoutput
NAME STATUS MESSAGE ERROR
controller-manager Healthy ok
scheduler Healthy ok
etcd-0 Healthy {"health": "true"}
etcd-1 Healthy {"health": "true"}List the nodes in the remote Kubernetes cluster:
kubectl get nodesoutput
NAME STATUS ROLES AGE VERSION
worker-0 Ready <none> 66s v1.17.3
worker-1 Ready <none> 62s v1.17.3