kubernetes_persistent_volume

The resource provides a piece of networked storage in the cluster provisioned by an administrator. It is a resource in the cluster just like a node is a cluster resource. Persistent Volumes have a lifecycle independent of any individual pod that uses the PV.

More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes/

Example Usage

resource "kubernetes_persistent_volume" "example" {
    metadata {
        name = "terraform-example"
    }
    spec {
        capacity {
            storage = "2Gi"
        }
        access_modes = ["ReadWriteMany"]
        persistent_volume_source {
            vsphere_volume {
                volume_path = "/absolute/path"
            }
        }
    }
}

Argument Reference

The following arguments are supported:

Nested Blocks

spec

Arguments

persistent_volume_source

Arguments

aws_elastic_block_store

Arguments

azure_disk

Arguments

  • caching_mode - (Required) Host Caching mode: None, Read Only, Read Write.
  • data_disk_uri - (Required) The URI the data disk in the blob storage
  • disk_name - (Required) The Name of the data disk in the blob storage
  • fs_type - (Optional) Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified.
  • read_only - (Optional) Whether to force the read-only setting in VolumeMounts. Defaults to false (read/write).

azure_file

Arguments

  • read_only - (Optional) Whether to force the read-only setting in VolumeMounts. Defaults to false (read/write).
  • secret_name - (Required) The name of secret that contains Azure Storage Account Name and Key
  • share_name - (Required) Share Name

ceph_fs

Arguments

cinder

Arguments

fc

Arguments

  • fs_type - (Optional) Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified.
  • lun - (Required) FC target lun number
  • read_only - (Optional) Whether to force the read-only setting in VolumeMounts. Defaults to false (read/write).
  • target_ww_ns - (Required) FC target worldwide names (WWNs)

flex_volume

Arguments

  • driver - (Required) Driver is the name of the driver to use for this volume.
  • fs_type - (Optional) Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. "ext4", "xfs", "ntfs". The default filesystem depends on FlexVolume script.
  • options - (Optional) Extra command options if any.
  • read_only - (Optional) Whether to force the ReadOnly setting in VolumeMounts. Defaults to false (read/write).
  • secret_ref - (Optional) Reference to the secret object containing sensitive information to pass to the plugin scripts. This may be empty if no secret object is specified. If the secret object contains more than one secret, all secrets are passed to the plugin scripts.

flocker

Arguments

  • dataset_name - (Optional) Name of the dataset stored as metadata -> name on the dataset for Flocker should be considered as deprecated
  • dataset_uuid - (Optional) UUID of the dataset. This is unique identifier of a Flocker dataset

gce_persistent_disk

Arguments

glusterfs

Arguments

host_path

Arguments

iscsi

Arguments

  • fs_type - (Optional) Filesystem type of the volume that you want to mount. Tip: Ensure that the filesystem type is supported by the host operating system. Examples: "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified. More info: http://kubernetes.io/docs/user-guide/volumes#iscsi
  • iqn - (Required) Target iSCSI Qualified Name.
  • iscsi_interface - (Optional) iSCSI interface name that uses an iSCSI transport. Defaults to 'default' (tcp).
  • lun - (Optional) iSCSI target lun number.
  • read_only - (Optional) Whether to force the read-only setting in VolumeMounts. Defaults to false.
  • target_portal - (Required) iSCSI target portal. The portal is either an IP or ip_addr:port if the port is other than default (typically TCP ports 860 and 3260).

metadata

Arguments

Attributes

nfs

Arguments

photon_persistent_disk

Arguments

  • fs_type - (Optional) Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified.
  • pd_id - (Required) ID that identifies Photon Controller persistent disk

quobyte

Arguments

  • group - (Optional) Group to map volume access to Default is no group
  • read_only - (Optional) Whether to force the Quobyte volume to be mounted with read-only permissions. Defaults to false.
  • registry - (Required) Registry represents a single or multiple Quobyte Registry services specified as a string as host:port pair (multiple entries are separated with commas) which acts as the central registry for volumes
  • user - (Optional) User to map volume access to Defaults to serivceaccount user
  • volume - (Required) Volume is a string that references an already created Quobyte volume by name.

rbd

Arguments

secret_ref

Arguments

vsphere_volume

Arguments

  • fs_type - (Optional) Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified.
  • volume_path - (Required) Path that identifies vSphere volume vmdk

Import

Persistent Volume can be imported using its name, e.g.

$ terraform import kubernetes_persistent_volume.example terraform-example

© 2018 HashiCorp
Licensed under the MPL 2.0 License.
https://www.terraform.io/docs/providers/kubernetes/r/persistent_volume.html