hope some of you may have a solution to this :
I have a python code that is supposed to write a file output.csv, I want to find that file outside the container in a folder named /data, I have a glusterfs volumes. so I'm using Kubernetes to deploy my container. then when it runs I should find that file in the folder of the glusterfs: here is my Yaml file : the glusterfs volume :
[xxx@xxxx ~]$ df |grep gluster
/dev/mapper/glustervg-glusterlv 10471424 1633164 8838260 16% /var/lib/glusterfs
xxxx:/gluster_vol 10471424 1737876 8733548 17% /data
thank you for your help
update: I've followed this tutorial to try to deploy a volume with glusterfs https://docs.openshift.com/container-platform/3.7/install_config/storage_examples/gluster_example.html
so I created these file : gluster endpoit.yaml
apiVersion: v1
kind: Endpoints
metadata:
name: gluster-cluster
subsets:
- addresses:
- ip: 10.122.5.143
ports:
- port: 1
protocol: TCP
- addresses:
- ip: 10.122.5.142
ports:
- port: 1
protocol: TCP
the persistent volume:
apiVersion: v1
kind: PersistentVolume
metadata:
name: gluster-pv
spec:
capacity:
storage: 3Gi
accessModes:
- ReadWriteMany
glusterfs:
endpoints: gluster-cluster
path: data
readOnly: false
persistentVolumeReclaimPolicy: Retain
the persistent volume claim :
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: gluster-claim
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 3Gi
the gluster service :
apiVersion: v1
kind: Service
metadata:
name: gluster-cluster
spec:
ports:
- port:
and my new deployment looks like this :
apiVersion: apps/v1
kind: Deployment
metadata:
name: uc1-deploy
spec:
selector:
matchLabels:
app: uc1
replicas: 1
template:
metadata:
labels:
app: uc1
spec:
containers:
- name: uc1
image: predicteur_uc1:1.5
volumeMounts:
- mountPath: /output
name: test-volumed
readOnly: false
ports:
- containerPort: 90
volumes:
- name: test-volumed
persistentVolumeClaim:
claimName: gluster-claim
and when I deploy it I get that error :
Output: Running scope as unit run-20456.scope.
[2019-11-25 11:29:08.230125] E [glusterfsd.c:825:gf_remember_backup_volfile_server] 0-glusterfs: failed to set volfile server: File exists
Mount failed. Please check the log file for more details.
, the following error information was pulled from the glusterfs log to help diagnose this issue:
[2019-11-25 11:29:08.244765] E [glusterfsd-mgmt.c:1958:mgmt_getspec_cbk] 0-glusterfs: failed to get the 'volume file' from server
[2019-11-25 11:29:08.244841] E [glusterfsd-mgmt.c:2151:mgmt_getspec_cbk] 0-mgmt: failed to fetch volume file (key:/data)
As OP already mentioned in comments, the issue was that spec.glusterfs.path
in PersistentVolume
was set to the name of directory where glusterfs volume was mounted on system.
Setting its value to actual glusterfs volume path (/gluster_vol
instead of data
) resolved the issue.
YES the value must be gluster_vol instead of data wich data represent the folder where the glusterfs is mounted on the machine but the volume name is rather gluster_vol. that is the fisrt error I made.
second the mountpath in the deployment represent a folder inside the container where my gluster_vol ( and what it containes) must be mounted so it create a folder inside the container that is linked to the gluster vol, so basicaly i will put whatever is on the gluster_vol inside the folder output wich is inside my container.
third my python code crate the csv files inside the folder output/opportunity, so this folder structure must be in the gluster_vol too . thank you helloWorld and clement for your implication guys, you helped