Kubernetes the hard way on bare metal/VMs — Configuring remote access

Part of the Kubernetes the hard way on bare metal/VM. This is designed for beginners.

Drew Viles
1 min readDec 14, 2021
Kubernetes Logo

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 Drewbernetes \
--certificate-authority=pki/ca/ca.pem \
--embed-certs=true \
--server=https://${KUBERNETES_PUBLIC_ADDRESS}:6443 \
--kubeconfig=configs/admin/admin-remote.kubeconfig
kubectl config set-credentials admin \
--client-certificate=pki/admin/admin.pem \
--client-key=pki/admin/admin-key.pem \
--embed-certs=true \
--kubeconfig=configs/admin/admin-remote.kubeconfig
kubectl config set-context Drewbernetes \
--cluster=Drewbernetes \
--user=admin \
--kubeconfig=configs/admin/admin-remote.kubeconfig
kubectl config use-context Drewbernetes --kubeconfig=configs/admin/admin-remote.kubeconfig#Then make it permanent
cp configs/admin/admin-remote.kubeconfig ~/.kube/config

Test it!

kubectl get componentstatuses
kubectl version
kubectl get nodes

If you want to access the cluster from other locations as the admin user, cp the following file.
./configs/admin/admin-remote.kubeconfig

Conclusion

You’ve configured the cluster and the kubeconfig for remote access.

Next: Setting up Pod Routing

Unlisted

--

--