Rancher greatly simplifies running containers on various hosts. It also has a template system which allows for easy container customization.
For those who want to use openHAB with the Rancher container management platform, it is nowadays part of the default Rancher Community catalog.
Here is a brief guide on how to get openHAB running with Rancher (assuming you have some Docker knowlegde and Docker is already installed on your machine).
With Rancher you run a Server container and per host (which connects to the server) an Agent container. On the Server you can create application Stacks that run on one or more agents. You can also run an Agent on the same host that the server runs on.
Running Rancher Server
Run the Rancher server container and let it listen at port 4444: sudo docker run -d --restart=unless-stopped -p 4444:8080 --name rancher-server rancher/server:stable
When the server container has fully started, open the Rancher UI in your browser (initial startup takes some time): e.g. browse to http://hostname:4444
Adding a Host for running Docker containers (Rancher Agent)
This host can either be the machine on which Rancher Server is running or a completely different host.
Open the āInfrastructure -> Hostsā page
Check if āThis siteās addressā is an IP that other machines can use for connecting to Rancher
When it is set to āhttp://localhost:4444ā then choose the āSomething else:ā option and enter an IP which computers in your network can use to connect to Rancher, e.g. āhttp://192.168.1.123:4444ā
Click the Save button
At step (4) of the Wizard you should enter the external IP of the machine that is going to connect to the server, e.g. ā192.168.1.123ā when it is the same machine
Now copy the command at step (5) of the Wizard and run it at the machine you want to use for running your Docker containers
Click the āCloseā button and after some time the machine should show up in the āHostsā view.
Creating an openHAB Stack
Open the āCatalog -> Communityā page, and enter āopenHABā in the search field
Click the View Details button
You optionally can customize the template options which are based on those of the openHAB Docker Readme
When you click the Launch button, a new Stack is created that is automatically deployed on the host running the Rancher Agent.
You should now be able to login at openHAB via the port youāve configured in the template (8080 by default).
Notes
Make sure to enable Access Control via āAdmin -> Access Controlā!
When you connect multiple Rancher Hosts to the Server you can assign labels to the hosts and use the āHost Labelā in the openHAB template to run openHAB on a specific host
The Rancher Catalog contains many templates that also simplify using other containerized applications
Rancher uses exactly the same Docker container as you would normally run with a docker or docker-compose command. So when openHAB is the only Docker container you use there will not be much added value of also using Rancher.
It makes a lot of sense to start using a container management platform like Rancher once you start running a lot of containers on different hosts. It allows you to easily manage all your hosts from one graphical user interface. So you can deploy, check performance metrics and logging of all connected containers/hosts using a single UI.
You can also easily open a shell in any container of the connected hosts without first having to SSH to the host and then get into the container with docker exec.
It also allows you to define health checks on containers (see Container Details screenshot). The platform will for instance mark the openHAB container as unhealthy when connections to port 8080 fail several times. When containers become unhealthy you can either manually resolve this or define a strategy the platform uses to resolve this.
The user friendly GUI also helps with simplifying Docker technology so non-Developers (Operations) can easily deploy and support containers applications stacks. Installing/upgrading complete container stacks becomes clicking some buttons, checkboxes and entering some occasional text (see openHAB Template screenshot).
There is also access control using a local user directory/LDAP/etc. What people can do with containers is managed through a permissions system.
One of the biggest downsides is of course that youāll need to learn how Rancher works and what its limitations are. It may be well worth your time when all of the functionality it provides solves more issues than you have with learning it.
Hey @wborn,
thatās a great addition! Did you think about adding your Rancher option to the official documentation under http://docs.openhab.org/installation/docker.html or in an addition article next to that one? Feel free to open a Pull Request against the docs repo!
This looks cool. I was able to start a container, but itās unclear on how to manage to add volumes like /opt/openhab/conf so that I donāt have to configure each time.
Yes volume management may be a bit different than you are used to when using Rancher.
When you run a lot of containers it does not scale well to mount directories to specific host directories which are used in the openHAB Docker readme examples. It then starts to make sense to store data at dedicated storage machines. So that when a container stops due to a server crash/restart/upgrade another one can easily take over using the same data.
There is still the (default) ālocalā volume driver option that stores the data in volumes on the same machine running the container. You usually have direct access to this data on the host via /var/lib/docker/volumes.
If you still want to mount specific directories of the host you can ofcourse always fork the catalog and modify the volumes in docker-compose.yml.tpl. Rancher Compose uses the same syntax as Docker Compose but it also supports the Go Template Engine
When you delete the stack Rancher will also delete your volumes! So you should only delete the stack when you are really sure about this (e.g. after creating a backup).
Rancher does support upgrading a stack to a new version. E.g. when openHAB 2.2.0 is released:
The catalog (hosted at GitHub) is updated
Users click the refresh button (the circle at the top right in the Catalog screenshot)
Rancher will show an āUpgradeā button for any stack that can be upgraded
After clicking āUpgradeā on a stack, Rancher will download the new container and start it with the existing volumes
The only issue with step 4. is that there are still some manual steps involved when upgrading the openHAB containers. E.g. like cleaning /userdata/tmp and /userdata/cache and possibly manually migrating /userdata/etc
All Pull Requests got merged today so now all openHAB versions (including the new 2.2.0 and 2.3.0-SNAPSHOT) can be installed via the default Rancher Community catalog!
The instructions for manually adding an openHAB catalog have been removed from the opening post.
If youāve been using this catalog you can remove it from āAdmin -> Settingsā. After refreshing the Community Catalog you should now also find an openHAB catalog item after entering āopenHABā in the search field.
This is the most complete and clean rancher community catalog contribution Iāve seen so far. The choice for different architectures and distributions is amazing and every important option is laid out nicely.
While every service except for openHAB and the SSH gateway are running on Rancher here, I will definitely give it a try the next weeks. I will probably need a USB hub for all the gateways, though.
Thanks @gersilex! Nice to know there are other Rancher users here as well.
After using Rancher for other projects it was only natural to also create an openHAB catalog item. The existing community catalog items also serve as a good source of inspiration!
It should now be possible to upgrade existing containers in most cases without manual intervention by simply clicking the āUpgradeā button.
When you manually edit files in /userdata/etc they may be overwritten during the upgrade. During the upgrade a backup of /userdata is made and stored in /userdata/backup.