Skip to content

Instantly share code, notes, and snippets.

@matthewpalmer
Created October 21, 2018 20:37
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save matthewpalmer/bd10ea5360bdf3d735109a68050afeaa to your computer and use it in GitHub Desktop.
Save matthewpalmer/bd10ea5360bdf3d735109a68050afeaa to your computer and use it in GitHub Desktop.
Kubernetes volume example YAML
kind: Pod
apiVersion: v1
metadata:
name: simple-volume-pod
spec:
# Volumes are declared by the pod. They share its lifecycle
# and are communal across containers.
volumes:
# Volumes have a name and configuration based on the type of volume.
# In this example, we use the emptyDir volume type
- name: simple-vol
emptyDir: {} # No extra configuration
# Now, one of our containers can mount this volume and use it like
# any other directory.
containers:
- name: my-container
volumeMounts:
- name: simple-vol # This is the name of the volume we set at the pod level
mountPath: /var/simple # Where to mount this directory in our container
# Now that we have a directory mounted at /var/simple, let's
# write to a file inside it!
image: alpine
command: ["/bin/sh"]
args: ["-c", "while true; do date >> /var/simple/file.txt; sleep 5; done"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment