In this Video
OpenShift provides official Jenkins images that run in containers on OpenShift.
Jenkins is a widely popular and open-source continuous integration and continuous delivery (CI/CD) tool that is used to automate building, testing and deploying application projects. OpenShift provides an official Jenkins image that runs in containers on OpenShift with the OpenShift Pipeline Plugin pre-installed which allows performing actions in OpenShift within Jenkins jobs.
OpenShift 3.2, introduced Jenkins Source-to-Image (S2I) feature which simplifies customization of the official Jenkins image through the S2I build process. You can use Jenkins S2I to copy your custom Jenkins job definitions, additional plugins, or replace the provided config.xml file with your own custom configuration. The resulting image is stored in the OpenShift registry and can be used to deploy pre-configured Jenkins instances.
The Kubernetes Plugin is also pre-installed in the official Jenkins image. This plugins allows Jenkins master to create slave pods on OpenShift and delegate running jobs to them to achieve scalability as well as providing pods with specific runtimes for specific jobs.
This video demonstrates how to use Jenkins S2I and run distributed builds through the Kubernetes Plugin.
Setting Up Jenkins
An example template for using the Jenkins S2I builder as well as creating custom slave images for building Java apps is available on GitHub:
https://github.com/siamaksade/jenkins-s2i-example
Create a new project for Jenkins:
$ oc new-project ci --display-name="CI/CD"
Give the Jenkins pod service account enough rights to be able to make API calls to OpenShift. This allows Jenkins to automatically discover slave images available in the registry.
$ oc policy add-role-to-user edit -z default -n ci
The Jenkins slave template takes any image as an input and layers Jenkins JNLP client on top of it to be used as a Jenkins slave pod. The default parameters turn a RHEL 7 image to a Jenkins slave pod that can run JDK 8 jobs. Import the Jenkins master and slave template:
$ oc create -f https://raw.githubusercontent.com/siamaksade/jenkins-s2i-example/master/jenkins-master-s2i-template.yaml
$ oc create -f https://raw.githubusercontent.com/siamaksade/jenkins-s2i-example/master/jenkins-slave-builder-template.yaml
Create a Jenkins slave image using the Jenkins slave template. You can repeat this step for all slave image types (ruby, python, etc) you need. Image Name is the name of the image you want to convert to a Jenkins slave image and Jenkins Slave Label is the slave label used by Jenkins master to discover slave pods and delegate job to them.
The template defines a build which can be viewed in Browse → Builds section. After build is finished, create the Jenkins master based on the master template via OpenShift Console or CLI:
$ oc new-app jenkins-master-s2i
Running Distributed Builds
Point your browser to Jenkins url as displayed in OpenShift Console and login with default admin user:
Username: adminPassword: password
A build job is already defined by Jenkins S2I based on the job configuration which was provided in the GitHub repo. Click on tasks-build job and then Configure. Check “Restrict where this project can be run” and specify jdk8 for Label Expression.
Note that Label Expression is how Jenkins finds the slave pods and assigns jobs to them. If you have chosen a different label when instantiating the Jenkins slave template, use the same value in the job configuration.
Start the tasks-build job and note that a slave pod gets created on-demand in OpenShift, runs the jobs and gets removed afterwards.
Conclusion
Jenkins S2I builder simplifies creating custom Jenkins images based on official Jenkins image in OpenShift by providing plugins, job and other configurations in a Git repository. This approach also promotes the infrastructure-as-code principle by applying version control on Jenkins master configurations.
Furthermore, using the Kubernetes Plugin allows running distributed builds at scale and creating Jenkins slave pods on-demand on OpenShift when running Jenkins jobs.
Über den Autor
Mehr davon
Nach Thema durchsuchen
Automatisierung
Das Neueste zum Thema IT-Automatisierung für Technologien, Teams und Umgebungen
Künstliche Intelligenz
Erfahren Sie das Neueste von den Plattformen, die es Kunden ermöglichen, KI-Workloads beliebig auszuführen
Open Hybrid Cloud
Erfahren Sie, wie wir eine flexiblere Zukunft mit Hybrid Clouds schaffen.
Sicherheit
Erfahren Sie, wie wir Risiken in verschiedenen Umgebungen und Technologien reduzieren
Edge Computing
Erfahren Sie das Neueste von den Plattformen, die die Operations am Edge vereinfachen
Infrastruktur
Erfahren Sie das Neueste von der weltweit führenden Linux-Plattform für Unternehmen
Anwendungen
Entdecken Sie unsere Lösungen für komplexe Herausforderungen bei Anwendungen
Original Shows
Interessantes von den Experten, die die Technologien in Unternehmen mitgestalten
Produkte
- Red Hat Enterprise Linux
- Red Hat OpenShift
- Red Hat Ansible Automation Platform
- Cloud-Services
- Alle Produkte anzeigen
Tools
- Training & Zertifizierung
- Eigenes Konto
- Kundensupport
- Für Entwickler
- Partner finden
- Red Hat Ecosystem Catalog
- Mehrwert von Red Hat berechnen
- Dokumentation
Testen, kaufen und verkaufen
Kommunizieren
Über Red Hat
Als weltweit größter Anbieter von Open-Source-Software-Lösungen für Unternehmen stellen wir Linux-, Cloud-, Container- und Kubernetes-Technologien bereit. Wir bieten robuste Lösungen, die es Unternehmen erleichtern, plattform- und umgebungsübergreifend zu arbeiten – vom Rechenzentrum bis zum Netzwerkrand.
Wählen Sie eine Sprache
Red Hat legal and privacy links
- Über Red Hat
- Jobs bei Red Hat
- Veranstaltungen
- Standorte
- Red Hat kontaktieren
- Red Hat Blog
- Diversität, Gleichberechtigung und Inklusion
- Cool Stuff Store
- Red Hat Summit