Hello DevOps Guys!!
This post is about Kubernetes Volume type hostPath type. In this post, I've tried multiple options with Volume with hostPath type association with Pods.
Volume type - hostPath
- it posts the persistent data to a specific file or directory on the Host machine's file-system
- Pods running on same node and using the same path in their volume
- this hostPath volume is not deleted when Pod crashed or brought down intentionally
- Specialty of the hostPath Volume is retained, if a new Pod is started as replacement, the files in the hostPath volume will be reused and re-attached to new Pod.
If we compare with emptyDir if the pod dies the Volume will be reclaimed by the Kubernetes Control Plane. whereas in hostPath it remains on the host path.
Pre-requisites
- Docker Engine installed
- Kubernetes Cluster Up and Running (You can do a test on MiniKube as well)
- Enough disk space to define in the PV manifestation
In this post we will do two experiments
- Bare pod using hostPath Volume
- Pod Deployment using hostPath Volume (PV, PVC)
# Manifestation of HostPath Volume type # File: barepod-vol.yaml apiVersion: v1 kind: Pod metadata: name: nginx-hostpathTo create the manifestation for Bare Pod
spec: containers: - name: nginx-container image: nginx volumeMounts: - mountPath: /test-data name: test-vol volumes: - name: test-vol hostPath: path: /vagrant/data
kubectl create -f barepod-vol.yamlimage here
No comments:
Post a Comment