<syntaxhighlight lang="yaml">
# Test pod to mount a PV bound to a PVC into a container# Before starting this pod, apply the PVC with kubectl apply -f pvc.yamlapiVersion: v1kind: Podmetadata: name: your-username-pvc-access-podspec: containers: - name: pvc-access-container # we use a small ubuntu base to access the PVC image: ubuntu:18.04 # make sure that we have some time until the container quits by itself command: ['sleep', '6h'] # list of mount paths within the container which will be # bound to persistent volumes. volumeMounts: - mountPath: "/mnt/pvc-mnist" # name of the volume for this path (from the below list) name: pvc-mnist volumes: # User-defined name of the persistent volume within this configuration. # This can be different from the name of the PVC. - name: pvc-mnist persistentVolumeClaim: # name of the PVC this volume binds to claimName: your-username-tf-mnist-pvc
</syntaxhighlight>
After the PVC is applied, spin up the test pod with
<syntaxhighlight lang="yaml">
> kubectl apply -f pvc-access-pod.yaml
</syntaxhighlight>
You now have several options to get data to and from the container.
=== 1. Copying data from within the container ===
You can get a root shell inside the container as usual (insert the correct pod name you used below):
<syntaxhighlight lang="yaml">
> kubectl exec -it pvc-access-pod /bin/bash
</syntaxhighlight>
Your pod has internet access. Thus, an option to get data to/from the pod, in particular into the persistent volume, is to use scp, which first needs to be installed inside the pod:
<syntaxhighlight lang="yaml">
# sudo apt-get update && sudo apt install openssh-client
# cd /my-pvc-mount-path
# scp your.username@external-server:/path/to/data/. ./
</syntaxhighlight>
By reversing source and destination, you can also copy data out of the container this way.
=== 2. Copying data from the outside ===
From the outside world, you can directly copy data to and from the container using kubectl cp, which has a very similar syntax to scp:
<syntaxhighlight lang="yaml">
# to get data into the container, substitute name with correct id obtained from kubectl get pods
> kubectl cp /path/to/data/. pvc-access-pod:/my-pvc-mount/path/
# to get data from the container
> kubectl cp pvc-access-pod:/my-pvc-mount/path/. /path/to/output/
</syntaxhighlight>
TODO: Will finish this part soon, for now, read up on Kubernetes "kubectl cp" documentation to copy stuff to/from a PV.