Skip to content

Sample configuration using Google Cloud Storage as a container volume on Kubernetes

Notifications You must be signed in to change notification settings

maciekrb/gcs-fuse-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

GCSFuse storage for containers

This directory contains a sample deployment using Google Cloud Storage as a multi RW file system that can be mounted from different containers.

The deployment file contains the required configuration for a container to start with a Google Cloud Storage bucket mounted in a given path.

The most note worthy parts of the configuration are the following:

securityContext:
  privileged: true
  capabilities:
    add:
      - SYS_ADMIN

For the container to have access to /dev/fuse it has to run with SYS_ADMIN capabilities.

lifecycle:
  postStart:
    exec:
      command: ["gcsfuse", "-o", "nonempty", "test-bucket", "/mnt/test-bucket"]
  preStop:
    exec:
      command: ["fusermount", "-u", "/mnt/test-bucket"]

As no real Kubernetes volumes are really involved, the whole thing can be implemented by using lifecycle directives, a postStart will mount the gcsfuse volume and a preStop will unmount it.

The big catch is that for this to work, the container has to be built with gcsfuse. The Dockerfile includes a base build for debian jessie.

Unfortunately as the gcsfuse does not sync the files, it is not possible to share the file system with other containers in the pod via a volumes[].emptyDir.{} directive.

References

https://cloud.google.com/storage/docs/gcs-fuse https://github.com/GoogleCloudPlatform/gcsfuse https://karlstoney.com/2017/03/01/fuse-mount-in-kubernetes/

About

Sample configuration using Google Cloud Storage as a container volume on Kubernetes

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •