Edit the microk8s template file.
vim /var/snap/microk8s/current/certs/csr.conf.template
Add the new IP Address, make sure to use a higher number for the IP address.
IP.100 = 192.168.1.1
It should look like this.
...
[ 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
IP.1 = 127.0.0.1
IP.2 = 192.168.1.1
IP.100 = 192.168.1.1 # USE IP > 100
#MOREIPS
...
Refresh certificate
sudo microk8s refresh-certs -e ca.crt
Check new IP was added
sudo cat /var/snap/microk8s/current/certs/csr.conf
Reboot the PC, just to make sure everything is OK
sudo reboot -h now
You may need to re-join all nodes since we created a new certificate and they aren’t aware of this change.
ubuntu – microk8s, DEVOPS : Unable to connect to the server: x509: certificate is valid for <internal IPs>, not <external IP> – Stack Overflow: Add public IP to Microk8s