Ephemeral Volumes
Course: Kubernetes Part 2 - chapter 20
A lot of times you want two containers in a pod to share data. But when the pods dies, then the data can die with it.

- Create a manifest that starts two pods which share the same volume
apiVersion: apps/v1kind: Deploymentmetadata: name: shared-volume-deploymentspec: replicas: 1 selector: matchLabels: app: shared-volume-app template: metadata: labels: app: shared-volume-app spec: containers: - name: writer image: busybox command: ["/bin/sh", "-c", "echo 'Hello from Writer Pod' > /data/hello.txt; sleep 3600"] volumeMounts: - name: shared-data mountPath: /data - name: reader image: busybox command: ["/bin/sh", "-c", "cat /data/hello.txt; sleep 3600"] volumeMounts: - name: shared-data mountPath: /data volumes: - name: shared-data emptyDir: {}- Apply the manifest
kubectl apply -f kube.yml- Check the reader container and see if you can see the volume data in there
kubectl exec -it shared-volume-deployment-74d67d6567-tcdsl --container reader sh