Skip to the content.

Integrating Jenkins Master with OpenShift

Please find the step-by-step guide on how to integrate a Jenkins Master with an OpenShift x86/s390x cluster. This integration will enable Jenkins to deploy and manage workload on OpenShift

Prerequisites

1 - Jenkins Master: Ensure you have a running Jenkins instance

2 - OpenShift Cluster: Ensure you have access to an OpenShift x86 cluster

3 - Jenkins Plugins: Install the following Jenkins plugins: Kubernetes Plugin

Steps for Integration

1. Create a namespace in openshift cluster

oc create namespace ocp-namespace

2. Create Service account in OpenShift cluster

oc create serviceaccount dwabuild -n ocp-namespace
oc create token dwabuild --duration=$((90*24))h -n ocp-namespace

3. Configure OpenShift Credentials in Jenkins

4. Test connection of Jenkins & OpenShift

5 . Create RoleBinding

To create pods we need to create a new RoleBinding for our user that we called ocp-namespace-admin that references the Role cluster-admin

oc create rolebinding ocp-namespace-admin --clusterrole=cluster-admin --serviceaccount=ocp-namespace:dwabuild -n ocp-namespace