Quickstart Using the gcloud Tool

This quickstart shows you how to perform basic operations in Cloud Filestore using the gcloud command-line tool from a local terminal window. In the quickstart, you will:

  • Create a Cloud Filestore instance.
  • Mount the fileshare from that instance on a client VM instance.
  • Create a file on the mounted fileshare.
  • Delete the Cloud Filestore instance.

Before you begin

  1. Select or create a GCP project.

    Go to the manage resources page

  2. Make sure that billing is enabled for your project.

    Learn how to enable billing

  3. If you haven't already, enable the gcloud command-line tool by installing the Cloud SDK on your computer.

    If you already have the Cloud SDK installed, run the following command to update it:

    gcloud components update
    

Create a Compute Engine VM instance to be the client

  1. Go to the Compute Engine instances page
  2. Click Create Instance.
  3. Set Name to nfs-client.
  4. Set Zone to us-central1-c.
  5. In the Boot disk section, click Change to begin configuring your boot disk.
  6. In the OS images tab, choose a Debian or Ubuntu image.
  7. Click Select.
  8. In the Firewall section, select Allow HTTP traffic.
  9. Click Create to create the instance.

Create a Cloud Filestore instance

  1. Create an instance named nfs-server by running the following command in a local terminal window:

    gcloud filestore instances create nfs-server \
        --project=[PROJECT_ID] \
        --zone=us-central1-c \
        --tier=STANDARD \
        --file-share=name="vol1",capacity=1TB \
        --network=name="default",reserved-ip-range="10.0.0.0/29"
    

    Where [PROJECT_ID] is the ID of the GCP project in which to create the instance.

  2. Get information about the instance you just created by running the following command:

    gcloud filestore instances describe nfs-server --project=[PROJECT_ID] --zone=us-central1-c
    

    Where [PROJECT_ID] is the ID of the GCP project in which you created the instance.

    Note the IP address in the ipaddresses section in the response. This is the IP address for the Cloud Filestore instance, which you use to mount the Cloud Filestore fileshare on the client.

    The response to the instances describe command is similar to the following:

    createTime: '2017-11-06T16:49:36.852873Z'
    name: projects/yourproject/locations/us-central1-c/instances/nfs-server
    networks:
    - ipaddresses:
      - 10.0.0.2
      network: default
      reservedIpRange: 10.0.0.0/29
    state: READY
    tier: STANDARD
    fileshares:
    - capacityGb: '1024'
      name: vol1

When the command completes, leave the terminal window open, as you will use it when you delete the Cloud Filestore instance.

Mount the Cloud Filestore fileshare on the client

  1. Go to the VM instances page
  2. In the list of VM instances, click the SSH button for nfs-client to open a terminal window connected to that instance.
  3. Install NFS by running the following commands:

    sudo apt-get -y update
    sudo apt-get -y install nfs-common
    
  4. Make a mount directory for the Cloud Filestore fileshare by running the following command:

    sudo mkdir /mnt/test
    
  5. Mount the fileshare by running the mount command and specifying the Cloud Filestore instance IP address and fileshare name:

    sudo mount 10.0.0.2:/vol1 /mnt/test
    
  6. Make the fileshare accessible by changing the permissions:

    sudo chmod go+rw /mnt/test
    

Create a file on the fileshare

  1. In the terminal window that is connected to the nfs-client instance, create a file named testfile by running the following command:

    echo 'This is a test' > /mnt/test/testfile
    
  2. Confirm the file was created by running the following command:

    ls /mnt/test
    

    And verifying that testfile is in the directory contents returned.

Clean up

To avoid incurring charges to your GCP account for the resources used in this quickstart:

  1. Delete the Cloud Filestore instance by running the following command in your local terminal window:

    gcloud filestore instances delete nfs-server --project=[PROJECT_ID] --zone=us-central1-c

    Where [PROJECT_ID] is the ID of the GCP project in which you created the Cloud Filestore instance.

  2. Go to the VM instances page
  3. Click the name of the nfs-client instance.
  4. At the top of the instance's details page, click Delete.
  5. Follow the instructions at Shutting down projects to delete the GCP project you created.

What's next

  • Read the Cloud Filestore Overview to learn more about the basics of Cloud Filestore.
  • Set up a Cloud Filestore instance on your own by following the instructions at Creating Instances.
  • Read the Access Control to learn how to control access to Cloud Filestore operations as well as the resources on an instance.
Kunde den här sidan hjälpa dig? Berätta:

Skicka feedback om ...

Cloud Filestore Documentation