Home

Awesome

For a CI/CD demo using Tekton Pipelines and Argo CD on OpenShift refer to: https://github.com/siamaksade/openshift-cicd-demo

CI/CD Demo - OpenShift Container Platform 4.6

This repository includes the infrastructure and pipeline definition for continuous delivery using Jenkins, Nexus, SonarQube and Eclipse Che on OpenShift.

Introduction

On every pipeline execution, the code goes through the following steps:

  1. Code is cloned from Gogs, built, tested and analyzed for bugs and bad patterns
  2. The WAR artifact is pushed to Nexus Repository manager
  3. A container image (tasks:latest) is built based on the Tasks application WAR artifact deployed on WildFly
  4. If Quay.io is enabled, the Tasks app container image is pushed to the quay.io image registry and a security scan is scheduled
  5. The Tasks container image is deployed in a fresh new container in DEV project (pulled form Quay.io, if enabled)
  6. If tests successful, the pipeline is paused for the release manager to approve the release to STAGE
  7. If approved, the DEV image is tagged in the STAGE project. If Quay.io is enabled, the image is tagged in the Quay.io image repository using Skopeo
  8. The staged image is deployed in a fresh new container in the STAGE project (pulled form Quay.io, if enabled)

The following diagram shows the steps included in the deployment pipeline:

The application used in this pipeline is a JAX-RS application which is available on GitHub and is imported into Gogs during the setup process: https://github.com/OpenShiftDemos/openshift-tasks

Prerequisites

Get OpenShift 4

Download and install CodeReady Containers in order to create a local OpenShift 4 cluster on your workstation. Otherwise create an OpenShift 4 cluster on the public cloud or the infrastructure of your choice.

Automated Deploy on OpenShift

You can se the scripts/provision.sh script provided to deploy the entire demo:

./provision.sh --help
./provision.sh deploy 
./provision.sh delete 

If you want to use Quay.io as an external registry with this demo, Go to quay.io and register for free. Then deploy the demo providing your quay.io credentials:

./provision.sh deploy --enable-quay --quay-username quay_username --quay-password quay_password

In that case, the pipeline would create an image repository called tasks-app (default name but configurable) on your Quay.io account and use that instead of the integrated OpenShift registry, for pushing the built images and also pulling images for deployment.

Manual Deploy on OpenShift

Create the following projects for CI/CD components, Dev and Stage environments:

# Create Projects
oc new-project dev --display-name="Tasks - Dev"
oc new-project stage --display-name="Tasks - Stage"
oc new-project cicd --display-name="CI/CD"

# Grant Jenkins Access to Projects
oc policy add-role-to-group edit system:serviceaccounts:cicd -n dev
oc policy add-role-to-group edit system:serviceaccounts:cicd -n stage

And then deploy the demo:

# Deploy Demo
oc new-app jenkins-ephemeral -n cicd  
oc new-app -n cicd -f cicd-template.yaml

To use custom project names, change cicd, dev and stage in the above commands to your own names and use the following to create the demo:

oc new-app -n cicd -f cicd-template.yaml --param DEV_PROJECT=dev-project-name --param STAGE_PROJECT=stage-project-name

JBoss EAP vs WildFly

This demo by default uses the WildFly community image. You can use the JBoss EAP enterprise images provide by Red Hat by simply editing the tasks build config in the Tasks - Dev project and changing the builder image from wildfly to jboss-eap70-openshift:1.5. The demo would work exactly the same and would build the images using the JBoss EAP builder image. If using Quay, be sure not to leave the JBoss EAP images on a publicly accessible image repository.

Troubleshooting

Demo Guide

Using Eclipse Che for Editing Code

You can install Eclipse Che on OpenShift 4 using the OperatorHub. Follow the Installing Che on OpenShift 4 from OperatorHub docs in order to install Eclipse Che 7. Alternatively, if you OpenShift cluster is accessible over the internet, you can use the hosted Eclipse Che service at https://che.openshift.io .

You can then follow these instructions to use Eclipse Che for editing code in the above demo flow.