Search code examples
kubernetesminikubekubernetes-pvc

access minikube folder's data from host machine


I'm using minikube for running my Kubernetes deployment:

pvc:

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pipeline
spec:
  storageClassName:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi

pod:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: test1
  name: test1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: test1
  template:
    metadata:
      labels:
        app: test1
    spec:
      containers:
      - env:
        - name: SHARED_FOLDER_PATH
          value: /data/shared
        image: docker.io/foo/test1:st3
        imagePullPolicy: Always
        name: test1
        ports:
        - containerPort: 8061
          name: protobuf-api
        - containerPort: 8062
          name: webui
        volumeMounts:
        - mountPath: /data/shared
          name: test1
      imagePullSecrets:
      - name: acumos-registry
      volumes:
      - name: test1
        persistentVolumeClaim:
          claimName: pipeline

I have checked that pod and pvc are running:

$ kubectl describe pv,pvc

Name:            pvc-34bbd532-9c55-45cc-ab96-1accd08ded6e
Labels:          <none>
Annotations:     hostPathProvisionerIdentity: c6eeb812-6b82-4546-bc5a-8917cf0d3d6b
                 pv.kubernetes.io/provisioned-by: k8s.io/minikube-hostpath
Finalizers:      [kubernetes.io/pv-protection]
StorageClass:    standard
Status:          Bound
Claim:           test/pipeline
Reclaim Policy:  Delete
Access Modes:    RWO
VolumeMode:      Filesystem
Capacity:        1Gi
Node Affinity:   <none>
Message:         
Source:
    Type:          HostPath (bare host directory volume)
    Path:          /tmp/hostpath-provisioner/test/pipeline
    HostPathType:  
Events:            <none>

What I'm trying is to access the data on the minikube folder: /tmp/hostpath-provisioner/test/pipeline from host machine. For that purpose, I'm mounting local volumen:

$ minikube mount /tmp/hostpath-provisioner/test/pipeline:/tmp/hostpath-provisioner/test/pipeline

I have checked if any data is on minikube folder by ssh:

docker@minikube:/tmp/hostpath-provisioner/test/pipeline$ ls -a

.  ..  classes.json

But I can't see this info from local folder


Solution

  • The problem was the Firewall. The procedure detailed within the question post together with the solution proposed in this answer (on Ubuntu) worked for me:

    How to mount a Host folder in minikube VM