1

I want to copy a text file to a pod on minikube. But I get the timeout errorenter image description here.

scp -r /Users/joe/Downloads/Archive/data.txt  docker@192.168.49.2:/home/docker

I got the ip address (192.168.49.2) with:

minikube ip

Eventually I would like that the file appear on the persistentVolumeClaim/persistentVolume (that will be great!!)

The yaml for the PersistentVolume is:

kind: PersistentVolume
apiVersion: v1
metadata:
  name: my-pv
spec:
  storageClassName: local-storage
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/mnt/data"

The yaml for the PersistentVolumeClaim is:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: my-pvc
spec:
  storageClassName: local-storage
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 512Mi

The yaml for the pod is:

kind: Pod
apiVersion: v1
metadata:
  name: my-pvc-pod
spec:
  containers:
  - name: busybox
    image: busybox
    command: ["/bin/sh", "-c", "while true; do sleep 3600; done"]
    volumeMounts:
    - mountPath: "/mnt/storage"
      name: my-storage
  volumes:
  - name: my-storage
    persistentVolumeClaim:
      claimName: my-pvc
QBits
  • 121
  • 1
  • 11

1 Answers1

0

Eventually I would like that the file appear on the persistentVolumeClaim/persistentVolume.

You can achieve that with mounting the host directory into the guest using minikube mount command:

minikube mount <source directory>:<target directory>

Whereas the the <source directory> is the host directory and <target directory> is the guest/minikube directory.

And then use that <target directory> and create pv with hostPath:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: task-pv-volume
spec:
  storageClassName: manual
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "<target-directory"

Depending also driver, some of them have built-in host folder sharing. You can check them here.

If you need to mount only part of the volume, in your case a single file, you can use subPath to specify the part that must be mounted. This answer explains it well.

acid_fuji
  • 6,287
  • 7
  • 22