无法安装MySQL数据卷到Kubernetes Minikube吊舱
我试图通过Minikube与Kubernetesbuild立一个开发环境。 我使用Docker for Mac成功将相同的卷装载到相同的映像上,但我在Minikube上遇到了麻烦。
相关的文件和日志: db-pod.yml
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: name: msyql name: db namespace: default spec: containers: - name: mysqldev image: mysql/mysql-server:5.6.32 ports: - containerPort: 3306 hostPort: 3306 volumeMounts: - mountPath: "/var/lib/mysql" name: volumesnew volumes: - name: volumesnew hostPath: path: "/Users/eric/Volumes/mysql"
kubectl get pods
:
NAME READY STATUS RESTARTS AGE db 0/1 Error 1 3s
kubectl logs db
:
2016-08-29 20:05:55 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2016-08-29 20:05:55 0 [Note] mysqld (mysqld 5.6.32) starting as process 1 ... 2016-08-29 20:05:55 1 [Warning] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
kubectl describe pods db
:
Name: db Namespace: default Node: minikubevm/10.0.2.15 Start Time: Wed, 31 Aug 2016 07:48:39 -0700 Labels: name=msyql Status: Running IP: 172.17.0.3 Controllers: <none> Containers: mysqldev: Container ID: docker://af0937edcd9aa00ebc278bc8be00bc37d60cbaa403c69f71bc1b378182569d3d Image: mysql/mysql-server:5.6.32 Image ID: docker://sha256:0fb418d5a10c9632b7ace0f6e7f00ec2b8eb58a451ee77377954fedf6344abc5 Port: 3306/TCP State: Waiting Reason: CrashLoopBackOff Last State: Terminated Reason: Error Exit Code: 1 Started: Wed, 31 Aug 2016 07:48:42 -0700 Finished: Wed, 31 Aug 2016 07:48:43 -0700 Ready: False Restart Count: 1 Environment Variables: MYSQL_ROOT_PASSWORD: test Conditions: Type Status Initialized True Ready False PodScheduled True Volumes: volumesnew: Type: HostPath (bare host directory volume) Path: /Users/eric/Volumes/newmysql default-token-il74e: Type: Secret (a volume populated by a Secret) SecretName: default-token-il74e QoS Tier: BestEffort Events: FirstSeen LastSeen Count From SubobjectPath Type Reason Message --------- -------- ----- ---- ------------- -------- ------ ------- 7s 7s 1 {default-scheduler } Normal Scheduled Successfully assigned db to minikubevm 6s 6s 1 {kubelet minikubevm} spec.containers{mysqldev} Normal Created Created container with docker id 568f9112dce0 6s 6s 1 {kubelet minikubevm} spec.containers{mysqldev} Normal Started Started container with docker id 568f9112dce0 6s 4s 2 {kubelet minikubevm} spec.containers{mysqldev} Normal Pulled Container image "mysql/mysql-server:5.6.32" already present on machine 4s 4s 1 {kubelet minikubevm} spec.containers{mysqldev} Normal Created Created container with docker id af0937edcd9a 4s 4s 1 {kubelet minikubevm} spec.containers{mysqldev} Normal Started Started container with docker id af0937edcd9a 3s 2s 2 {kubelet minikubevm} spec.containers{mysqldev} Warning BackOff Back-off restarting failed docker container 3s 2s 2 {kubelet minikubevm} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "mysqldev" with CrashLoopBackOff: "Back-off 10s restarting failed container=mysqldev pod=db_default(012d5178-6f8a-11e6-97e8-c2daf2e2520c)"
我能够将数据目录从主机挂载到testing目录中的容器,但是我无法挂载到MySQL数据目录。 另外,我试图用适当的MySQL环境variables设置一个空目录到容器的数据目录,这在Docker for Mac中允许我在新目录中执行一个SQL转储,但是我在Minikube中看到了同样的错误。
任何可能的原因,或者如果我不build立我的开发环境首选Kubernetes / Minikube方式的想法,请分享您的想法。
我能够解决这个问题如下:
echo "/Users -network 192.168.99.0 -mask 255.255.255.0 -alldirs -maproot=root:wheel" | sudo tee -a /etc/exports sudo nfsd restart minikube start minikube ssh -- sudo umount /Users minikube ssh -- sudo /usr/local/etc/init.d/nfs-client start minikube ssh -- sudo mount 192.168.99.1:/Users /Users -o rw,async,noatime,rsize=32768,wsize=32768,proto=tcp
我在VirtualBox中运行Minikube。 我不知道这是否会与其他虚拟机驱动程序 – xhyve等。
参考: https : //github.com/kubernetes/minikube/issues/2
编辑:我应该提到,这适用于minikube v0.14.0。