Skip to content

Instantly share code, notes, and snippets.

@wborn
Last active October 15, 2017 22:26
Show Gist options
  • Select an option

  • Save wborn/a8f4c106cbf9d5992269d18e1aa12466 to your computer and use it in GitHub Desktop.

Select an option

Save wborn/a8f4c106cbf9d5992269d18e1aa12466 to your computer and use it in GitHub Desktop.
Running openHAB with Rancher

See: openHAB Community: Running openHAB with Rancher

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, I've put in Pull Request #621 today to get openHAB into the 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

  1. 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

  2. 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 the openHAB catalog

  1. Open the 'Admin -> Settings' page

  2. Scroll down to the 'Catalog' section and click on 'Add Catalog'

  3. Now enter the following details: Name: openHAB URL: https://github.com/wborn/community-catalog.git Branch: openhab-only

  4. Click Save to persist to the new catalog

  5. Reload your browser and it should now show a 'openHAB' menu item under the 'Catalog'

Catalog Settings

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.

  1. Open the 'Infrastructure -> Hosts' page
  2. Check if "This site's address" is an IP that other machines can use for connecting to Rancher
  3. 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"
  4. Click the Save button
  5. 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
  6. 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
  7. Click the "Close" button and after some time the machine should show up in the "Hosts" view.

Creating an openHAB Stack

  1. Open the 'Catalog -> openHAB' page, which should show just an openHAB entry
  2. Click the View Details button
  3. You optionally can customize the template options which are based on those of the openHAB Docker Readme
  4. 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'!
  • Once openHAB is part of the Community Catalog, the steps for adding the openHAB Catalog can be skipped
  • 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

Screenshots

CatalogTemplateLogging

User StacksHost Details

Container Details

See also

@wborn
Copy link
Author

wborn commented Sep 18, 2017

catalog

template

logging

settings-catalog

user-stacks

host-details

container-details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment