Non-Persisting State
Learn how to deploy Jenkins and analyze its state
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.
We created the objects and waited until the processes finished. Now we can open Jenkins in our browser of choice.
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.
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.
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.
The output is as follows.
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.
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.
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