Creating Deployment for Attaching Claimed Volumes to Pods
In this lesson, we will create a Jenkins deployment for attaching claimed volumes to pods and look into the sequence of associated events.
We'll cover the following
In the previous lesson, we looked into claiming the persistent volumes. The next step is to attach these claimed volumes to pods.
Looking into the Definition#
Let’s look into a Jenkins definition.
The relevant parts of the output as as follows.
You’ll notice that, this time, we added a new volume jenkins-home
, which references the PersistentVolumeClaim called jenkins
. From the container’s perspective, the claim is a volume.
Deploying Resources#
Let’s deploy Jenkins resources and confirm that everything works as expected.
The output is as follows.
Verification#
We’ll wait until the Deployment rolls out before proceeding with a test that will confirm whether Jenkins state is now persisted.
Once the rollout is finished, we’ll see a message stating that the deployment "jenkins"
was successfully rolled out
.
We sent a request to the Kubernetes API to create a Deployment. As a result, we got a ReplicaSet that, in turn, created the jenkins
Pod. It mounted the PersistentVolumeClaim, which is bound to the PersistenceVolume, that is tied to the EBS volume. As a result, the EBS volume was mounted to the jenkins
container running in a Pod.
The Sequential Break-down#
A simplified version of the sequence of events is depicted in the below illustration.
-
We executed
kubectl
command. -
kubectl
sent a request tokube-apiserver
to create the resources defined inpv/jenkins-pv.yml
. -
Among others, the
jenkins
Pod was created in one of the worker nodes. -
Since
jenkins
container in the Pod has a PersistentVolumeClaim, it mounted it as a logical volume. -
The PersistentVolumeClaim was already bound to one of the PersistentVolumes.
-
The PersistentVolume is associated with one of the EBS volumes.
-
The EBS volume was mounted as a physical volume to the
jenkins
Pod.
In the next lesson, we will verify the persistence of state and explore different types of failures that can occur.