Deploy Applications to Red Hat OpenShift Using Microsoft Azure DevOps Pipeline
Simple steps
In this blog, we’ll go through all the steps in setting up a pipeline using MS Azure DevOps to deploy an application on Red Hat OpeShift.
Prerequisites
- GitHub account
- Azure Subscription
- Red Had OpenShift cluster
Steps
Step#1: Create Azure DevOps Organization
The Organization is used to store your projects and manage access to data. Access Azure Pipelines page and click on start free, and follow the its steps. Write your organization name, in my case BashayrAlabdullah 😬
Step#2: Create project
Step#3: Install OpenShift extension
From the marketplace here click on Get it free
, install to the organization
Step#4: Create service connection
To connects Microsoft Azure DevOps to your OpenShift cluster, you need to configure the OpenShift service connection.
- Click on Project settings
- Select Service Connections
- Select OpenShift
Select the authentication method you want: Basic, Token or No authentication
Step#5: Create the pipeline
Let’s go now to the pipelines
and click on Create Pipeline
. My code on GitHub, I chose GitHub
Then, Authorize Azure Pipelines. You’ll be prompted to choose a repository.
After your connection to GitHub has been authorized, configure your pipeline and select Starter pipeline
Click on Show assistant
to
Search and select Execute oc command OC
and the click on Add
. Repeat the steps for the following commands:
oc new-app https://github.com/Bashayr29/simple-app.gitoc expose svc simple-appoc start-build simple-app --followoc status
the final pipeline
Save and run the pipeline
Access the job and watch it 😍
The job status is success 🎁
Step#6: Check the deployment on your OpenShift cluster
echo "http://$(oc get route simple-app -o jsonpath='{.spec.host}')"
Now, let’s have fun and commit some changes to the repo. I want to change the message from Hi there!
to Hi there!, from Azure DevOps
and then push this change to the main branch.
The job status is running 🏃♀ wait till the job is done
refresh the page
yaaa! Now every time the pipeline is triggered, a new build starts, and our application is pushed to the cluster.
And that’s all folks. Thank you for reading💛 ❤️
Bye!
Reference: