Hands-on Lab·Certified Kubernetes Administrator
Volume subPath and Mounted File Permissions
The two things that go wrong when configuration reaches a container as a file: a mount that hides the directory it landed on, and a permissions field that is decimal when everyone reads it as octal.
Storage Guide 66 of 103 Intermediate
- Kubernetes1.36.4
- Cluster4 nodes
- Runtimecontainerd 2.2.6
- CNICalico v3.32.1
- TimeAbout 16 min
The ..data timestamp directory name is generated per mount. Everything else here is the same on any cluster.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| CKA1001 | 192.168.0.175 | Ubuntu 26.04 LTS | Control Plane Node | 2 Core | 4 GB | 50 GB |
| CKA1001-NODE01 | 192.168.0.176 | Ubuntu 26.04 LTS | Worker Node | 2 Core | 4 GB | 50 GB |
| CKA1001-NODE02 | 192.168.0.177 | Ubuntu 26.04 LTS | Worker Node | 2 Core | 4 GB | 50 GB |
| CKA1001-NODE03 | 192.168.0.178 | Ubuntu 26.04 LTS | Worker Node | 2 Core | 4 GB | 50 GB |
This guide includes
Use this when a ConfigMap mount hides files the image shipped, or when a mounted Secret turns out to be readable by more than it should be. This matters because a volume mount replaces a directory rather than merging into it, and subPath fixes that at a cost people only discover later.
- establishing what the image ships in a directory before mounting anything over it
- mounting a ConfigMap over that directory and watching the original files disappear
- mounting a single key with
subPathso the rest of the directory survives - editing the ConfigMap and finding that a subPath mount never updates - the cost of using it
- setting
defaultModeon a Secret, a decimal number that nearly everyone reads as octal
Before you start
- guide 34 - the four ways configuration reaches a Pod, before this covers what the file mount does to the filesystem.
-
What the image ships in that directory
-
Mounting a ConfigMap over it
-
The same ConfigMap, mounted with subPath
-
The cost of subPath, which is the part that bites
-
File permissions on a mounted Secret