A few of the projects I work with use static websites based on middleman, which you can run locally to see how your edits, or those of others, will look on the live site when they’re merged.
Each of these sites defaults to port 4567 when running locally, so if I’m running more than one of them at a time, they complain that their favored port is already taken. It’s easy enough to fire up middleman on a different port, but I thought I’d try and run a couple of these in containers, using a local instance of OpenShift Origin, a Kubernetes-based container application platform.
It’s pretty easy to get up and running with an OpenShift Origin instance using the command
oc cluster up. The oc client is available for Linux, Windows and Mac OS. Since containers (pretty much) are Linux, you’ll need a Linux VM on Mac or Windows, but the oc client can use docker machine to take care of that for you. I haven’t tested that, though, because I use Linux already.
On Fedora, I followed these instructions, with the exception of installing the oc client from the Fedora repos (
dnf install -y origin-clients), rather than downloading the binary from GitHub.
I wanted my origin install to persist across restarts, so I created a folder in my home directory to store persistent data, and started up my instance with:
$ sudo oc cluster up --host-data-dir=/home/jbrooks/origin-data --use-existing-config
sudo was necessary because I haven’t set up my regular user account to run docker without it — not a big deal, but some config files for logging in to my origin instance as admin ended up in my
/root directory instead of my home directory, so I copied those over:
$ sudo cp -r /root/.kube ~/.
$ sudo chown -R jbrooks:jbrooks ~/.kube
I logged into the OpenShift web console using the URL and the developer:developer user name and password output by the
oc cluster up command, clicked “Add to Project”, and then, under the “Languages” heading, chose “Ruby,” and then “Ruby 2.3”, because middleman is a ruby affair.
I filled in a name, pasted in the git repository URL for the ovirt middleman site, and hit “Create.”
I headed to the “Overview” page, saw that my build was running, clicked “View Log,” and saw that a familiar-looking build process was chugging along.
When the build finished, OpenShift kicked off a deployment of my image, which I could see from the deployment log linked from the overview page, was erroring out.
After some poking around, I fixed the issue by heading to the deployments section of the web console and, after first pausing the deployment, hitting the edit YAML button. I used the YAML editor to add a command right in between the image and ports sections of the configuration.
I also changed the containerPort from a default of 8080 to the middleman default of 4567. I expected this change to filter down to the service and route that were automatically created for me, but they didn’t — it wasn’t tough to edit those via the web console, however.
GIT_COMMITTER_EMAIL environment variables to my deployment, from an “Environment” tab in the deployments area of the console. As I eventually learned, git got grumpy about running as a random UID (as is OpenShift’s security-conscious custom) rather than as a “real” user with an entry in
/etc/passwd, but adding those ENV variables calmed git down.
Once I had a pod up and running, I was able to view the development site in my web browser via the URL provided in the routes section of the console.
Next, I headed to my terminal to log into my running pod with OpenShift’s
oc rsh command, and fetch and check out a pending pull request on the ovirt site:
$ oc rsh ovirt-site-2-4-50eao
$ git fetch origin pull/877/head:pr-ovirt-gluster-411
$ git checkout pr-ovirt-gluster-411
The middleman development server handles live reloading, so once I checked out the new branch, it refreshed, and I could see my awaiting-merge blog post:
This works, but I’ll probably hone the process some more from here. I experimented a bit with using kompose to put together a simple docker compose-formatted manifest for my app that could either pull from an openshift-built or a built-elsewhere docker container. Like this:
- GIT_COMMITTER_NAME="Jason Brooks"
I think that that approach would then work for a regular kube cluster or, with some tweaking, probably, docker or docker swarm as well.