- Lab
- A Cloud Guru
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.
Path 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.
What's a lab?
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.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.