简体   繁体   English

更改所有权/ data / db,输入/输出错误,Kubernetes Mongo部署

[英]Changing ownership /data/db, input/output error, Kubernetes Mongo Deployment

I am trying to run a deployment for mongo using minikube. 我正在尝试使用minikube为mongo运行部署。 I have created a persistent storage using the following configuration: 我使用以下配置创建了永久存储:

kind: PersistentVolume
apiVersion: v1
metadata:
  name: mongo-volume
spec:
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteOnce
  claimRef:
    namespace: default
    name: mongo-claim
  hostPath:
    path: "/test"

The "/test" folder is being mounted using minikube mount <local_path>:/test 使用minikube mount <local_path>:/test "/test"文件夹

Then I created a PV Claim using the following configuration: 然后,我使用以下配置创建了PV Claim:

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: mongo-claim
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 50Mi

Finally, I am trying to create a Service and Deployment with the following configuration: 最后,我尝试使用以下配置创建服务和部署:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: mongo
spec:
  replicas: 1
  template:
    metadata:
      labels:
        tier: backend
        app: mongo
    spec:
      containers:
      - name: mongo
        image: "mongo"
        envFrom:
          - configMapRef:
              name: mongo-config
        ports:
          - name: mongo-port
            containerPort: 27017 
        volumeMounts:
          - name: mongo-storage
            mountPath: "/data/db"
      volumes:
        - name: mongo-storage
          persistentVolumeClaim:
            claimName: mongo-claim
---
apiVersion: v1
kind: Service
metadata: 
  name: mongo
spec:
  selector:
    app: mongo
  ports:
    - protocol: TCP
      port: 27017
      targetPort: mongo-port

The container quits with an error Changing ownership of '/data/db', Input/Output error. 容器退出,并显示以下错误:更改“ / data / db”的所有权,输入/输出错误。

Question 1) Who is trying to change the ownership of the internal directory of the container? 问题1)谁在尝试更改容器内部目录的所有权? Is it the PV Claim? PV索赔吗? Question 2) Why the above culprit is trying to mess with the permission of the Mongodb container's default storage path? 问题2)为什么上述罪魁祸首试图破坏Mongodb容器默认存储路径的许可?

Looks like it more about virtualbox driver for external folder then k8s itself, 看起来更像是有关外部文件夹的virtualbox驱动程序,然后是k8s本身,

in my scenario 在我的情况下

  • i've created a folder on my OS X, 我在OS X上创建了一个文件夹,
  • mapped that folder to minikube minikube mount data-storage/:/data-storage 将该文件夹映射到minikube minikube mount data-storage/:/data-storage
  • created PersistentVolume pointing to folder inside minikube 创建的PersistentVolume指向minikube中的文件夹
  • created PersistentVolumeClaim pointing to PV above 创建的PersistentVolumeClaim指向上方的PV
  • tried to start single simple mongodb using PVC above 尝试使用上面的PVC启动单个简单的mongodb

and got constantly restarting pods with logs: 并不断使用日志重新启动Pod:

Fatal Assertion and fsync: Invalid Argument was fighting for a few hours, and finally found this Fatal Assertionfsync: Invalid Argument奋战了几个小时,终于找到了

https://github.com/mvertes/docker-alpine-mongo/issues/1 https://github.com/mvertes/docker-alpine-mongo/issues/1

which is basically reporting issues with virtualbox driver in case if folder mapped to host. 如果文件夹映射到主机,这基本上是报告virtualbox驱动程序的问题。

Once i've mapped PersistentVolume to /data inside of minikube - my pod went live like a charm. 一旦我将PersistentVolume映射到minikube内的/data ,我的吊舱就像一个魅力一样上线了。

i my case i've decided since minikube is development environment there no reason to be stuck on this 我的情况是我决定的,因为minikube是开发环境,因此没有任何理由要坚持下去

UPDATE: 更新:

i wish i would found out this earlier, would save me some time! 我希望我能早点发现这个问题,可以节省一些时间!

docker CE desktop has built in kubernetes! docker CE桌面内置了kubernetes!

all you need is to go to the properties and turn it on, that's it no need in virtual box or minikube at all. 您所需要做的就是转到属性并将其打开,这完全不需要在虚拟盒子或minikube中。

and the best thing is that shared folders (on File Sharing tab) - are available for kubernetes - checked with mongodb inside of k8s. 最好的是,共享文件夹(在“文件共享”选项卡上)-适用于kubernetes-已在k8s内部使用mongodb检查。 And it way faster then minikube (which was failing all the time by the way on my OS X). 而且它的速度比minikube快(在我的OS X上一直失败)。

Hope it's going to save someone time. 希望它可以节省某人的时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM