minikube hostpath mount permissions

1/29/2019

I'm trying to mount a local directory to be used by a container in kubernetes, but getting this error:

$ kubectl logs mysql-pd

chown: changing ownership of '/var/lib/mysql/': Input/output error

minikube version: v0.33.1

docker for mac version: 2.0.0.2 (30215)

Engine: 18.09.1

Kubernetes: v1.10.11

I'm starting up minikube with mounted directory:

minikube start --mount-string /Users/foo/mysql_data:/mysql_data --mount

deployment.yml

apiVersion: v1
kind: Pod
metadata:
  name: mysql-pd
spec:
  containers:
  - image: mysql:5.7
    name: mysql-container
    env:
    - name: MYSQL_ROOT_PASSWORD
      value: ""
    - name: MYSQL_ALLOW_EMPTY_PASSWORD
      value: "yes"
    ports:
      - containerPort: 3306
    volumeMounts:
    - mountPath: "/var/lib/mysql"
      name: host-mount
  volumes:
  - name: host-mount
    hostPath:
      path: "/mysql_data"
-- slashdottir
kubernetes
macos
minikube
permissions
persistent-storage

1 Answer

1/29/2019

As @Matthew L Daniel mentioned in the comments, the main purpose of using hostPath is to mount a local folder from your machine which is hosting minikube inside to the nested Pod, therefore it's not necessary to mount local directory inside to minikube. Also, take a look at this article which explains some restrictions about host folder mounting for the particular VM driver in minikube.

-- mk_sta
Source: StackOverflow