creating NFS directories remotely in google cloud

3/20/2019

I'm trying to auomate the process of creating these directories

/data/foo
/data/foo/baz
/data/bar

on an NFS (Network File System) I created with the command

gcloud beta filestore instances create "${NFS_server_name}" \
  --project "${project_id}" \
  --location "${zone}" \
  --tier=STANDARD \
  --file-share=name="vol1",capacity=1TB \
  --network=name="default",reserved-ip-range="10.0.1.0/29"

so that I can create some kubernetes persistent volumes at the directories listed above. I have found no way to automate this process, the NFS has no public IP and even using a bastion machine doesn't work because google cloud logically separates the VM running the NFS from other instances.

This is my attempt with using a bastian machine:

# send remote command to provision NFS server
command_to_run='cd /data && mkdir -m 777 data && mkdir -m 777 outputs && mkdir -m 777 logs && mkdir -m 777 repos && mkdir -m 777 upload && cd repos && mkdir deployments/ && chmod 777 deployments/'
send_to_bastian=$(gcloud compute ssh ${NFS_server_name} \
    --zone ${zone} \
  --command "${command_to_run}")

echo "sending provisioning instructions to bastian machine: ${bastian_name}"
gcloud compute ssh ${bastian_name} \
    --zone ${zone} \
    --command "${send_to_bastian}"

How can I script the creation of these directories on the bastian machine? From my limited kubernetes experience it seems I cannot create persistent volume claims without the directory existing on the NFS server.

FYI I am trying to automate this blog post: https://danielfrg.com/blog/2018/10/model-management-polyaxon-argo-seldon/#installing-polyaxon

In that post the OP remotes into the NFS and manually creates the directories, there must be some way to automate this?

-- Adam Rummer
google-cloud-filestore
google-kubernetes-engine
kubernetes
nfs

1 Answer

4/9/2019

Filestore instances are managed by Google, which handles the hassle of installing and configuring software, letting the users focus on their projects. This is the reason for which you cannot access it via SSH.

To provision folders in a NFS server without manual intervention you can use nfs-client-provisioner. It's a Helm chart written to help with the provision of NFS folders without user intervention.


-- Matias Paglioni
Source: StackOverflow