<p>According to <a href="https://kubernetes.io/docs/concepts/storage/volumes/?spm=a2c63.p38356.0.0.28874dcbfWkCRx#hostpath" rel="nofollow noreferrer">Kubernetes documentation</a>, we should specify <code>type: DirectoryOrCreate</code> if we want to create directory on the host. The default option is <strong>&quot;no checks will be performed before mounting the hostPath volume&quot;</strong>.</p>
<p>However, I am seeing directory gets created on host even when no type is specified:</p>
<pre><code>---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: busybox-user-hostpath
spec:
  replicas: 1
  selector:
    matchLabels:
      app: busybox-user-local-storage1
  template:
    metadata:
      labels:
        app: busybox-user-local-storage1
    spec:
      containers:
        - name: busybox
          image: busybox:latest
          command: [&quot;/bin/sh&quot;, &quot;-ec&quot;, &quot;while :; do echo $(date '+%Y-%m-%d %H:%M:%S') deployment1 &gt;&gt; /home/test.txt; sleep 5 ; done&quot;]
          volumeMounts:
          - name: busybox-hostpath
            mountPath: /home
      volumes:
        - name: busybox-hostpath
          hostPath:
                path: /home/maintainer/data
</code></pre>
<p><code>/home/maintainer/data</code> directory did not exist before running the pod. After deployment, I can see the directory is created. This goes against the documentation unless I am missing something. I was expecting the pod should crash but I can see the files are created. Any idea please?</p>

Muzammil
<p>This is something that goes back in time, before type was even implemented for hostPath volume. When unset should just go and default directly to create an empty directory, and it's a backward compatible implementation, because no one had the option to add <strong>type</strong> and forcing an error when it's not defined would have broken all previously created pods without it. You can take a look into the actual design-proposal: <a href="https://github.com/kubernetes/design-proposals-archive/blob/main/storage/volume-hostpath-qualifiers.md#host-volume" rel="nofollow noreferrer">https://github.com/kubernetes/design-proposals-archive/blob/main/storage/volume-hostpath-qualifiers.md#host-volume</a></p>
<p>The design proposal clearly specifies that &quot;<em><strong>unset</strong> - If nothing exists at the given path, an empty directory will be created there. Otherwise, behaves like exists</em>&quot;</p>
