In this lab, we will learn to create a build pipeline on OpenShift. This pipeline will be setup using Jenkins running as an application pod on OpenShift. The pipeline running on Jenkins will trigger builds and deployments on OpenShift.
Important
|
Please replace Username with your username |
-
login to web UI via {{CONSOLE_ADDRESS}}
-
Use the same username and password that assigned to you
-
Click
Developer
underAdministrator
to switch to Developer persona -
Click onto
Project
on the top -
Click
Create Project
-
Enter pipeline-Username as name of the project. The display name and description is optional.
-
Alternatively, you can run this command below via CLI.
-
Login to the cluster via {{API_URL}}
[~]$ oc login {{API_URL}}
The server uses a certificate signed by an unknown authority.
You can bypass the certificate check, but any data you send to the server could be intercepted
by others.
Use insecure connections? (y/n): y
Authentication required for {{API_URL}} (openshift)
Username: user1
Password:
Login successful.
-
Navigate to
+Add
-
Click on
From Catalog
-
Check the
checkbox
next toTemplate
-
Enter
Jenkins
in theFilter by keyword
-
Click
Jenkins (Ephemeral)
-
Click
Instantiate Template
-
Take the default values and click
Create
-
Navigate to
Topology
-
Click onto the middle of the Jenkins icon to see the details
-
Wait for the solid blue ring shows on the icon
-
Click onto the route link to go to Jenkins Console
-
Click
Advanced
-
Click the link where
Proceed to jenkins-…
-
Click
Log in with OpenShift
-
Click
htpasswd
-
Login using your user name
-
Click
Allow selected permissions
-
You now login the Jenkins console
-
Create pipeline via web terminal
[~]$ oc project pipeline-userx
[~]$ oc create -f https://raw.githubusercontent.com/openshift/origin/master/examples/jenkins/pipeline/nodejs-sample-pipeline.yaml
buildconfig.build.openshift.io/nodejs-sample-pipeline created
-
Grant permissions to jenkins sevice account for access to the project.
[~] $ oc adm policy add-cluster-role-to-user cluster-admin system:serviceaccount:pipeline-Username:jenkins -n pipeline-Username
clusterrole.rbac.authorization.k8s.io/admin added: "system:serviceaccount:pipeline-Username:jenkins"
NOTE: NOTE: pipeline-Username will be replaced to your project name
-
Go back to your web console {{CONSOLE_ADDRESS}}
-
Navigate to
Build
-→Build Configs
-
Click onto
nodejs-sample-pipeline
-
Click
Actions
dropdown on the top right -
Select
Start Build
-
Build starts as show below
-
Click
View Logs
-
Click
Open Blue Ocean
from the Jenkins Console
-
Blue Ocean console here (may take a minute to show up):
-
Go back to OpenShift web console
-
When Pipleline build is completed, navigate
Network
-→Route
-
Click onto the link under
LOCATION
fornodejs-mongodb-example
Congratulations!! In this lab, you have learnt how to set up and run your own CI/CD pipeline on OpenShift.