August 28, 2018 | Written by: Ram Vennam
Categorized: Compute Services | How-tos | Open Source
Share this post:
Introducing the Jenkins X open source project
IBM Cloud has a built-in, hosted Continuous Delivery toolchain that can be used for automating the building and deployment of applications. However, we know our customers sometimes like to use custom solutions, especially when building multi-cloud environments.
Jenkins X comes with regular Jenkins and additional components which are pre-wired together to provide an out-of-the-box CI/CD for cloud-native applications on Kubernetes. These additional components include Nexus for caching build artifacts and chartmuseum for Helm chart repository. It also comes with Build Packs for creating quick-start applications and generating Dockerfile, Jenkinsfile, and Helm charts for existing applications. As a result, the CI/CD experience is seamless.
In this blog, I’ll show you the installation steps to get Jenkins X running on IBM Cloud Kubernetes Service.
Installing Jenkins X on IBM Cloud Kubernetes Service
- Create a Kubernetes cluster on IBM Cloud. I recommend choosing a Standard cluster with at least 4 Core X 16GB with 3 nodes for optimal performance.
- Follow the instructions on the Access tab to point your
kubectl cli to your cluster.
- Install Helm and run `helm init` to initialize.
- Install Jenkins-X and run `jx install.`
ibm as the provider and set your Domain to the Ingress subdomain found on the IBM Cloud Cluster Overview page.
- Stand up and stretch your legs for a few minutes. The installer creates several deployments, persistent volumes, services, and ingress. After your break to stretch, run
kubectl get deployments,services,pvc,pv,ingress -n jx to see everything that got installed. Note that there are additional charges that are incurred due to the persistent volumes.
- After installation, run
jx console to launch the console. Verify that you can log in to Jenkins using the provided URL and admin password.
Configure Jenkins X to use IBM Cloud Container Registry
- Jenkins X comes with a docker registry, but we’ll change it to store images in the IBM Cloud Container Registry instead.
Go to the Jenkins Console (->
Manage Jenkins -> Configure System) and edit the
DOCKER_REGISTRY env var to your IBM Cloud Container Registry URL (
- Get your ICR token:
ibmcloud cr token-add --description "Jenkins X Token" --non-expiring --readwrite
- Encode the token :
echo -n token:<TOKEN> | base64
- Create a config.json file with the encoded token. Update the registry URL if you’re using a different registry in a different location.
"auth": "<ENCODED TOKEN>"
- Delete and recreate secret.
kubectl delete secret jenkins-docker-cfg -n jx
kubectl create secret generic jenkins-docker-cfg --from-file=./config.json -n jx
The config.json file gets mounted into the Kubernetes pods doing the build. Docker will use this file for authenticating into the Registry for pushing the application images.
The above steps are subject to change as the project continues to grow. See https://jenkins-x.io/architecture/docker-registry/ if you’re having trouble.
All done with the setup! Now for the fun part
Back in the terminal, use `jx create quickstart` to create a project.
This will create a new git repository in your GitHub org with the starter source code, a Jenkins pipeline, and a github webhook to automatically pick up any code changes. On code commits, the build checks out the source code from GitHub, builds the app, creates a Docker image, stores the image in the docker registry, and then uses the Helm chart in the repo to deploy the application to your cluster.
Make code changes in your git repository and watch for a new pipeline and an updated application. This gives you a great starting point and is ready for you to modify it to match your requirements.
I hope this post gave you a quick overview of what Jenkins X is and how you can use it with IBM Cloud Kubernetes Service. To learn more, I recommend watching the presentation from KubeCon 2018.
For questions regarding the IBM Cloud Kubernetes service, engage our team via Slack by registering here. Join the discussion in the #questions channel on https://ibm-container-service.slack.com.