Aditya Samant:
@Alistair Mackay - I’m setting up a 3 node (1 controlplane and 2 workers) Kubernetes cluster locally on Macbook Pro M1 Silicon.
I’m following the instructions prepared by you in the below link and using Multipass as the solution for virtualisation.
https://github.com/kodekloudhub/certified-kubernetes-administrator-course/tree/master/kubeadm-clusters/apple-silicon
Everything works well and I can get the cluster up and running.
The problem is that on a restart of the Multipass VMs, they are allocated a new IP address. I’m not sure if its a restart of the Multipass VMs or a restart of the Macbook that causes this, but it happens.
Once the VMs come up with a new IP address allocated to them, it breaks the Kubernetes cluster.
The kubectl commands don’t work anymore as the config files all refer to the previous IP address.
Do you have any solution or recommendation for the Multipass VMs to retain their IP addresses on restart?
I really like the Multipass solution to run K8S locally, but need the IP addresses to persist over restarts to make the cluster usable over time.
Any guidance here would be really helpful.
Alistair Mackay:
I can’t answer you immediately since I borrowed a mac to do that lab. You might look through multipass documentation to see if there is anything relating to making the IPs fixed.
Aditya Samant:
I checked that page, but it does not have Mac specific instructions.
Thanks anyway. I’ll research further if there is any option.
Alistair Mackay:
A quick google search yields https://support.apple.com/en-gb/guide/mac-help/mh43557/mac
Once you have established the bridge network, the remaining commands are all generic multipass.
Aditya Samant:
@Alistair Mackay I tried my hands at this several times. It’s too complex to get the proper configuration for static IPs with multipass done on the Mac, with hardly any good examples on how to achieve it. I’m going to let this rest for now, as its not that important. I may look at it later if time permits.
Till then thanks for your help, and if you have any more tips on this topic it would really help.
Aditya Samant:
@Alistair Mackay I was able to configure a static IP for the nodes using multipass.
The steps are same as mentioned in the multipass official documentation. https://multipass.run/docs/configure-static-ips
For macOS, I just skipped step 1 which is creating a new bridge.
Instead we need to use one of the existing networks, in my case I used the network of the Wifi on my host laptop.
The below steps worked fine for me to generate a static IP which can persist over restarts. This is crucial in order to have a stable cluster that can withstand restarts.
Step a:
Launch the kubemaster instance with a manual network
multipass launch --disk 5G --memory 3G --cpus 2 --name kubemaster --network name=en0,mode=manual,mac="52:54:00:4b:ab:cd" jammy
en0 is the name of the Wifi network on the mac
Step b:
Configure the extra interface
multipass exec -n kubemaster -- sudo bash -c 'cat << EOF > /etc/netplan/10-custom.yaml
network:
version: 2
ethernets:
extra0:
dhcp4: no
match:
macaddress: "52:54:00:4b:ab:cd"
addresses: [192.168.68.101/24]
EOF'
The addresses field holds the value of the static IP to be provisioned. The static IP address should be in the same subnet as the original IP address of the instance.
Step c: Apply the new configuration
multipass exec -n kubemaster -- sudo netplan apply
To test that it generated a second static IP address, use multipass info kubemaster
Alistair Mackay:
Great work! I’ll incorporate that into the instructions next time I get my hands on my friend’s macbook.