Build DOCKER image using Openshift S2I

Source-To-Image (S2I), as the name implies, is responsible for transforming your application source into an executable Docker image that we can later run inside of OpenShift v3 or directly via `docker run`.

We can find the main project at github and bunch of sti templates for language specific builds.

We need to get the s2i tool from github release and include in PATH.

[sudhaker@dell-cs24-n2 ~]$ wget
[sudhaker@dell-cs24-n2 ~]$ ll
total 5860
drwxrwxr-x. 2 sudhaker sudhaker    4096 Feb 26 21:04 bin
-rw-rw-r--. 1 sudhaker sudhaker 5992810 Feb 18 13:23 source-to-image-v1.0.5-b731f95-linux-amd64.tar.gz
[sudhaker@dell-cs24-n2 ~]$ cd bin; tar zxf ../source-to-image-*.tar.gz; rm ../source-to-image-*.tar.gz; cd -

And the proceed with cooking docker image from a source repository.

[sudhaker@dell-cs24-n2 ~]$ sudo docker images | grep -v openshift
REPOSITORY                                   TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
[sudhaker@dell-cs24-n2 ~]$ sudo ~/bin/s2i build git:// openshift/nodejs-010-centos7 my-node-app
I0228 19:19:01.037320 01056 clone.go:32] Downloading "git://" ...
I0228 19:19:01.356601 01056 install.go:236] Using "assemble" installed from "image:///usr/libexec/s2i/assemble"
I0228 19:19:01.356684 01056 install.go:236] Using "run" installed from "image:///usr/libexec/s2i/run"
I0228 19:19:01.356740 01056 install.go:236] Using "save-artifacts" installed from "image:///usr/libexec/s2i/save-artifacts"
---> Installing application source
---> Building your Node application from source
E0228 19:19:05.417666 01056 util.go:91] npm info it worked if it ends with ok
E0228 19:19:05.417827 01056 util.go:91] npm info using npm@1.4.28
E0228 19:19:05.417915 01056 util.go:91] npm info using node@v0.10.40
E0228 19:19:05.608556 01056 util.go:91] npm info preinstall my-node-app@0.0.1
E0228 19:19:05.618591 01056 util.go:91] npm info build /opt/app-root/src
E0228 19:19:05.619139 01056 util.go:91] npm info linkStuff my-node-app@0.0.1
E0228 19:19:05.620359 01056 util.go:91] npm info install my-node-app@0.0.1
E0228 19:19:05.622702 01056 util.go:91] npm info postinstall my-node-app@0.0.1
E0228 19:19:05.623821 01056 util.go:91] npm info prepublish my-node-app@0.0.1
E0228 19:19:05.628719 01056 util.go:91] npm info ok
[sudhaker@dell-cs24-n2 bin]$ sudo docker images | grep -v openshift
REPOSITORY                                   TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
my-node-app                                  latest              85901d40c60b        55 seconds ago      438.7 MB

Let’s test this docker image

[sudhaker@dell-cs24-n2 ~]$ sudo docker run --detach --publish 8080:8080 my-node-app
[sudhaker@dell-cs24-n2 ~]$ curl http://localhost:8080/
My Node App v-1.0 !! Server : 92c707e8bedd

My basement data-center


Hardware Setup

  • Biostar NM70I-847 Intel Celeron 847 | my 24×7 file-server, web-server
  • Dell CS24-SC Server | 6 Servers | Each @ Xeon L5420 8 cores 2.5GHz, two servers with 40GB + others 24GB RAM
  • Dell PowerEdge C1100 (CS24-TY) | 1 Server | Xeon X5650 12 cores 2.66GHz, 96GB RAM (added recently)

