Metalogin simplifies access to your lovely bare-metal Kubernetes cluster.
It receives necessary information from Kubernetes API node via SSH and creates a context in your local ~/.kube/config.
Literally, after executing this:
ssh [user]@[cluster-IP] "sudo cat /etc/kubernetes/admin.conf" \ | docker run -i --rm -v ~/.kube/:/kube moikot/metalogin -c /kube/config
You should be able to execute
kubectl get nodes on your local machine.
No installation, no fiddling with certificates, contexts or users.
This command does require Docker though.
You can also build and run it locally if you have a Golang environment. In such case you need to run the following commands:
go get github.com/moikot/metalogin ssh [user]@[cluster-IP] "sudo cat /etc/kubernetes/admin.conf" | ~/go/bin/metalogin -c ~/.kube/config
What it actually does
- First of all, it receives
configfile from your Kubernetes API node and deserializes it.
- It tries to find a cluster record in it with name
kubernetes. This record corresponds to the bare-metal Kubernetes cluster.
- It uses
serverfield and assuming that it has a correct URI format, it tries to extract the server hostname. Usually, it's the IP address you used in the SSH call.
- It creates a cluster record in the local configuration with name
host_nameis the hostname extracted on the previous step. All the other fields like
serverare copied from the source record.
- It tries to find a user record with name
kubernetes-adminand when it succeeds it creates a user record in the local configuration with name
kubernetes-admin-[host_name]and then copies content of
client-key-datafields from the source.
- It creates a context with name
kubernetes-admin-[host_name]@kubernetes-[host_name]using previously created cluster and user.
- Finally, it sets the created context as the current one.