CI/CD / Kubernetes

How to Install Jenkins X on an Existing Kubernetes Cluster

23 Nov 2019 9:51am, by

First released in 2018, Jenkins X was created by James Strachan, creator of the Apache Groovy language. Currently managed by CloudBees, the purpose of this tool is to be a cloud-native, Kubernetes application to support CI/CD and simplify Kubernetes deployments. With just a single Jenkins X command, an admin can create a Kubernetes cluster, install the tools necessary to manage an application, create pipelines, and deploy an application to various environments.

Jenkins X is also an extensible automation server, configured by plugins, that function as a Continuous Integration (CI) server, a Continuous Deployment (CD) hub, and automated testing.

Jenkins X (also called JX) is easily installed on an existing cloud provider (such as Amazon Elastic Container Service for Kubernetes, Google Kubernetes Engine, or Microsoft Azure Kubernetes Service). Or, if you have an on-premises Kubernetes cluster, you can also make use of Jenkins X. With the jx command, you can quickly deploy clusters locally or to remote cloud providers (such as Google Cloud Platform).

I’m going to walk you through the process of installing Jenkins X on an existing Kubernetes cluster, running on Ubuntu Server 18.04.

What You’ll Need

I’m going to demonstrate deploying a Kubernetes cluster (using Jenkins X) both locally and to Google Cloud Platform. For this you’ll need:

  • A running instance of Ubuntu Server with Kubernetes installed.
  • A Google Cloud Platform account.
  • A user with sudo privileges.
  • A network connection.

Outside of that, just a little time.

Let’s make things happen.

Installing Jenkins X

Installing Jenkins X on Ubuntu is actually quite simple. The executable binary can be downloaded from the official Jenkins X GitHub page and then moved into the proper directory. To do this, either log into your server, via SSH, or into the console directly. Once you have a bash prompt for your server, issue the command:

The above command will download the latest release of Jenkins X and then unpack the binary. Once the command completes, you should see an executable in the current working directory, named jx (Figure 1).

Figure 1: The jx binary, ready to be relocated.

To move the Jenkins X binary, issue the command:

If you opt to deploy a cluster using a virtual machine environment, you’ll have to have that installed as well. For this, you can always install KVM, KVM-2, or VirtualBox. To make this easy, we’ll install VirtualBox. This does install an X server, but you don’t have to use it.

In order to install VirtualBox, issue the command:

This installation will take some time. Let it finish. Next, you’ll want to install minikube on your Ubuntu Server (as that will be our provider). To do this, download the necessary file with the command:

Change the permission of the downloaded file with the command:

Move (and rename) the file into the proper directory with the command:

You should see that minikube is now installed with the command:

The output will show the release number of minikube (Figure 2).

Figure 2: Minikube is installed and ready to go.

Deploying a Cluster with the jx Command

We’re now going to deploy a cluster. The cluster will use the minikube provider and VirtualBox as the driver. The command to deploy the cluster is:

You will be asked the following questions:

  • Amount of memory to apply to the cluster (default is 4096).
  • Number of cores to apply to the cluster (default is 3).
  • Disk size (default is 150GB).
  • Select driver (select from kvm, kvm2, virtualbox, none).

If you select the following options:

  • Memory 4096
  • Cores 3
  • Disk size 20GB
  • Driver virtualbox

The effective command would be:

You can also deploy a cluster on a local environment without using a driver (selecting the none option). To do this, you must run the jx command with sudo like so:

Effectively, the command that will be run is:

The jx command will take care of pulling all of the necessary images and deploy the configured cluster.

Deploy to Google Cloud

Let’s say you want to deploy your cluster to the Google Cloud Platform. Jenkins X makes this possible as well. Before you do this, you must first have the gcloud application Installed. To do this, go back to your terminal window and download the source file with the command:

Unpack the file with the command:

Change into the newly created directory with the command:

Finally, run the installer with the command:

Once you’ve taken care of that, update all things gcloud with the command:

Finally, you must login to your Google Cloud Platform account with the command:

A link will print out. Open that link in a browser, select the Google account you wish to use, and then copy the verification code you are given. Paste that code into the command prompt and hit Enter. You are now logged into your Google Cloud Platform account and can issue the command:

When prompted, make sure you select the Google Cloud Project you wish to use (Figure 3). 

Figure 3: Selecting a Google Cloud Project.

Once you’ve made your selection and hit Enter, you’ll be prompted to select a zone (Figure 4).

Figure 4: Selecting a zone for your cluster.

Next, you’ll be asked the Jenkins installation type (choose from Serverless Jenkins X Pipelines with Tekton or Static Jenks Server with Jenkinsfiles). Do note, when using tekton, only kaniko is supported as a builder.

You’ll then have to enter a name and email address to use with git and then acquire the necessary API key for your GitHub account. That’s it. The cluster will deploy and is ready to work for you.

And that’s the gist of installing and using Jenkins X on an existing Kubernetes Cluster. There’s so much more that this tool can do, so I highly recommend combing through the official documentation.

CloudBees is a sponsor of The New Stack.

A newsletter digest of the week’s most important stories & analyses.

View / Add Comments

Please stay on topic and be respectful of others. Review our Terms of Use.