How to mount a google storage bucket for storage of call recordings or syncing of any directory:
Step 1 – install Cloud SDK:
Update YUM with Cloud SDK repo information:
sudo tee -a /etc/yum.repos.d/google-cloud-sdk.repo << EOM
[google-cloud-sdk]
name=Google Cloud SDK
baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOM
Install the Cloud SDK:
yum install google-cloud-sdk
Run gcloud init to get started:
gcloud init
Step 2 install gcsfuse:
Configure the gcsfuse repo:
sudo tee /etc/yum.repos.d/gcsfuse.repo > /dev/null <<EOF[gcsfuse]name=gcsfuse (packages.cloud.google.com)baseurl=https://packages.cloud.google.com/yum/repos/gcsfuse-el7-x86_64enabled=1gpgcheck=1repo_gpgcheck=1gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpgEOF
Make the system aware of the new repo:
sudo yum update
Be sure to answer “yes” to any questions about adding the GPG signing key.
Install gcsfuse:
sudo yum install gcsfuse
Be sure to answer “yes” to any questions about adding the GPG signing key.
Create a directory you want to sync.
$ mkdir /path/to/mount
Create the bucket you wish to mount, if it doesn’t already exist, using the Google Cloud Console.
Use Cloud Storage FUSE to mount the bucket (e.g. example-bucket).
$ gcsfuse example-bucket /path/to/mount
Edit fstab (this step is important)
nano /etc/fstab
mybucket /var/spool/asterisk/cloud gcsfuse rw,allow_other,file_mode=777,dir_mode=777
Stop your VM in GCE console, once it’s stopped edit the VM and scroll to the bottom the Cloud API access scopes section. Change the storage API to full access. (stopping the VM is important, you need to reboot for the fstab config to take affect and properly mount, also you must allow full access to the storage api)
Start the VM.
Once it boots up the directory will now be mounted to a google storage bucket.