openHAB is a popular open source home automation platform that can run on a Docker container. The openHAB K3s deployment in this example uses persistent volume claims on NFS volumes and Traefik Ingress controller for easy external access to GUIs.
NOTE: The yaml-files for openHAB uses NFS Persistent volumes, hence instructions on this page needs to be done before continuing.
The following instructions assumes you are logged into the master node.
You first need to clone the openHAB Docker repo to be able to fetch the latest container additions from OpenHAB:
git clone https://github.com/openhab/openhab-docker.git openhab-docker-official
Then clone the docker-openhab repo:
git clone https://github.com/jannegpriv/docker-openhab.git openhab-docker
Change directory to openhab-docker and build the container image using docker-compose, it will take a while to build:
docker-compose build openhab3
Check that it exists in your docker image repository:
docker images
Now it is time to push it to your local Docker registry as described in this gist
You need to tag it with the local registry name and repo name and tag, in the example below k3s-master-1:5000/openhab:latest Note: This requires k3s-master-1to be present in /etc/hosts, use master node's IP instead:
docker tag openhab:3.1.0.M3 k3s-master-1:5000/openhab:latest
Then it is time to push it:
docker push k3s-master-1:5000/openhab:latest
You can try to pull the image from a worker node using cri which containerd uses:
sudo crictl --debug pull k3s-master-1:5000/openhab:latest
DEBU[2019-09-28T20:38:49.027935548+01:00] PullImageRequest: &PullImageRequest{Image:&ImageSpec{Image:k3s-master-1:5000/openhab:latest,},Auth:nil,SandboxConfig:nil,}
DEBU[2019-09-28T20:38:49.206211341+01:00] PullImageResponse: &PullImageResponse{ImageRef:sha256:cbc9490d8062bb74776d05e9e9e78ec16ba36a0f668b6bd175727e1a682bb022,}
Then it is time to clone the k3s-openhab repo:
git clone https://github.com/jannegpriv/k3s-openhab.git
Change directory to k3s-openhaband then it is time to apply the yaml-files for the openhab deployment:
k apply -f openhab-deployment.yaml
k apply -f openhab-claims.yaml
k apply -f openhab-service.yaml
k apply -f openhab-traefik.yaml
Log in to dashboard and check that everything has been created.
Check status via CLI:
k describe pod <openhab-pod-id>
k describe service <service-id>
k describe ingress <ingress-id>
k describe persistentvolumeclaims
k exec -it <openhab-pod-id> /openhab/runtime/bin/client
k exec -it <openhab-pod-id> /bin/bash
The Traefik/Ingress deployment will ensure that OpenHAB GUI can be reached using the following URL:
http://k3s-openhab.example.org
NOTE: You need to configure /etc/hosts so that k3s-openhab.example.org points to your master node.
NOTE: openHAB3.0 uses Server Side Events that are not working with Traefik 1.7 that k3s ships with, a w.o. is to turn of compression as described in: traefik/traefik#6161
kubectl edit configmap -n kube-system traefik
kubectl delete pods -n kube-system `kubectl get pods -n kube-system | grep traefik | awk '{print $1}'`