Verifying State Persistence and Exploring Failures
Verify the state persistence of our Jenkins deployment and explore different failures that can occur.
Verifying the state persistence
Now that Jenkins is up and running, we’ll execute a similar set of steps as before and validate that the state has persisted across failures.
open "http://$CLUSTER_DNS/jenkins"
We have opened the Jenkins home screen.
Creating a new job
If you are not authenticated, please click the “Log in” link and type “jdoe” as the User and “incognito” as the Password. Click the “log in” button.
You’ll see the “Create new jobs” link. Click it. Type “my-job” as the item name, select “Pipeline” as the job type, and click the “OK” button. Once inside the job configuration screen, all we have to do is click the “Save” button. An empty job will be enough to test persistence.
Getting the Pod
Now we need to find out the name of the Pod created through the jenkins
Deployment.
POD_NAME=$(kubectl \--namespace jenkins \get pod \--selector=app=jenkins \-o jsonpath="{.items[*].metadata.name}")
Terminating a process
With the name of the Pod stored in the environment variable POD_NAME
, we can proceed and terminate the java
process that’s running Jenkins.
kubectl --namespace jenkins \exec -it $POD_NAME pkill java
We teminated the Jenkins process and therefore simulated failure of the container. As a result, Kubernetes detected the failure and recreated the container.
Verification
A minute later, we can open the Jenkins home screen again and check whether the state (the job we created) is preserved.
open "http://$CLUSTER_DNS/jenkins"
As you can see, the job is still available, therefore proving that ...