- Lab
-
Libraries: If you want this lab, consider one of these libraries.
- Cloud

Creating a ClusterRole to Access a PV in Kubernetes
In this hands-on lab, you will be tasked with accessing a persistent volume from a pod in order to view the available volumes inside the Kubernetes cluster. By default, pods cannot access volumes directly, so you will also need to create a cluster role to provide authorization to the pod. Additionally, you cannot access the API server directly without authentication, so you will need to run kubectl in proxy mode to retrieve information about the volumes.

Lab Info
Table of Contents
-
Challenge
View the Persistent Volume
- Use one command that will list the persistent volumes within the cluster.
-
Challenge
Create a ClusterRole and ClusterRoleBinding
- Use one command that will create a new ClusterRole with the verb
get
andlist
to the resourcepersistentvolumes
. - Use one command that will create a new ClusterRoleBinding to the ClusterRole, in the
web
namespace and using thedefault
service account.
- Use one command that will create a new ClusterRole with the verb
-
Challenge
Create a pod to access the PV
- Create the YAML file including the two containers, using the two images
curlimages/curl
andlinuxacademycontent/kubectl-proxy
. - Issue a command to the curl container to sleep for 1 hour (3600 seconds).
- Apply the YAML to the Kubernetes cluster to run the pod.
- Create the YAML file including the two containers, using the two images
-
Challenge
Request access to the PV from the pod
- Open a shell inside the container.
- From the container shell prompt, issue the
curl
command to request persistent volumes from the API server.
About the author
Real skill practice before real-world application
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.