VK Cloud logo
Updated atJuly 12, 2023   01:52 PM

Creating NFS

To create NFS, create a file nfs.tf, which will describe the configuration of the NFS being created. This example creates NFS and grants read/write access from two IP addresses. Add the text from the examples below, and correct the settings for your NFS.

Create a virtual network for NFS

When creating NFS, you must specify the network and subnet on which this resource will be created. You can create a network and subnet according to instruction and specify them in the vkcs_networking_network and vkcs_networking_subnet resources in the example below.

If you want to use a network and subnet created in another way, specify them as data source [vkcs_networking_network](https://github.com/vk-cs/terraform-provider-vkcs/blob/master/docs/data-sources/vkcs_networking_network .md) and vkcs_networking_subnet instead of the corresponding resources.

Create NFS

To create NFS, you need the following objects:

  • Resources:

    • vkcs_networking_network — network where NFS will be created. In the example below, a network is created with the name "sfs".

    • vkcs_networking_subnet — subnet from the network. In the example: sfs.

    • vkcs_sharedfilesystem_sharenetwork — Use this resource to set up a share network. The share network stores information that NFS servers can use when creating NFS. Includes the following resources:

      • name — Name for the shared network. Changing this setting updates the name of an existing shared network.
      • neutron_net_id — UUID of the neutron network when setting up or updating the general network. Changing this setting updates the existing shared network if it is not being used by shared resources.
      • neutron_subnet_id — UUID of the neutron subnet when setting up or updating the shared network. Changing this setting updates the existing shared network if it is not being used by shared resources.
    • vkcs_sharedfilesystem_share — Use this share to set up a share. Contains the following resources:

      • name — Share name. Changing this setting updates the name of an existing share.
      • description — A human-readable description of the share. Changing this setting updates the description of an existing share.
      • share_proto — Sharing protocol — can be NFS, CIFS, CEPHFS, GLUSTERFS, HDFS or MAPRFS. Changing this setting creates a new share.
      • share_type — The share type name. If you omit this parameter, the default share type is used.
      • size — Share size, in gigabytes. The requested share size cannot exceed the allowed quota in GB. Changing this setting changes the size of the existing share.
      • share_network_id — network ID with NFS server.
    • vkcs_sharedfilesystem_share_access — Use this resource to manage share lists. Contains the following resources:

      • share_id is the UUID of the share that you have been granted access to.
      • access_type — Access rule type. Can be either ip, user, cert, or cephx.
      • access_to — Value specifying access. This can be either an IP address or a username verified by the configured Public Network security service.
      • access_level — Level of access to the shared resource. Can be either rw for read-write access or ro for read-only access.

Example nfs.tf file:

1resource "vkcs_networking_network" "sfs" {
2       name="network"
3     }
4
5resource "vkcs_networking_subnet" "sfs" {
6   name="subnet"
7   cidr="192.168.199.0/24"
8   network_id = "${vkcs_networking_network.sfs.id}"
9}
10
11resource "vkcs_sharedfilesystem_sharenetwork" "sharenetwork" {
12   name="test_sharenetwork"
13   neutron_net_id = "${vkcs_networking_network.sfs.id}"
14   neutron_subnet_id = "${vkcs_networking_subnet.sfs.id}"
15}
16
17resource "vkcs_sharedfilesystem_share" "share" {
18   name="nfs_share"
19   description = "test share description"
20   share_proto="NFS"
21   share_type = "default_share_type"
22   size=1
23   share_network_id = "${vkcs_sharedfilesystem_sharenetwork.sharenetwork.id}"
24}
25
26resource "vkcs_sharedfilesystem_share_access" "share_access_1" {
27   share_id = "${vkcs_sharedfilesystem_share.share.id}"
28   access_type="ip"
29   access_to="192.168.199.10"
30   access_level="rw"
31}
32
33resource "vkcs_sharedfilesystem_share_access" "share_access_2" {
34   share_id = "${vkcs_sharedfilesystem_share.share.id}"
35   access_type="ip"
36   access_to = "192.168.199.11"
37   access_level="rw"
38}

Apply changes

Add both parts of the example to the nfs.tf file and run the following commands:

terraform init
terraform apply