Need help! hostpath volume mounted with ownership 1001:1001, while 999:1000 is expected

I’ve been working on deploying MQ containers in a minikube cluster using the yaml file below.

In the standalone container, just as any local installation, MQ directories are owned by mqm:mqm, which is 999:1000.

But after mounting the hostpath /home/user1/data/mq/QMGR1 as a volume to /var/mqm/data/QMGR1, the mounted folder carries the ownership of 1001:1001, which doesn’'t even exist in the container Pod. So the process won’t start, with a message:
AMQ6242: Incorrect ownership for ‘/var/mqm/data/QMGR1’. Current(1001) Expected(999)

Can a more experienced member advise me what is the proper course of action for me to take? should I alter the uid:gid on the container to 1001:1001? But that might break the container. Or is there a way to force the ownership to 999:1000?

thanks much for any advice!

Cluster information:

minikube version: v0.28.2
Host OS: Ubuntu 16.04 server

| | | volumeMounts:
| | | - mountPath: /var/mqm/data/QMGR1
| | | | name: mqdata
| | | - mountPath: /var/mqm/log/QMGR1
| | | | name: mqlog
| | volumes:
| | - name: mqdata
| | | hostPath:
| | | | path: /hosthome/user1/data/mq/QMGR1
| | - name: mqlog
| | | hostPath:
| | | | path: /hosthome/user1/log/mq/CBPGTW0

Is that the UID/GID of the host-side directory? hostPath gives you access to host files, but it does not chmod them. You would do better to use a volume.

thanks for answering. No, it is not. On the host, it is 999:1001 which is mqm:mqm. So it is the mounting action that set it the 1001:1001. I tried to sudo chown, but nothing happens.

I thought I was doing hostpath volume mount. would you mind explain a bit more?

hostPath is sort of an escape-hatch when nothing else works. You can model host-specific directories as PersistentVolumes instead, which DOES allow chown.

https://kubernetes.io/blog/2019/04/04/kubernetes-1.14-local-persistent-volumes-ga/

thanks for sharing the article. I just updated my docker, minikube and kubectl.

  • minikube version: v1.12.2
  • kubectl version v1.18.6
  • docker Version: 19.03.12
    I noticed now in the pod, /hosthome is no longer there. maybe because a better way as you described exists now?
    Here’s the main question. To use local persistent volume, I have to have a disk or partition in the minikube node, which is a VBox VM. But I can only share a host folder to the VM, not a partition. How should a pass a host partition to that in a VM?

thanks much!