Convert Simple apps to Kubernetes

While doing research on Kubernetes, I was getting tired of running the same nginx server with no pizzazz, so I set up a couple of simple apps to make things more interesting.

I decided to modify nginx to display different colors for each instance: Red and Blue. For each instance I did similar steps

mkdir red && cd red
echo Red > index.html
echo 'FROM nginx
COPY index.html /usr/share/nginx/html' > Dockerfile
sudo docker build .
...

Successfully built 7bb6d362f021

Now that we have an image, let’s tag it and send it to our local docker registry.

sudo docker tag 7bb6d362f021 localhost:5000/red

This results in a new image on our registry

sudo docker images |grep red
localhost:5000/red latest 7bb6d362f021 2 minutes ago 109MB

And run it with docker

$ docker run -d -p 8085:80 localhost:5000/red
$ curl localhost:8085
Red

In general, when converting an application to using docker, we:

  1. Get a (simple) working version of the application
  2. Create a new docker image that starts with a known-good base and adds application specifics.
  3. Test
  4. Repeat steps 2 and 3
  5. Publish to a docker registry.