-
-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot mount volume with non-root user #6
Comments
@epalazuelosb Does it work if you specify the correct |
Yes, I have tried it, but still not working: apiVersion: v1
kind: PersistentVolume
metadata:
name: csi-gcs-pv
annotations:
pv.beta.kubernetes.io/gid: "1000"
spec:
accessModes:
- ReadWriteOnce
capacity:
storage: 50Gi
persistentVolumeReclaimPolicy: Retain
storageClassName: csi-gcs
csi:
driver: gcs.csi.ofek.dev
volumeHandle: csi-gcs
volumeAttributes:
uid: "1000"
gid: "1000"
dir-mode: "777"
file-mode: "664"
nodePublishSecretRef:
name: csi-gcs-secret
namespace: csi-gcs |
apiVersion: v1
kind: PersistentVolume
metadata:
name: csi-gcs-pv
namespace: liferay7
annotations:
pv.beta.kubernetes.io/gid: "1000"
spec:
accessModes:
ReadWriteMany
capacity:
storage: 50Gi
persistentVolumeReclaimPolicy: Retain
storageClassName: csi-gcs
csi:
driver: gcs.csi.ofek.dev
volumeHandle: csi-gcs
volumeAttributes:
uid: "1000"
gid: "1000"
dir-mode: "775"
file-mode: "664"
nodePublishSecretRef:
name: csi-gcs-secret
namespace: csi-gcs |
@epalazuelosb You need to set apiVersion: v1
kind: PersistentVolume
metadata:
name: csi-gcs-pv
namespace: liferay7
annotations:
pv.beta.kubernetes.io/gid: "1000"
spec:
accessModes:
ReadWriteMany
capacity:
storage: 50Gi
persistentVolumeReclaimPolicy: Retain
storageClassName: csi-gcs
csi:
driver: gcs.csi.ofek.dev
volumeHandle: csi-gcs
volumeAttributes:
flags:
uid: "1000"
gid: "1000"
dir-mode: "775"
file-mode: "664"
nodePublishSecretRef:
name: csi-gcs-secret
namespace: csi-gcs or maybe this: apiVersion: v1
kind: PersistentVolume
metadata:
name: csi-gcs-pv
namespace: liferay7
annotations:
pv.beta.kubernetes.io/gid: "1000"
spec:
accessModes:
ReadWriteMany
capacity:
storage: 50Gi
persistentVolumeReclaimPolicy: Retain
storageClassName: csi-gcs
csi:
driver: gcs.csi.ofek.dev
volumeHandle: csi-gcs
volumeAttributes:
flags:
- '--uid="1000"'
- '--gid="1000"'
- '--dir-mode="775"'
- '--file-mode="664"'
nodePublishSecretRef:
name: csi-gcs-secret
namespace: csi-gcs |
I've got a validation error in both cases: error validating data: ValidationError(PersistentVolume.spec.csi.volumeAttributes.flags): invalid type for io.k8s.api.core.v1.CSIPersistentVolumeSource.volumeAttributes: got "array", expected "string"; if you choose to ignore these errors, turn validation off with --validate=false But the previous one I have applied was correct:
So it looks that is correctly configured, but not correctly mounted. Maybe the mistake is on the deployment side? |
@epalazuelosb The volume attributes you mentioned are not being read. They have no effect. Try with this? apiVersion: v1
kind: PersistentVolume
metadata:
name: csi-gcs-pv
namespace: liferay7
annotations:
pv.beta.kubernetes.io/gid: "1000"
spec:
accessModes:
ReadWriteMany
capacity:
storage: 50Gi
persistentVolumeReclaimPolicy: Retain
storageClassName: csi-gcs
csi:
driver: gcs.csi.ofek.dev
volumeHandle: csi-gcs
volumeAttributes:
flags: '--uid="1000" --gid="1000" --dir-mode="775" --file-mode="664"'
nodePublishSecretRef:
name: csi-gcs-secret
namespace: csi-gcs |
Now it looks we have something:
|
Once corrected the quotes it looks to work correctly! Let me check it |
Confirmed. The solution provided by @maennchen:
Worked correctly. edit: fixed typo |
@epalazuelosb We recently made flags more robust: |
I have realized that the mount is not working properly:
I can create directories and files from pods, I can list files created by other users. I cannot see directories created by other users unless I create a directory with the same name. In that case I can see the directory and its contents. |
@epalazuelosb Can you enable implicit dirs? |
Also fyi |
@epalazuelosb Any luck? |
Excuse me. No, I cannot deploy the PV: apiVersion: v1
kind: PersistentVolume
metadata:
name: csi-gcs-pv
annotations:
pv.beta.kubernetes.io/gid: "1000"
spec:
accessModes:
- ReadWriteMany
capacity:
storage: 50Gi
mountOptions:
- --uid=1000
--gid=1000
--dir-mode=0775
--file-mode=0664
--implicit-dirs="document_library"
persistentVolumeReclaimPolicy: Retain
storageClassName: csi-gcs
csi:
driver: gcs.csi.ofek.dev
volumeHandle: csi-gcs
volumeAttributes:
gid: "1000"
uid: "1000"
dirMode: "0775"
fileMode: "0664"
implicitDirs: "document_library"
nodePublishSecretRef:
name: csi-gcs-secret
|
While apiVersion: v1
kind: PersistentVolume
spec:
mountOptions:
- --gid=63147
- --dir-mode=0775
- --file-mode=0664 that shouldn't matter since @maennchen Any thoughts? |
@ofek The yml above is not valid. Will not work therefore. |
Oh, yes. @epalazuelosb try removing |
Excuse, I have tried it before with the same result:
|
Ok, I am trying right now |
|
Now the PVC cannot be provisioned:
|
Excuse me. I have just updated the csi-gcs deployment. Now it looks to work, but the directory "document_library" created externally stills hidden for the pod:
|
Found the mistake on implicitDirs flag:
Thank you for your help. Now it works correctly. |
Steps
kubectl create namespace csi-gcs
kubectl create secret generic csi-gcs-secret --from-literal=bucket=my-gcs-bucket --from-file=key=./key.json --namespace csi-gcs
kubectl apply -f csi-gcs-sc.yaml
kubectl apply -f csi-gcs-pv.yaml
kubectl apply -f csi-gcs-pvc
Tried to chown objects with initcontainers command
kubectl apply -f csi-gcs-test.yaml
kubectl get sc,pv,pvc -n csi-gcs
kubectl get deploy -n csi-gcs
kubectl -n csi-gcs exec -it $(kubectl -n csi-gcs get po |grep csi | cut -f 1 -d " ") -c writer -- ls -l /data
Is there any way to mount it as non-root user? Tried also with gid annotations on pv and
fsGroup securityContext on deployment, with the same result
The text was updated successfully, but these errors were encountered: