MicroK8s / Homekube Installation

In the previous step we created the container.

These steps need to be repeated for each Homekube container on the host

Install an empty Ubuntu container

This command installs and launches an empty OS Ubuntu 24.04 inside a container named homekube and applies 3 profiles in the order of specification. Later profile specs override earlier specs so we can be sure that our macvlan network settings are honored:

lxc launch -p default -p microk8s -p macvlan ubuntu:24.04 homekube

Lets check if we were successful lxc list results in something like

+----------+---------+----------------------+------+-----------+-----------+
|   NAME   |  STATE  |         IPV4         | IPV6 |   TYPE    | SNAPSHOTS |
+----------+---------+----------------------+------+-----------+-----------+
| homekube | RUNNING | 192.168.1.100 (eth0) |      | CONTAINER | 0         |
+----------+---------+----------------------+------+-----------+-----------+

Note the IP V4 indicates that the container got an IP from DHCP service of our local network. But always keep in mind that this container will not be reachable from the host. Thats the limitation of macvlan networks. In case thats too limiting for you you need to install a bridge. Read more about bridge configuration here

Clone the github repo

Its recommended to fork the repo on github and clone your fork to your server. This way you might save all your local changes or additions to your own repo and if you notice errors or suggest improvements you might easily sumbit a PR to improve homekube.

# Recommended
git clone git@github.com:<your clone>/homekube.git

# Alternative
git clone https://github.com/homekube/homekube.git

Now we install microk8s inside a container named homekube and give it access to our cloned homekube repository on the host.

cd ~/homekube   # your fork of https://github.com/homekube/homekube.git
lxc config device add homekube homekube disk source=$(pwd) path=/root/homekube
lxc exec homekube -- bash

snap install microk8s --classic --channel=1.31/stable
microk8s status --wait-ready
microk8s enable dns rbac helm3

On the host execute lxc list again and you should see something like. Sidenote: You can step out of containers with the same command when leaving a shell: exit

+----------+---------+----------------------------+------+-----------+-----------+
|   NAME   |  STATE  |            IPV4            | IPV6 |   TYPE    | SNAPSHOTS |
+----------+---------+----------------------------+------+-----------+-----------+
| homekube | RUNNING | 192.168.1.100 (eth0)       |      | CONTAINER | 0         |
|          |         | 10.1.74.128 (vxlan.calico) |      |           |           |
+----------+---------+----------------------------+------+-----------+-----------+

Fix AppArmor settings

These fixes are needed for the container to survive a reboot. When the LXD container boots it needs to load the AppArmor profiles required by MicroK8s or else you may get the error:

cannot change profile for the next exec call: No such file or directory

Now step again into the container

lxc exec homekube -- bash

and execute the next commands from inside the container

cat > /etc/rc.local <<EOF
#!/bin/bash

apparmor_parser --replace /var/lib/snapd/apparmor/profiles/snap.microk8s.*
exit 0
EOF

Make the rc.local executable:

chmod +x /etc/rc.local

Fine tuning

On order to make all our existing scripts working out of the box we need to apply the following changes once in the container:

Add aliases for kubectl and helm

cat >> .bash_aliases << EOF
alias kubectl='microk8s kubectl'
alias helm='microk8s helm3'
EOF

Reboot and enjoy

exit the container and restart lxc restart homekube it to activate the changes.
Reenter the container lxc exec homekube -- bash and verify the installation:

kubectl version
root@homekube:~# kubectl version
Client Version: v1.31.0
Kustomize Version: v5.4.2
Server Version: v1.31.0

Now We are done with installation in a Microk8s container

Install Homekube appliances

TLDR; Install all Homekube appliances in one go

lxc exec homekube -- bash
cd ~/homekube/src

# modify and set your environment variables !
set -a
. ./homekube.env.sh
set +a

echo "Please make sure that ${HOMEKUBE_NFS_SERVER_PATH} exists on ${HOMEKUBE_NFS_SERVER_URL} before proceeding with the installation !"
 
# Plain installation (without Keycloak SSO)
bash -i install-all.sh
# or install with Keycloak Single Sign On (more complex)
bash -i install-with-sso-1.sh

Learn the individual steps and take the quick tour

Now proceed with the individual steps by taking the Quick tour

Further reading

Recommendations about using lxd

Troubleshooting

Error: cannot change profile for the next exec call: No such file or directory

Tutorials