This resource allows the user to request for and claim to a persistent volume.
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"
}
}
}
}
The following arguments are supported:
metadata
- (Required) Standard persistent volume claim's metadata. For more info see Kubernetes referencespec
- (Required) Spec defines the desired characteristics of a volume requested by a pod author. For more info see Kubernetes referencewait_until_bound
- (Optional) Whether to wait for the claim to reach Bound
state (to find volume in which to claim the space)metadata
annotations
- (Optional) An unstructured key value map stored with the persistent volume claim that may be used to store arbitrary metadata.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. For more info see Kubernetes referencelabels
- (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.name
- (Optional) Name of the persistent volume claim, must be unique. Cannot be updated. For more info see Kubernetes referencenamespace
- (Optional) Namespace defines the space within which name of the persistent volume claim must be unique.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. For more info see Kubernetes referenceuid
- The unique in time and space value for this persistent volume claim. For more info see Kubernetes referencespec
access_modes
- (Required) A set of the desired access modes the volume should have. For more info see Kubernetes referenceresources
- (Required) A list of the minimum resources the volume should have. For more info see Kubernetes referenceselector
- (Optional) A label query over volumes to consider for binding.volume_name
- (Optional) The binding reference to the PersistentVolume backing this claim.storage_class_name
- (Optional) Name of the storage class requested by the claim.volume_mode
- (Optional) Defines what type of volume is required by the claim. For more info see Kubernetes referencematch_expressions
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
limits
- (Optional) Map describing the maximum amount of compute resources allowed. For more info see Kubernetes referencerequests
- (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. For more info see Kubernetes referenceselector
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.Persistent Volume Claim can be imported using its namespace and name, e.g.
$ terraform import kubernetes_persistent_volume_claim.example default/example-name