10

I would like to mount Google storage bucket in Google Container Engine using gcafuse or any other tool/other provision. The container runs under Google container engine So,we need to use yaml file to define few parameters in it.

If there is any kind of thing that can be used in .yaml file to build new replication controller/service using privileged and sys_admin or any other required parameters in it.

Nitin
  • 10,101
  • 4
  • 17
  • 34
  • This upstream [issue](https://github.com/kubernetes/kubernetes/issues/7890) seems related. It seems the use case is not supported yet but I could be wrong. Asking the question there might get you answers from those experts :) – caesarxuchao Mar 13 '16 at 23:59
  • I have installed gcsfuse in the docker container image and using privileged=true parameter to mount it still not able to mount it in container. Need more inputs on it. apiVersion: v1 kind: ReplicationController metadata: name: apache spec: replicas: 1 template: metadata: labels: app: apache spec: containers: - name: apachehttps image: httpd:v1 securityContext: capabilities: {} privileged: true command: ["gcsfuse --key-file=/usr/local/Test.json test1-clod-storage /mnt"] ports: - containerPort: 443 - containerPort: 80 – Nitin Mar 14 '16 at 06:18
  • Nitin, like chao mentioned GCSFuse currently does not have a Kubernetes volume plugin (since there is no FUSE FS support in k8s yet). To mount GCS in a container you have to set it all up manually using gcsfuse, which it appears you are doing. What errors do you see in the container log? – Saad Ali Mar 14 '16 at 18:22
  • Now I am good with mounting bucket manually in pod. Is there anyway to mount bucket at container/pod startup passing "mount /mnt" to some script or anything. fstab is not working at startup for pods. after adding parameters in fstab need to execute "mount /mnt" manually and i don't want to mount it manually. I was trying like below multiple options in yaml file. command: ["sh","-c","/usr/local/start.sh"] exec: command: "/usr/local/start.sh" command: ["mount /mnt"] - "/usr/local/start.sh" – Nitin Mar 15 '16 at 11:39

1 Answers1

12

We can use gcsfuse or s3fuse to mount Google Storage bucket in Kubernetes pod/Container. Before starting installation of fuse on container run container with SYS_ADMIN privileges like below.

$ docker run -it --cap-add SYS_ADMIN --name dev --device /dev/fuse ContainerID/Name /bin/bash

  1. Install gcsfuse or s3fuse in pod/Container image.
  2. Create shell script and add mount command in it.
  3. Add privileged parameter into the YAML file to grant admin capabilities to pod/Container. example as below.

      securityContext:
         capabilities: {}
         privileged: true
    
  4. Add Postlife cycle hook parameters in YAML file to mount bucket after postStart of pod/Container. example as below.

      lifecycle:
        postStart:
         exec:
            command:
              - "sh"
              - "/usr/local/gcsfusemount.sh"
    
Nitin
  • 10,101
  • 4
  • 17
  • 34