I have multiple microk8s clusters (arch64 and arm) but during the installation all are named microk8s-cluster.
I am trying to manage my clusters from a separate server but having all the clusters internally named microk8s-cluster is preventing me from using the ‘kubectl config use-context’ command, as it always chooses the first cluster named ‘microk8s-cluster’.
As a work around I have aliases that set the KUBECONFIG variable to point to different config files. The problem with this method is the ‘config view’ command does not tell me which cluster I am really working on. I have to issue a ‘get nodes’ to see the servers.
Is there a way to set the cluster name at creation or rename a cluster in microk8s?
When you get the kubeconfig in microk8s you can always change the clustername accordingly.
microk8s config
Thanks, I had done that, but also changed the ip address to its FQDN.
Strangely I can use the FQDN if I I do not change the cluster-name in the config file. If I change the cluster-name I need to use the IP address.
If I used the FQDN along with a changed cluster-name I get a certificate error:
X509: certificate is valid for kubernetes, kubernetes.default, kubernetes.default.svc, kubernetes.default.svc.cluster, kubernetes.default.svc.cluster.local, not rpi-k8s-cnode0.local
In order to register the fqdn with the certificate list, you need to change the file /var/snap/microk8s/current/certs/csr.conf.template
and add your fqdn in the DNS
list.
Example:
[ alt_names ]
DNS.1 = kubernetes
DNS.2 = kubernetes.default
DNS.3 = kubernetes.default.svc
DNS.4 = kubernetes.default.svc.cluster
DNS.5 = kubernetes.default.svc.cluster.local
DNS.99 = <your node's fqdn>
IP.1 = 127.0.0.1
IP.2 = 10.152.183.1
#MOREIPS
If you are running a multi node cluster you may have to temporarily rename this file var/snap/microk8s/current/var/lock/no-cert-reissue
to something else.
Wait for a few seconds for the auto cert regeneration then change the name back to no-cert-reissue
Can you try this?
Thanks
1 Like
That did work. Thank you.
I have one more issue which I will try to take care of on my own.
That is each of the microk8s instances specifies the user ‘admin’ and when I have multiple configs in the variable KUBECONFIG (KUBECONFIG=$HOME/.kube/arch64k8s:$HOME/,kube/armk8s) the password of the second one in the list appears to be dropped. You can see this with:
kubectl config view --merge --flatten
I am guessing I will need to add a new admin user to one of them. But I want to play with this for a while on my own.
I think if im not mistaken the user
can be arbritrary and is not related to the user in cluster.
But i can be wrong here.
How did you assign a FQDN in the first place instead of an ip address?
Thanks!