Search⌘ K

Creating Deployment for Attaching Claimed Volumes to Pods

Understand how to create Kubernetes deployments that attach persistent volume claims to pods. This lesson guides you through the process of mounting EBS-backed persistent volumes in a Jenkins deployment, ensuring state persistence within your pods for reliable application data management.

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:

Shell
cat pv/jenkins-pv.yml

The relevant parts of the output as as follows:

Shell
...
apiVersion: apps/v1
kind: Deployment
metadata:
name: jenkins
namespace: jenkins
spec:
...
template:
...
spec:
containers:
- name: jenkins
...
volumeMounts:
- name: jenkins-home
mountPath: /var/jenkins_home
...
volumes:
- name: jenkins-home
persistentVolumeClaim:
claimName: jenkins
...

You’ll notice that this time, we add a new volume jenkins-home, which references the PersistentVolumeClaim called jenkins. From the container’s perspective, the claim is ...