Deploying Docker Image in OpenShift

On this series on Kubernetes/Docker/Containers, I’ve shown how to deploy a docker image on a vanilla Kubernetes platform, and deploying the same image on Amazon EC2 Container Service. This time, I wanted to test how to deploy the same image on Red Hat’s OpenShift Container Platform.

OpenShift is Red Hat’s offering to bring Docker and Kubernetes to the enterprise. There is an upstream community project called Origin which provides open source container application platform.

OpenShift Online

Red Hat offers cloud-based OpenShift Online. You could sign-up for a free OpenShift Online platform access to try it out. This gives you a limited environment but sufficient enough to do our test deployment. On another note, Red Hat OCP can be deployed on-premise on a RHEL environment.

¬†Once you have the access, let’s start by creating a new project.

OpenShift has features where you could create an application from scratch using templates, or importing a YAML/JSON specification of our applications, or as for this example, deploy an already created image.

Once your project is created after clicking that Create button, Select Deploy Image

I will be using the same dockerflask image used in the previous examples. (note: I made some minor changes on the application and the Dockerfile manifest)

After hitting the search button, OpenShift displays some information about our image.

Time to hit Deploy

and that should deploy our image.


OpenShift automatically deployed our image. As we can see here, we have one pod running our application. It also created a service that automatically talks (port 8000 tcp) to our pod(s). Later we will increase the number of our pods and we can see that the service will automatically load balance the request. The changes I made on our application is to show the host name where the application is running from.

For now, let’s create a Route to our application so we can access it externally.

Once you hit Create, you’ll be provided with a link for your application.

We can now access our application externally.

Let’s try increasing the number of our pods. Here I set it to run 2 pods.


Hitting that url again

Using curl to check if the service indeed is doing load balancing.

As you can see from the above, OpenShift Service did load balanced the request as we see the host name changes based on which pod processed the request. We could put in auto-scaling configurations that will increase the number of pods to handle the load accordingly.

Red Hat OpenShift Container Platform provides enterprises with on-cloud (OCP Online) or on-premise container platform. With this series, it showed what containers is and how technology is moving away from the traditional way of deploying and managing applications.


Trying out Amazon EC2 Container Service (Amazon ECS)

In the previous post I wrote, I showed how to build/configure a Kubernetes platform where we could run Docker image/containers. Container technology allows us to have consistent way to package our application and we could expect that it will always run the same way regardless of the environment. With this, I wanted to test our previous application and check out what Cloud providers such as Amazon Web Services (AWS) and Google Cloud Platform (GCP) offers in this space.

Amazon EC2 Container Service (AWS ECS)

Amazon ECS is an AWS service that makes it simple to store, manage and deploy Docker containers. Using this service, we don’t have to install a Container platform and Orchestration Software to run our container images. Since AWS ECS is tightly integrated with other AWS Services, we can expect that we could utilize other services such as AWS Load Balancer, IAM, S3 etc.

Amazon EC2 Container Registry

Amazon EC2 Container Registry (Amazon ECR) provides a container registry where we could store, manage and deploy our Docker images. Amazon ECR also eliminates the need to setup and manage a repository for our container images. Since it using S3 at the back-end, it provides us a highly available and accessible platform to serve our images. It also provides a secure platform since it transfers our images using https and secures our images at rest. By leveraging AWS IAM, we can control access to our image repository. So let’s get started.

Under the Compute Section, click EC2 Container Service.

We will create a new image and deploy our application so leave the default selection and click Continue.

In the next page, I’ll be using awscontainerio as the name of this repository.

After clicking Next Step, you should be presented with something similar below. Using AWS Cli, we can now push our docker image to our repository by following the steps listed.

I will be using the application and Dockerfile from the previous post to test AWS ECS.

[root@k8s-master dockerFlask]# aws ecr get-login –no-include-email –region us-east-1
docker login -u AWS -p <very-long-key>
[root@k8s-master dockerFlask]# docker login -u AWS -p <very-long-key>
Login Succeeded
[root@k8s-master dockerFlask]# docker build -t awscontainerio .
Sending build context to Docker daemon 128.5 kB
Step 1 : FROM alpine:3.1
—> f13c92c2f447
Step 2 : RUN apk add –update python py-pip
—> Using cache
—> 988086eeb89d
Step 3 : RUN pip install Flask
—> Using cache
—> 4e4232df96c2
Step 4 : COPY /src/
—> Using cache
—> 9567163717b6
Step 5 : COPY app/ /src/app/
—> Using cache
—> 993765657104
Step 6 : COPY app/ /src/app/
—> Using cache
—> 114239a47d67
Step 7 : COPY app/templates/index.html /src/app/templates/index.html
—> Using cache
—> 5f9e85b36b98
Step 8 : COPY app/templates/about.html /src/app/templates/about.html
—> Using cache
—> 96c6ac480d98
Step 9 : EXPOSE 8000
—> Using cache
—> c79dcdddf6c1
Step 10 : CMD python /src/
—> Using cache
—> 0dcfd15189f1
Successfully built 0dcfd15189f1
[root@k8s-master dockerFlask]# docker tag awscontainerio:latest
[root@k8s-master dockerFlask]# docker push
The push refers to a repository []
596bab3c12e4: Pushed
e24802fe0ea0: Pushed
fdee42dc503e: Pushed
2be9bf2ec52c: Pushed
9211d7b219b7: Pushed
239f9a7fd5b0: Pushed
8ab8949d0d88: Pushed
03b625132c33: Pushed
latest: digest: sha256:8f0e2417c90ba493ce93f24add18697b60d34bfea60bc37b0c30c0459f09977b size: 1986
[root@k8s-master dockerFlask]#

Continue reading “Trying out Amazon EC2 Container Service (Amazon ECS)”