Search⌘ K

Persisting State through the emptyDir Volume Type

Explore how the Kubernetes emptyDir volume type allows state persistence within a Pod despite container failures. Understand its behavior, usage for testing, and limitations in achieving fault tolerance, providing foundational knowledge for managing volumes in Kubernetes deployments.

Updating the Jenkins deployment definition

Let’s look at a slightly updated YAML definition of jenkins-empty-dir.yml.

YAML
...
kind: Deployment
...
spec:
...
template:
...
spec:
containers:
...
volumeMounts:
- mountPath: /var/jenkins_home
name: jenkins-home
volumes:
- emptyDir: {}
name: jenkins-home
...

We add a mount that references the jenkins-home volume. This time, the volume type emptyDir. We’ll discuss the new volume type soon. But before we dive into explanations, we’ll try to experience its effects.

Shell
kubectl apply \
-f jenkins-empty-dir.yml
kubectl rollout status deploy jenkins

We have applied the new definition and waited until the rollout finished.

Now we can open the “New Job” Jenkins screen and repeat the same process we followed before.

Shell
kubectl port-forward service/jenkins 3000:8080 --address 0.0.0.0
#Open the link beside run button

Please type test in the “item name” field, select “Pipeline” as the type, click the “OK” button, and finish by clicking the “Save” button.

Now we’ll terminate the container and see what ...