Networking Setup

  • Verizon Fios @ 50/50 mbps
  • Servers are sitting in outer DMZ (
  • NIC and BMC ports are assigned static IP & hostname
  • Everything is connected through a Gigabit switch

Software Setup

  • Celeron server runs: samba, docker/nginx, docker/gitlab
  • Dell servers are rebuilt frequently using technique mentioned here. CentOS distribution is catched locally using technique mentioned TODO.

And I can control them from my Android phone.


Demo script for OpenShift V3

Quick demo script for OpenShift V3

# needed if running on all-in-one node

oc login -u demo

oc new-project demo
oc project demo

#oc delete all --all

#ensure git is installed
git --version

oc new-app -l app=my-node-app
watch oc status

oc expose service my-node-app -l name=my-node-app

oc get pods
oc get svc
oc get route

# scale up pod
oc scale dc/my-node-app --replicas=2
oc scale dc/my-node-app --replicas=5
oc scale dc/my-node-app --replicas=2

# pod auto-recovery
oc get pods
oc delete pod #ID

# re-build
oc start-build bc/my-node-app
oc logs bc/my-node-app

# curl based test
while true; do echo -n "$(date) || "; curl; sleep 0.2; done
### BlueGreen deployment

oc delete all --all

# deploy version 1.0
oc new-app "" --name=node-app-v1 -l app=my-node-app

oc expose service node-app-v1 --name=my-node-app -l name=my-node-app

# curl based test
for i in {1..5}; do curl; done

# deploy version 2.0
oc new-app "" --name=node-app-v2 -l app=my-node-app

oc edit route my-node-app

# curl based test
for i in {1..5}; do curl; done

### AB deployment

oc delete route my-node-app
oc delete service node-app-v1
oc delete service node-app-v2

oc create -f ab-node-app-service.json

oc expose service ab-node-app -l app=my-node-app

oc scale dc/node-app-v1 --replicas=4

oc scale dc/node-app-v2 --replicas=1

# curl based test
for i in {1..12}; do curl; done

File: my-node-app-ab-service.json

    "kind": "Service",
    "apiVersion": "v1",
    "metadata": {
        "name": "ab-node-app",
        "namespace": "demo",
        "labels": {
            "app": "my-node-app"
    "spec": {
        "ports": [
                "name": "8080-tcp",
                "protocol": "TCP",
                "port": 8080,
                "targetPort": 8080
        "selector": {
            "app": "my-node-app"
        "sessionAffinity": "None"

# A colorful demo

oc new-app -l app=nodequotes
oc expose service nodequotes -l name=nodequotes


Install the latest OpenShift V3 on CentOS 7.x

Prerequisites: CentOS 7.x minimal install (tested on 7.2)

Updated 2016/06/05: to docker 1.11.x & OPENSHIFT_VERSION=v1.2.0

Mode: Single node setup, all manual.

Step 1: Install docker and tweak INSECURE_REGISTRY for smoother operation on “integrated docker registry”.

Fix DNS (as needed)

tee -a /etc/hosts << '__EOF__' osv3-single

Continue reading Install the latest OpenShift V3 on CentOS 7.x

Install the latest Kubernetes on CentOS 7.x

This is how we get a single machine installation of Kubernetes 1.2.0 on CentOS 7.2

Update 2016-Apr-23: The latest release of Kubernetes is now available in repo “extras”.

Mode: Single node setup, extra repo.

[root@my-build-n5 ~]# date
Sat Apr 23 12:08:13 EDT 2016
[root@my-build-n5 ~]# yum info kubernetes
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Available Packages
Name        : kubernetes
Arch        : x86_64
Version     : 1.2.0
Release     : 0.9.alpha1.gitb57e8bd.el7
Size        : 34 k
Repo        : extras
Summary     : Container cluster management
URL         :
License     : ASL 2.0
Description : Container cluster management

Install ‘docker’, ‘etcd’ & ‘kubernetes’

yum install docker etcd kubernetes 
for SERVICE in docker etcd kube-apiserver kube-controller-manager kube-scheduler kube-proxy kubelet; do 
    systemctl restart $SERVICE
    systemctl enable $SERVICE
yum install cockpit cockpit-kubernetes
systemctl enable cockpit.socket
systemctl start cockpit.socket
firewall-cmd --permanent --zone=public --add-port=9090/tcp && firewall-cmd --reload

And browse to cockpit UI -> https://server_ip:9090


Modding CentOS 7.x CD to Kickstart Automatically

This is my solution for re-installing my lab server quickly. I just boot from this modded CD (source CentOS-7-x86_64-Minimal-1511) which will eject the CD after re-build and boots into a freshly baked “CentOS” in less than 10 minutes (I’ll cover KS and network setup in different post).

The trick lies in tweaking “isolinux/isolinux.cfg” – you can see original file here.


[sudhaker@dell-server ~]$ diff isolinux-orig.cfg isolinux.cfg
< timeout 600
> timeout 10
> label linux-ks
>   menu label Install CentOS 7 ^KS
>   menu default
>   kernel vmlinuz
>   append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 ks= quiet
<   menu default

Here are summary of changes (also highlighted above).

  1. Change timeout to 10 (or even lower if you like) from original 600 (10 minutes)
  2. Clone the boot option ‘linux’ section as ‘linux-ks’
  3. Make this new cloned option as default boot option
  4. Add ks=URL
  5. Remove ‘menu default’ from the old boot option