How to setup Openshift on AWS EC2

Dan Martines
2 min readMar 30, 2017

--

You would think that it’d be easy to spin up a Openshift… yet after a lot of archeology and help from my friend Michael Bechauf, here are the steps:

First spin up a EC2 instance with Amazon Linux

Amazon Linux AMI 2016.09.1 (HVM), SSD Volume Type — ami-0b33d91d

While creating your instance make sure you create a key pair and download .pem file it to your local drive. Then grab your Public DNS (IPv4) and use it to SSH into your instance

ssh -i <your key pair file>.pem ec2-user@<your instance Public DNS>.compute-1.amazonaws.com

Make sure to add the EC2 user ec2-user when running SSH

Install Docker

sudo yum install docker

Add ec2-user to docker

sudo usermod -aG docker ec2-user

Exit SSH, log back in, and start Docker

sudo service docker start

You should be able to test Docker with command

docker ps

Get Openshift from Github https://github.com/openshift/origin/releases (scroll all the way to the bottom)

wget https://github.com/openshift/origin/releases/download/v3.6.0-alpha.0/openshift-origin-client-tools-v3.6.0-alpha.0-0343989-linux-64bit.tar.gz

Untar file

tar -xvzf openshift-origin-client-tools-v3.6.0-alpha.0–0343989-linux-64bit.tar.gz

Copy Openshift comand into your bin folder

sudo cp oc /usr/local/bin/

You have to add insecure registry to docker configuration

cd /etc/sysconfig/Add option --insecure-registry 172.30.0.0/16 to ‘docker’ file

So it should look like the following:

OPTIONS="--default-ulimit nofile=1024:4096 --insecure-registry 172.30.0.0/16"

Restart Docker

service docker restart

For AWS EC2 instances you have to configure shared mounts

sudo mount --make-shared /sudo sed -i.bak -e \
's:^\(\ \+\)"$unshare" -m -- nohup:\1"$unshare" -m --propagation shared -- nohup:' \
/etc/init.d/docker

Now you are ready to start Openshift with oc cluster up command … make sure you are running as root

sudo su -[root@ip-172-31-19-218 ~]#oc cluster up --routing-suffix=<your public AWS EC2 IP address>.nip.io --public-hostname=<your AWS EC2 public DNS>.compute-1.amazonaws.com

--

--