The error message indicates a failure during container creation because of an issue mounting a secret file inside the container:
error mounting "/var/lib/kubelet/pods/.../volume-subpaths/daca-secretfile-pem/hsm-service/3" to rootfs at "/app/hsm/safenet/lunaclient/cert/client/DACA_CLIENT_CERT.pem":
mount ... flags: 0x5001, data: context="system_u:object_r:container_file_t:s0:c36,c0": not a directory
What this means:
The mount path basically says: Kubernetes is trying to mount a volume subpath (which should be a file) onto a path inside the container /app/hsm/safenet/lunaclient/cert/client/DACA_CLIENT_CERT.pem. However, it encounters a "not a directory" error during mount, often indicating a type mismatch or that the target path inside the container is expected to be a regular file, but something else exists there (e.g., directory or does not match).
Common causes:
-
The target path /app/hsm/safenet/lunaclient/cert/client/DACA_CLIENT_CERT.pem already exists in the container as a directory
If the container's image has this path as a directory, the mount fails because the volume mount expects to mount a file on a file.
-
The source path in volume-subpaths is not a file (e.g., it's missing or is a directory)
The source path for the volume mount needs to be a file since it's a secret subpath mount.
-
SELinux context or permissions issues
There is an SELinux context in the error—system_u:object_r:container_file_t:s0:c36,c0—which could interfere if the container runtime or kubelet doesn't have permission to access or mount it correctly.
-
Incorrect use of subPath in the volume mount config.
If the Kubernetes manifest uses a subPath on a secret volume, it needs to be correct and must match exactly the file path inside the secret.
How to troubleshoot and fix:
-
Check if the container image already has /app/hsm/safenet/lunaclient/cert/client/DACA_CLIENT_CERT.pem present and is a directory:
- If you have access to the container image (or Dockerfile), inspect whether this exact path is a file or directory.
- If it's a directory, that's a conflict; you need to either rename the mount path or remove the directory inside the image.
-
Verify your Pod manifest volume and volumeMounts:
For example, if your pod YAML includes something like:
volumes:
- name: daca-secretfile-pem
secret:
secretName: your-secret
containers:
- name: your-container
volumeMounts:
- name: daca-secretfile-pem
mountPath: /app/hsm/safenet/lunaclient/cert/client/DACA_CLIENT_CERT.pem
subPath: hsm-service
Make sure:
subPath refers exactly to the file name inside the secret, not to a directory.
- If you want to mount a specific file inside a secret as a file in the container, the secret key and subPath must be the file name.
-
Check secret keys and exported files:
Ensure that the secret mounted contains a key called e.g., hsm-service and that this key's content is a file (not a directory).
-
Try mounting entire secret as a directory rather than single file if possible:
Sometimes mounting the secret as a directory (default approach) is simpler:
volumeMounts:
- name: daca-secretfile-pem
mountPath: /app/hsm/safenet/lunaclient/cert/client/
readOnly: true
This mounts the whole secret as files inside the directory.
-
Review SELinux or AppArmor policies
If your system enforces SELinux or AppArmor, verify the kubelet and container runtime have the correct permissions for this secret file. You might try disabling SELinux temporarily to test (not recommended for production).
-
Clean up stale directories in host paths
Sometimes leftover content in the volume-subpaths directory on the host can cause this kind of problem. You can try restarting kubelet or cleaning /var/lib/kubelet/pods/... for that pod.
Summary of action items:
- Inspect container image to ensure mount target is a file, not a dir.
- Confirm secret data keys and subPath usage in pod spec are correct for file mount.
- Mount the secret as a directory instead of mounting single file by subPath, if possible.
- Validate SELinux/AppArmor permissions or policies if enforced.
- Clean out stale kubelet volume-subpath data or restart kubelet as a last resort.
If you want, you can share your pod spec volume and volumeMounts to get more targeted advice!