Featured Carousel

Installing Jenkins X on IBM Cloud Kubernetes Service

Share this post:

Introducing the Jenkins X open source project

The Jenkins X open source project is a continuous delivery solution that was designed and configured especially for Kubernetes. It comes with a simple installer tool that provides a turn-key install when pointed at a Kubernetes cluster, and it supports multiple Kubernetes environments with custom configurations for each.

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.`
  • Choose 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

  1. 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 (registry.ng.bluemix.net).
  2. Get your ICR tokenibmcloud cr token-add --description "Jenkins X Token" --non-expiring --readwrite
  3. Encode the token :
    echo -n token:<TOKEN> | base64
  4. Create a config.json file with the encoded token. Update the registry URL if you’re using a different registry in a different location.
    {
      "auths": {
        "registry.ng.bluemix.net": {
          "auth": "<ENCODED TOKEN>"
        }
      }
    }
    
  5. 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.

IBM Cloud Technical Offering Manager

More Featured Carousel stories
September 19, 2018

Serverless Functions vs. Virtual Machines: A Total Cost of Ownership Comparison

Explore relevant costs, performance, and availability issues for a Total Cost of Ownership comparison of virtual machine and serverless functions.

Continue reading

September 10, 2018

Debunking 7 Serverless Myths

There are plenty of myths associated with serverless functions that prevent teams from adopting this technology. Were going to debunk the top seven serverless myths about IBM Cloud Functions.

Continue reading

September 6, 2018

Geospatial Without Projections in IBM Cloud SQL Query

This is the first in a series of articles explaining the key highlights of the geospatial functions of IBM Cloud SQL Query. We will cover the Full Earth feature of the geospatial functions in this article—i.e., every topological and metric function operating on the Full Earth or the ellipsoidal Earth model.

Continue reading