--- layout: "kubernetes" page_title: "Kubernetes: kubernetes_persistent_volume_claim" sidebar_current: "docs-kubernetes-resource-persistent-volume-claim" description: |- This resource allows the user to request for and claim to a persistent volume. --- # kubernetes_persistent_volume_claim This resource allows the user to request for and claim to a persistent volume. ## Example Usage ```hcl resource "kubernetes_persistent_volume_claim" "example" { metadata { name = "exampleclaimname" } spec { access_modes = ["ReadWriteMany"] resources { requests { storage = "5Gi" } } volume_name = "${kubernetes_persistent_volume.example.metadata.0.name}" } } resource "kubernetes_persistent_volume" "example" { metadata { name = "examplevolumename" } spec { capacity { storage = "10Gi" } access_modes = ["ReadWriteMany"] persistent_volume_source { gce_persistent_disk { pd_name = "test-123" } } } } ``` ## Argument Reference The following arguments are supported: * `metadata` - (Required) Standard persistent volume claim's metadata. More info: https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata * `spec` - (Required) Spec defines the desired characteristics of a volume requested by a pod author. More info: http://kubernetes.io/docs/user-guide/persistent-volumes#persistentvolumeclaims * `wait_until_bound` - (Optional) Whether to wait for the claim to reach `Bound` state (to find volume in which to claim the space) ## Nested Blocks ### `metadata` #### Arguments * `annotations` - (Optional) An unstructured key value map stored with the persistent volume claim that may be used to store arbitrary metadata. More info: http://kubernetes.io/docs/user-guide/annotations * `generate_name` - (Optional) Prefix, used by the server, to generate a unique name ONLY IF the `name` field has not been provided. This value will also be combined with a unique suffix. Read more: https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#idempotency * `labels` - (Optional) Map of string keys and values that can be used to organize and categorize (scope and select) the persistent volume claim. May match selectors of replication controllers and services. More info: http://kubernetes.io/docs/user-guide/labels * `name` - (Optional) Name of the persistent volume claim, must be unique. Cannot be updated. More info: http://kubernetes.io/docs/user-guide/identifiers#names * `namespace` - (Optional) Namespace defines the space within which name of the persistent volume claim must be unique. #### Attributes * `generation` - A sequence number representing a specific generation of the desired state. * `resource_version` - An opaque value that represents the internal version of this persistent volume claim that can be used by clients to determine when persistent volume claim has changed. Read more: https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#concurrency-control-and-consistency * `self_link` - A URL representing this persistent volume claim. * `uid` - The unique in time and space value for this persistent volume claim. More info: http://kubernetes.io/docs/user-guide/identifiers#uids ### `spec` #### Arguments * `access_modes` - (Required) A set of the desired access modes the volume should have. More info: http://kubernetes.io/docs/user-guide/persistent-volumes#access-modes-1 * `resources` - (Required) A list of the minimum resources the volume should have. More info: http://kubernetes.io/docs/user-guide/persistent-volumes#resources * `selector` - (Optional) A label query over volumes to consider for binding. * `volume_name` - (Optional) The binding reference to the PersistentVolume backing this claim. ### `match_expressions` #### Arguments * `key` - (Optional) The label key that the selector applies to. * `operator` - (Optional) A key's relationship to a set of values. Valid operators ard `In`, `NotIn`, `Exists` and `DoesNotExist`. * `values` - (Optional) An array of string values. If the operator is `In` or `NotIn`, the values array must be non-empty. If the operator is `Exists` or `DoesNotExist`, the values array must be empty. This array is replaced during a strategic merge patch. ### `resources` #### Arguments * `limits` - (Optional) Map describing the maximum amount of compute resources allowed. More info: http://kubernetes.io/docs/user-guide/compute-resources/ * `requests` - (Optional) Map describing the minimum amount of compute resources required. If this is omitted for a container, it defaults to `limits` if that is explicitly specified, otherwise to an implementation-defined value. More info: http://kubernetes.io/docs/user-guide/compute-resources/ ### `selector` #### Arguments * `match_expressions` - (Optional) A list of label selector requirements. The requirements are ANDed. * `match_labels` - (Optional) A map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of `match_expressions`, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. ## Import Persistent Volume Claim can be imported using its name, e.g. ``` $ terraform import kubernetes_persistent_volume_claim.example example-name ```