mak3r / turnkey

turnkey operations from containers - prebuilt images with k3s running hosting the setup container
Apache License 2.0
9 stars 2 forks source link

Integrate system upgrade controller #6

Closed mak3r closed 4 years ago

mak3r commented 4 years ago

The system is now capable of being configured to use the wireless NIC wlan0 by user interaction. At this point however, there are manual steps which need to be done in order to restart the system such that the user can access the k3s cluster in the network they have configured.

We need to modify the host OS to expose the network. Ideally, we will be able to not only turn the reigns over to the user but also to revert the system to be reset for the base turnkey configuration. Both of these things can be accomplished by using the system upgrade controller. https://github.com/rancher/system-upgrade-controller

Turn the reigns over to the user

It is not yet clear what the best solution will be so here are a couple of options.

Option 1

The benefit of this solution may be it's simplicity

  1. get the gateway default for wlan0 gwip=$(ip r | grep -e "default" | grep -e "wlan0" | awk '{print $3}')
  2. add (or replace) the IP in /var/lib/rancher/turnkey/resolv.conf echo "nameserver $gwip" >> /var/lib/rancher/turnkey/resolv.conf
  3. delete the default route on eth0 ip r del default via 192.168.1.1 dev eth0

Option 2

The benefit of this solution is that it "gives back" the eth0 adapter if the end-user wants also use ethernet

  1. write the wpa_supplicant.conf to the host
    • currently this is only available as a configmap in the cluster
    • from the wifi container
      • mount the host /etc/wpa_supplicant directory
      • cp the local wpa_supplicant to the host /etc/wpa_supplicant/wpa_supplicant.conf
  2. and enable wpa_supplicant
    • this requires that wpa_supplicant is configured appropriately
    • systemctl enable wpa_supplicant
    • systemctl start wpa_supplicant
  3. and restart k8s without pointing to the /var/lib/rancher/turnkey/resolv.conf
    • rm --resolv-conf flag from k3s or restart without it
  4. cleanup the host /etc/rc.local file which bootstraps eth0

Reset the system

With the use of a systemd configuration file, it is possible to scan the /boot directory for a specific file and if it exists, take steps to reset.