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.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- View the Persistent Volume
- Use one command that will list the persistent volumes within the cluster.
- 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
- 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
- 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.