kudeadm k8s cluster on azure

3/14/2020

i have followed along this excellant blog [medium blog to create an unmanaged k8s cluster on azure with kubeadm] [1]: https://medium.com/@patnaikshekhar/creating-a-kubernetes-cluster-in-azure-using-kubeadm-96e7c1ede4a and created a 2 worker and 1 master k8s cluster on azure free tier subscription. i am able to do kubectl get nodes from the master node and see that all the nodes are ready and also see that pods are up and running. everything seems to be dandy so long as i am logged into the master node

sbs-kubeadm-master:~$ kubectl cluster-info
Kubernetes master is running at https://172.0.0.4:6443
KubeDNS is running at https://172.0.0.4:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

Now, I would like to access this cluster from my laptop. i have the sudo cat /etc/kubernetes/admin.conf file, which i copied it over to the local laptop. and set the environment and all that correctly. but I get this error

Unable to connect to the server: x509: certificate is 
valid for sbs-kubeadm-master, kubernetes, kubernetes.default, 
kubernetetes.default.svc.cluster.local, not sbs-kubeadm-master.eastus.cloudapp.azure.com

so, my question is what is the server name I should give in the local kubeconfig file, I gave this, any direction will be greatly appreciated

server: https://sbs-kubeadm-master.eastus.cloudapp.azure.com:6443
-- sbolla
azure
azure-aks
kubeadm
kubernetes

1 Answer

3/14/2020

This error indicated that the Kubernetes API Server certificate generated by kubeadm does not have sbs-kubeadm-master.eastus.cloudapp.azure.com as Subject Alternative Name(SAN). Use kubeadm init as below in the master node to setup the cluster.

kubeadm reset -f    
kubeadm init --apiserver-cert-extra-sans=sbs-kubeadm-master.eastus.cloudapp.azure.com

Alternatively you can use public IP of master node as server and use it in kubeadm init

kubeadm reset -f    
kubeadm init --apiserver-cert-extra-sans=PUBLIC-IP_OF-MASTER-NODE
-- Arghya Sadhu
Source: StackOverflow