Volumes are used to retain data that is generated by a pod after the pod has been deleted. Volumes are created on the kubernetes clusters.
apiVersion: v1
kind: Pod
metadata:
name: randon-number-generator
spec:
containers:
- name: alpine
image: alpine
command: ["/bin/sh","-c"]
args: ["shuf -i 0-100 -n 1 >> /opt/number.out;"]
volumeMounts:
- mountPath: /opt
name: data-volume
volumes:
- name: data-volume
hostPath:
path: /data
type: Directory
anything written to the /opt file system in the pod will be written to the /data directory on the cluster node.
This will store data on the node the pod was run on in the directory specified.