Mount Google storage bucket in Google container

2019-04-29 03:18发布

问题:

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.

回答1:

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"