Difficulty: Beginner
Estimated Time: 35 minutes

This scenario walks through many of the ways your application can read and write to various filesystems and volumes on Kubernetes. Some developers have the notion that apps running in a container can only have ephemeral data because once the container goes away, so does all of its data. That is true if the files you write to are not mounted to external volumes. Sometimes that ephemeral file storage is a welcomed feature, sometimes it's vital the files stores are persisted, backed-up and encrypted at rest. No matter what your file storage requirements are we will explore the spectrum of the techniques to connect your application to various volume types.

This scenario starts with your application reading and writing to its local file system in the container. Then we look at storage in the Pod, then at the Node, then to other Pods and finally to external file stores. We start at the inner layer of your application onion and work our way out.

In the following steps you will learn:

  • about the file system inside a container.
  • about mounting a volume to a ConfigMap.
  • about mounting to the Pod file system.
  • about mounting to emptyDir with initContainers.
  • about mounting to a Node filesystem.
  • about mounting to a Persistent Volume.
  • about mounting to a file system outside the cluster.

Volumes, filesystems, and mounts are a complex topic. The length of this scenario reflects this rich topic. You will need some dedicated time to complete all the steps. Each step is a different topic and independent of the other topics. If you wish to skip a topic or have to come back to this scenario later, each step can be explored separately to fit your busy schedule.

This shows you that Kubernetes is a thing of persistent integrity thanks to the levels of indirection with Linux file mounts, PVs, and PVCs. 😉

The steps were organized to go from easy and basic to more complicated. We hope you made it through each step. If not, go back to the squirrely bits and review them again.

Lessons Learned

With these steps you have learned:

  • ✔ about the file system inside a container.
  • ✔ about mounting a volume to a ConfigMap.
  • ✔ about mounting to the Pod file system.
  • ✔ about mounting to emptyDir with initContainers.
  • ✔ about mounting to a Node filesystem.
  • ✔ about mounting to a Persistent Volume.
  • ✔ about mounting to a file system outside the cluster.

References


For a deeper understanding of these topics and more join
Jonathan Johnson
at various conferences, symposiums, workshops, and meetups.

Software Architectures ★ Speaker ★ Workshop Hosting ★ Kubernetes & Java Specialist

Volumes and Mounts

Step 1 of 8

Your Kubernetes Cluster

For this scenario, Katacoda has just started a fresh Kubernetes cluster for you. Verify it's ready for your use.

kubectl version --short && \ kubectl get componentstatus && \ kubectl get nodes && \ kubectl cluster-info

The Helm package manager used for installing applications on Kubernetes is also available.

helm version --short

Kubernetes Dashboard

You can administer your cluster with the kubectl CLI tool or use the visual Kubernetes Dashboard. Use this script to access the protected Dashboard.

token.sh

Terminal
Kubernetes Dashboard
Demo-web