Automatic build and deploy with OpenShift and GitLab CI

Code, Build, and Deploy

Automated Build with S2I

As I mentioned earlier, OpenShift has CI/CD tools for accelerated application development. You can easily turn source code into running applications with S2I capabilities. This is the tool used when you type the oc new-app command (line 19). S2I produces ready-to-run images by injecting source code into a container and letting the container prepare that code for execution. As Figure 7 illustrates, it performs the following steps:

1. Start a container from the builder image, depending on the code language you use for your application.

2. Download the application source.

3. Stream the scripts and application sources into the builder image container.

4. Run the assemble script (from the builder image) and save the final image.

Figure 7: S2I steps to build and deploy an application automatically (image source: Red Hat Developer [17]).

In this example, OpenShift Origin provides S2I-enabled Node.js images for building and running Node.js applications [18]. The Node.js S2I builder image assembles the application source with any required dependencies to create a new image containing the Node.js application. This resulting image can be run either by OpenShift Origin or by Docker. S2I provides, at the moment, official images for different languages – Node.js, Perl, PHP, Python, Ruby, Wildfly – but it is also possible to use customized images.

Now, when a developer makes a new commit/push on the repository, the code is cloned from GitLab, built, and tested. Then, OpenShift builds a Docker Node.js image with S2I capabilities. The Docker image is deployed in a fresh new container in the development environment. The last container is deleted and the new application related to the last commit replaces it (Figure 8).

Figure 8: The new containerized application being deployed.

Conclusion

In this article, I described the steps needed to create a working CI/CD pipeline by combining OpenShift and GitLab CI. I showed how it can be achieved with a slide presentation example, and I showed that setting up a CI/CD process with OpenShift is within the reach of every developer.

Currently, I am improving this CI/CD process by adding more phases, such as checking the service quality and monitoring OpenShift resources with tools like Prometheus [19] and Grafana [20].

The Author

Alexandre Nuttinck is a research engineer at CETIC, Belgium. He received a master's degree in computer science from the University of Namur, Belgium, in 2017. His main fields of interest concern cloud computing, configuration management, and DevOps techniques.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy ADMIN Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus
Subscribe to our ADMIN Newsletters
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs



Support Our Work

ADMIN content is made possible with support from readers like you. Please consider contributing when you've found an article to be beneficial.

Learn More”>
	</a>

<hr>		    
			</div>
		    		</div>

		<div class=