# MountVolume.SetUp failed for volume "my-volume" : hostPath type check failed: /data/logs is not a directory

- **ID:** `kubernetes/volume-mount-failed-hostpath-type-mismatch`
- **Domain:** kubernetes
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

The hostPath volume's type is set to 'Directory' but the specified path on the node is a file or does not exist.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Kubernetes v1.27.0 | active | — | — |
| Kubernetes v1.28.0 | active | — | — |
| Kubernetes v1.30.0 | active | — | — |

## Workarounds

1. **SSH into the node and create the directory: `ssh node-user@node-ip 'sudo mkdir -p /data/logs'`.** (95% success)
   ```
   SSH into the node and create the directory: `ssh node-user@node-ip 'sudo mkdir -p /data/logs'`.
   ```
2. **If the path is a file, change the pod spec to use `type: FileOrCreate` or remove the type field entirely.** (80% success)
   ```
   If the path is a file, change the pod spec to use `type: FileOrCreate` or remove the type field entirely.
   ```
3. **Check the path on the node with `ls -la /data/logs` to verify its type, then adjust the pod YAML accordingly.** (90% success)
   ```
   Check the path on the node with `ls -la /data/logs` to verify its type, then adjust the pod YAML accordingly.
   ```

## Dead Ends

- **Changing the pod's restart policy to Always** — The pod will keep restarting but still fail because the underlying path issue persists. (100% fail)
- **Adding a PVC instead of hostPath without understanding the requirement** — PVCs require storage classes and may not match the need for node-local storage. (60% fail)
