Setting up Kubernetes with Jenkins (on IBM RedHat Openshift)

Pranav Bhatia
3 min readAug 24, 2020

--

This article will be focussing on how to setup a Kubernetes cluster with Jenkins pipeline. In this tutorial, we will be creating a pipeline that will automatically deploy an Heroku application built on Flask. Something like this (if you are an AoE fan probably you would be a bit more interested in this article)
You can also have a look at other cool free APIs here — https://github.com/public-apis/public-apis/blob/master/README.md

1. Setting up Jenkins

Assuming you already have a cluster running — (tested my demo on Openshift) — run the following command to set up Jenkins.

helm install my-release stable/jenkins

You need to run this following ingress to open it on a browser —

Copy it into a textfile and give it a name — ingress.yaml and run the following command to create an ingress resource

kubectl apply -f ingress.yaml

Check the Jenkins application running it on —
http://jenkins.<your_cluster_sub_domain>

You can get the password by using the following command — (username would be admin)

Run this in your terminal —

printf $(kubectl get secret --namespace <namespace> my-release-jenkins -o jsonpath="{.data.jenkins-admin-password}" | base64 --decode);echo

2. Creating credentials for Heroku

Create an Heroku account — https://www.heroku.com/

After that generate your Secret Token — https://dashboard.heroku.com/account

Copy and save that value somewhere safe. We will use it in Jenkins.

Go to the following Jenkins page —
<jenkins_url>/credentials/store/system/domain/_/

Add a credential —

Create HEROKU_ID as shown in figure —

Do similar with HEROKU_API_KEY and copy the Secret Token you generated in Heroku.

3. Creating your Jenkins pipeline

Click on New Item

Fill in the following —

Click on Configure

Fill out the following —

For repository URL —
https://github.com/prav10194/kubernetes-jenkins

After that, click on Build Now

If everything goes well, you would see the following pipeline —

3. Accessing the web application

On the Jenkins page, you need to click on the small triangle down arrow as shown in figure and need to select Console Output

Scroll to the end and you will see the URL of the app published.

Click on the link to access the webpage.

That should be all. Feel free to write down your questions if you have any trouble accessing the environment.

--

--

No responses yet