Cloud Filestore is a managed file storage service for applications that require a filesystem interface and a shared filesystem for data. Filestore gives users a simple, native experience for standing up managed Network Attached Storage (NAS) with their Compute Engine and Google Kubernetes Engine instances.
The ability to fine-tune Filestore’s performance and capacity independently leads to predictably fast performance for your file-based workloads.
In this lab we’ll learn how to perform basic operations in Cloud Filestore using the Google Cloud console. We will:
- Create a Cloud Filestore instance.
- Mount the fileshare from that instance on a client VM instance.
- Create a file on the mounted fileshare.
Cloud Filestore Architecture
Cloud Filestore architectural choices that affect your Cloud Filestore instances:
A Cloud Filestore instance consists of a single NFS fileshare with fixed export settings and default Unix permissions.
- You must create a Cloud Filestore instance in the same Google Cloud project and VPC network as any clients that connect to it. All internal IP addresses in the selected VPC network can connect to the Cloud Filestore instance.
- If you are using a VPC network other than the default network, you might need to create firewall rules to enable communication with Cloud Filestore instances.
- You can’t use a legacy network with Cloud Filestore instances.
IP address range
Each Cloud Filestore instance must have an IP address range associated with it. The IP address range must be from within the internal IP address ranges (10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16) and have a block size of 29. Examples of valid Cloud Filestore instance IP address ranges are 10.0.3.0/29 and 172.31.0.0/29.
You can assign the IP address range if there’s a specific one you want to use, otherwise Cloud Filestore picks a random range to use from within the internal IP address ranges. If the range is already in use, the service tries again until it finds one that is free. If you assign an IP address range, make sure it doesn’t overlap with any existing subnets in the VPC network that the Cloud Filestore instance uses, or with the IP address ranges assigned to any other existing Cloud Filestore instances in that network.
Cloud Filestore network peering
The first time you create a Cloud Filestore instance, Cloud Filestore also creates a peered network to enable network connectivity between clients in your project and the Cloud Filestore instance. The peered network has a machine-generated name similar to r-1abc2d3e-45fg-6789-hf12-3456i78j9k1-0000000a-peer, and appears in the VPC Network Peering page.
Don’t delete the peered network, because this will cause you to lose connectivity with your Cloud Filestore instances. If you accidentally delete the peered network, the easiest thing to do to re-create it is to create another Cloud Filestore instance. Cloud Filestore will recognize that there is no connectivity between your project and the new instance, and will re-create the peered network. you can delete the new Cloud Filestore instance after that if you don’t need it for anything else.
Storage size units
Cloud Filestore defines 1 gigabyte (GB) as 1024^3 bytes, also known as a gibibyte (GiB). Cloud Filestore also defines 1 terabyte (TB) as 1024^4 bytes, also known as a tebibyte (TiB).
Create a Compute Engine instance
Navigate to VM Instances by going to Navigation Menu > Compute Engine > VM Instances and click Create.
Set up your VM with the following information:
You you will need to fill the details similar to below:
Now Click on Create.
Once the instance is created, you will get something like below:
Create a Cloud Filestore instance
Check that Cloud Filestore API is enabled and then move ahead.
Navigate to Navigation Menu > Filestore.
If you get an error message be sure you navigated to Filestore and not Firestore.
Click Create Instance at the top of the page.
Create your Cloud Filestore instance with the following information:
You will see similar like this:
Wait for couple of minutes until it our Filestore server gets created. Upon successfully creation, you will see something like below:
Mount the Cloud Filestore fileshare on a Compute Engine VM
- Navigate Navigation Menu > Compute Engine > VM Instances.
- In the list of VM instances, click the SSH button for nfs-client to open a terminal window connected to that instance.
- In SSH shell install NFS by running the following commands:
sudo apt-get -y update &&
sudo apt-get -y install nfs-common
- Make a mount directory for the Cloud Filestore fileshare by running the following command:
sudo mkdir /mnt/test
- Mount the fileshare by running the mount command and specifying the Cloud Filestore instance IP address and fileshare name:
sudo mount YOUR_INSTANCE_URL:/vol1 /mnt/test
In our case its:
sudo mount 10.48.193.218:/vol1 /mnt/test
- Make the fileshare accessible by changing the permissions:
sudo chmod go+rw /mnt/test
Create a file on the fileshare
- In the terminal window that is connected to the nfs-client instance, run the following to create a file named testfile:
echo ‘This is a test’ > /mnt/test/testfile
- Confirm the file was created by running the following command:
You’ll see that testfile is in the directory.
3. You can see the content of the file by running the following command:
You should see that the file contains the following text:
This is a test
That concludes the tutorial for Cloud Filestore.