Here is an example YAML file for creating a Kubernetes pod with a hostPath volume:
apiVersion: v1
kind: Pod
metadata:
name: my-pod
spec:
containers:
- name: my-container
image: nginx
volumeMounts:
- name: hostpath-volume
mountPath: /mnt/data
volumes:
- name: hostpath-volume
hostPath:
path: /data
type: DirectoryOrCreate
This YAML file creates a pod named “my-pod” with one container that uses the nginx image. The pod has a volume mounted at “/mnt/data” using a hostPath of “/data”. The “type” field specifies that if “/data” does not exist on the host, it should be created as a directory.