Kubernetes the hard way on bare metal/VMs — Configuring remote access
Part of the Kubernetes the hard way on bare metal/VM
--
Introduction
This guide is part of the Kubernetes the hard way on bare metal/VMs series. On its own this may be useful to you however since it’s tailored for the series, it may not be completely suited to your needs.
Configure remote access
Setup the admin config file.
Back on the lab machine where you generated the certs, kubeconfigs etc (so not the controllers or workers), run the following commands.
kubectl config set-cluster DeeToTheVee-kubernetes \
--certificate-authority=pki/ca/ca.pem \
--embed-certs=true \
--server=https://${KUBERNETES_PUBLIC_ADDRESS}:6443 \
--kubeconfig=configs/admin/admin-remote.kubeconfigkubectl config set-credentials admin \
--client-certificate=pki/admin/admin.pem \
--client-key=pki/admin/admin-key.pem \
--kubeconfig=configs/admin/admin-remote.kubeconfigkubectl config set-context DeeToTheVee-kubernetes \
--cluster=DeeToTheVee-kubernetes \
--user=admin \
--kubeconfig=configs/admin/admin-remote.kubeconfigkubectl config use-context DeeToTheVee-kubernetes --kubeconfig=configs/admin/admin-remote.kubeconfig#Then make it permanent
cp configs/admin/admin-remote.kubeconfig ~/.kube/config
Test it!
kubectl get componentstatuses
If you want to access the cluster from other locations as the admin user, cp the following files.
./configs/admin/admin-remote.kubeconfig
./pki/admin/admin.pem
./pki/admin/admin-key.pem
Note. The kube config will have a full path configured within it, such as:
client-certificate: /home/USER/kubernetes-the-hard-way/pki/admin/admin.pem
client-key: /home/USER/kubernetes-the-hard-way/pki/admin/admin-key.pem
These will need updating to the new absolute path locations of the .pem files on your other machines.
Conclusion
You’ve configured the cluster and the kubeconfig for remote access.
Next: Setting up DNS