Linux containers are simple, portable instances of Linux that run under the LXC container system. Whether you have Groundwork Core or Enterprise, it’s always good to have portable versions of your GroundWork servers. With containers, you can move them, copy them, snapshot them, and upgrade them (or test doing so) easily.
A Linux system with enough horsepower to run GroundWork. That usually means at least a dual-core CPU and 8 GB RAM, and 160 GB free on your hard drive. Yes, you could run this on a VM, but we can safely ignore that consideration since it’s abstract. If you want to run GroundWork on Amazon EC2, you can do it in a container as well, but you will want to follow a particular configuration option. See below.
- Install LXC
- Create a container (or download the 7.1 beta container)
- Install GroundWork in the container
- Really, it’s almost that simple. On our lab system here, running Ubuntu 14.4, step 1 is all of:
Of course, there's more to it if you want to get the most up-to-date version, but this works fine.
If you are using another distro, you can find the equivalent for your package manager.
- Just for fun, you might want the web panel too:
That gives you a nice little view into what the containers are doing.
Figure: LXC Web Panel
The web panel runs on port 5000 on your local system by default. The default username and password is admin/admin.
- Once you install, you will be able to run commands that start with lxc-, like this:
This will list all installed containers. Or you can run:
This says a bit more about the containers, like if they are running and their IP addresses.
- But first, you will need a container! If you downloaded the 7.1 beta, just un-tar it to /var/lib/lxc, like this:
Then skip to step 15, below.
- Otherwise, here's how you make one: You need an “image” to make a container with. Let’s say you are running on Ubuntu, but you want the container to run Centos. Well, you would need to install yum for that to work:
- Then you can download an image and create a container with just one line:
- Call it whatever you want. The “-n” is for name, and you can be as creative as you like.
You can start the container like this:
- Then you can attach to it like this:
- Now you have a root shell on the container! But networking is still not done. Let’s fix that.
By default, LXC installs a DHCP server that hands out private addresses to containers, so you can probably just type:
- That will get a few useful things installed. Then you can start the SSH server:
- Then set a root password:
- Finally, exit the shell:
And you are back at the prompt of your Ubuntu Linux system. From here, you can see what the IP address is with:
- You can SSH to this address (whatever it is on your system) from the Ubuntu command line:
- Now you are ready to install GroundWork. Just follow the usual instructions to transfer the file to the container and install it from a root shell. See: https://kb.groundworkopensource.com/display/FILES/GroundWork+Monitor+7.0.2
- Once GroundWork is installed, how do you access the portal pages? Isn’t the whole thing on a private address?
Yes it is. Of course you can access it using a browser from your Ubuntu desktop, but what if you want to get to it from other systems? You can’t reach that private address directly, but you can reach the address of your Ubuntu system that has LXC running on it.
You actually have two choices. You can either run Apache on the Ubuntu system and proxy HTTP requests to the GroundWork container, or you can make the container itself have an address on your normal network via a bridge. If you are running on the Amazon AWS cloud, you should use the proxy method. If you have control of your DHCP server, or can safely allocate static IP addresses, you might want to use the bridge method. The bridge method is covered nicely at this link: http://unix.stackexchange.com/questions/50201/how-to-configure-external-ip-addresses-for-lxc-guests
We recommend setting a hostname with DHCP/DNS that matches the hostname on the container, and ensuring that it correctly resolves prior to installing GroundWork.
To proxy HTTP requests to the GroundWork container, first install GroundWork on the container as mentioned above. Then install Apache and the proxy module on the Ubuntu host running the container. We will assume the Ubuntu host has address 192.168.42.103, and that the container has private address 10.0.3.110. You can adjust as necessary.
- Modify the conf file:
- Add the lines:
- Edit the /etc/apache2/mods-enabled/proxy.conf file:
Add the lines:
- Ok, now run Apache on the Ubuntu server:
- Now to modify things on the GroundWork server, SSH to the Centos container (or use lxc-attach). Find the gw-config utility, and run it:
- That will adjust all the portal configuration files to point to the proxied address. Note: depending on the version of GroundWork you are using, you might also need to do this:
- Replace ‘mycentos’ with the name of your container host. Then restart GroundWork portal services:
- Now if you point a browser to http://192.168.42.103, you will see the GroundWork portal!
There are a few limitations with the proxy approach. GDMA won’t work without a lot of adjustments that we haven’t covered here. Also, for example, it’s not possible to directly upload background files for the views application. The portal applications do work, though, and it’s adequate for testing and light-duty production monitoring. The best part is, you can move the server to any host just by stopping it (lxc-stop command) and tarring it up, then untarring it in the new location. If you use the bridge method, it’s just like having a GroundWork server on the network, but be advised that the load on the Ubuntu system network interface will be heavy, so you should use a capable machine.