Non-Persisting State

Deploying Jenkins#

This time we’ll deploy Jenkins and see what challenges we will face.

Looking into the definition#

Let’s take a look at the jenkins.yml definition.

Definition of 'jenkins.yml'

There’s nothing special in that YAML file. It defines an Ingress with /jenkins path, a Deployment, and a Service. We won’t waste time with it. Instead, we’ll move on and create the objects.

Creating the objects#

Its time to create the deployments.

Create Jenkins

We created the objects and waited until the processes finished. Now we can open Jenkins in our browser of choice.

Call Jenkins

Jenkins UI opened, thus confirming that the application is deployed correctly. Jenkins’ primary function is to execute jobs, so it’s only fair to create one.

Call /newJob

Please type test in the item name field, select Pipeline as the type, and click the OK button.

There’s no need to make the Pipeline do any specific set of tasks. For now, you should be fine if you just Save the job.

Killing the Pod and Analysing the State#

Let’s explore what happens if the main process inside the Jenkins container dies.

Killing main process inside Jenkins

We retrieved the name of the Pod, and we used it to execute kill 1 inside its only container. The result is a simulation of a failure. Soon afterward, Kubernetes detected the failure and recreated the container. Let’s double-check all that.

Get all pods

The output is as follows.

All Running pods

We can see that a container is running. Since we killed the main process and, with it, the first container, the number of restarts was increased to one.

Let’s go back to Jenkins UI and check what happened to the job. I’m sure you already know the answer, but we’ll double-check it anyways.

Call Jenkins again

As expected, the job we created is gone. When Kubernetes recreated the failed container, it created a new one from the same image. Everything we generated inside the running container is no more. We reset to the initial state.

Try it yourself#

For your ease, all the commands used in this lesson are given below.

Commands used in this lesson

You can practice the commands in the following code playground by pressing the Run button and waiting for the cluster to set up.

/
jenkins.yml
Exploring non persistent state

Working with the New Prometheus Configuration
Persisting State through the emptyDir Volume Type
Mark as Completed
Report an Issue