Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mount Google storage bucket in Google container

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.

like image 608
Nitin Avatar asked Mar 13 '16 05:03

Nitin


People also ask

How do I mount a GCP bucket inside a container?

To mount the GCP bucket inside the container, run the container in privileged mode. For a container to start the deployment the file should contain required configuration with a Google Cloud Storage bucket mounted in a given path.

How do I mount a GCS bucket in Linux?

FUSE InstallationCloud Storage FUSE is an open source FUSE adapter that allows you to mount Google Cloud Storage buckets as file systems on Linux or OS X systems. It also provides a way for applications to upload and download Google Cloud Storage objects using standard file system semantics.

How do I add a bucket to my Google Cloud?

In the Google Cloud console, go to the Cloud Storage Buckets page. In the list of buckets, click on the name of the bucket that you want to upload an object to. In the Objects tab for the bucket, either: Drag and drop the desired files from your desktop or file manager to the main pane in the console.


1 Answers

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"
    
like image 90
Nitin Avatar answered Nov 10 '22 16:11

Nitin