Docker volume mount to kubernetes volume

  docker, google-kubernetes-engine, kubernetes

I am trying out to have a volume mount on Kubernetes.

Currently I have a Docker image which I run like:

docker run --mount type=bind,source="$(pwd)"<host_dir>,target=<docker_dir> container

To have this run on Google Kubernetes cluster, I have:

  1. Create a Google Compute Disk
  2. Created a persistent volume which refers to the disk:

kind: PersistentVolume
...
    namespace: default
    name: pvc
spec:
  claimRef:
    namespace: default
    name: pvc
  gcePersistentDisk:
    pdName: disk-name
    fsType: ext4
---
...
kind: PersistentVolumeClaim
metadata:
  name: pvc
spec:
  storageClassName: "storage"
...
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2000Gi
  1. Created pod with mount
kind: Pod
apiVersion: v1
metadata:
  name: k8s-pod
spec:
  volumes:
    - name: pvc
      persistentVolumeClaim:
       claimName: pvc
  containers:
    - name: image_name
      image: eu.gcr.io/container:latest
      volumeMounts:
        - mountPath: <docker_dir>
          name: dir

I am missing out where the binding between the host and container/pod directories will take place. Also where do I mention that binding in my yaml files.

I will appreciate any help 🙂

Source: Docker Questions

LEAVE A COMMENT