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.
Sobre o autor
Navegue por canal
Automação
Últimas novidades em automação de TI para empresas de tecnologia, equipes e ambientes
Inteligência artificial
Descubra as atualizações nas plataformas que proporcionam aos clientes executar suas cargas de trabalho de IA em qualquer ambiente
Nuvem híbrida aberta
Veja como construímos um futuro mais flexível com a nuvem híbrida
Segurança
Veja as últimas novidades sobre como reduzimos riscos em ambientes e tecnologias
Edge computing
Saiba quais são as atualizações nas plataformas que simplificam as operações na borda
Infraestrutura
Saiba o que há de mais recente na plataforma Linux empresarial líder mundial
Aplicações
Conheça nossas soluções desenvolvidas para ajudar você a superar os desafios mais complexos de aplicações
Programas originais
Veja as histórias divertidas de criadores e líderes em tecnologia empresarial
Produtos
- Red Hat Enterprise Linux
- Red Hat OpenShift
- Red Hat Ansible Automation Platform
- Red Hat Cloud Services
- Veja todos os produtos
Ferramentas
- Treinamento e certificação
- Minha conta
- Suporte ao cliente
- Recursos para desenvolvedores
- Encontre um parceiro
- Red Hat Ecosystem Catalog
- Calculadora de valor Red Hat
- Documentação
Experimente, compre, venda
Comunicação
- Contate o setor de vendas
- Fale com o Atendimento ao Cliente
- Contate o setor de treinamento
- Redes sociais
Sobre a Red Hat
A Red Hat é a líder mundial em soluções empresariais open source como Linux, nuvem, containers e Kubernetes. Fornecemos soluções robustas que facilitam o trabalho em diversas plataformas e ambientes, do datacenter principal até a borda da rede.
Selecione um idioma
Red Hat legal and privacy links
- Sobre a Red Hat
- Oportunidades de emprego
- Eventos
- Escritórios
- Fale com a Red Hat
- Blog da Red Hat
- Diversidade, equidade e inclusão
- Cool Stuff Store
- Red Hat Summit