What is the VM folder when using Linux as OS and kvm as driver in kubernetes? What is the VM folder when using Linux as OS and kvm as driver in kubernetes? kubernetes kubernetes

What is the VM folder when using Linux as OS and kvm as driver in kubernetes?


Based on this doc, Host folder sharing is not implemented in the KVM driver yet. This is the driver I am using actually.

To overcome this, there are 2 solutions:

  • Use the virtualbox driver so that you can mount your hostPath volume by changing the path on you localhost /home/THE_USR/... to /hosthome/THE_USR/...

  • Mount your volume to the minikube VM based on the command $ minikube mount /home/THE_USR/.... The command will return you the path of your mounted volume on the minikube VM. Example is given down.

Example

(a) mounting a volume on the minikube VM

the minikube mount command returned that path /mount-9p

$ minikube mount -v 3 /home/amine/DockerProjects/gcloud-kubernetes/application/06-hostPath-volume-example-minikubeMounting /home/amine/DockerProjects/gcloud-kubernetes/application/06-hostPath-volume-example-minikube into /mount-9p on the minikubeVMThis daemon process needs to stay alive for the mount to still be accessible...2017/03/31 06:42:27 connected2017/03/31 06:42:27 >>> 192.168.42.241:34012 Tversion tag 65535 msize 8192 version '9P2000.L'2017/03/31 06:42:27 <<< 192.168.42.241:34012 Rversion tag 65535 msize 8192 version '9P2000'

(b) Specification of the path on the deployment

apiVersion: extensions/v1beta1kind: Deploymentmetadata:  name: php-hostpathspec:  replicas: 1  template:    metadata:      labels:        app: php-hostpath    spec:      containers:      - name: php-hostpath        image: php:7.0-apache        ports:        - containerPort: 80        volumeMounts:          - name: vol-php-hostpath            mountPath: /var/www/html      volumes:      - name: vol-php-hostpath        hostPath:          path: /mount-9p

(c) Checking if mounting the volume worked well

amine@amine-Inspiron-N5110:~/DockerProjects/gcloud-kubernetes/application/06-hostPath-volume-example-minikube$ kubectl exec -ti php-hostpath-3498998593-6mxsn bashroot@php-hostpath-3498998593-6mxsn:/var/www/html# cat index.php <?phpecho "This is my first docker project";root@php-hostpath-3498998593-6mxsn:/var/www/html# cat index.php                                                                                                                                 <?phpecho 'This is my first hostPath on kubernetes';root@php-hostpath-3498998593-6mxsn:/var/www/html# cat index.php <?phpecho 'This is my first hostPath on kubernetes';root@php-hostpath-3498998593-6mxsn:/var/www/html# 

NB: this kind of volume mounting is only development environment. If I were in production environment, the code will not be mounted: it will be in the image.

Hope it helps others.