# persistent-volume-claim

A PersistentVolumeClaim as its own cluster instance, with its StorageClass set explicitly or taken from the storageClasses dependency

This page is generated from [`kix/packages/stable/persistent-volume-claim`](https://github.com/kix-run/kix/tree/main/kix/packages/stable/persistent-volume-claim).

| | |
| --- | --- |
| Stability | Stable |
| `package` value | `packages.persistent-volume-claim` |
| Default aliases | `storage` |

## How-to guides

- [Provision persistent storage](/docs/how-to/package-task-guides/provision-persistent-storage/)

## Dependencies

Kix matches each dependency below to another package instance by instance name, alias, or role. To bind a specific instance, set [`deps.<name>`](/docs/reference/instances-and-composition/#deps) in your cluster definition. See [Declaring dependencies](/docs/reference/package-anatomy/#declaring-dependencies) for how required and optional dependencies work.

| Dependency | Requirement |
| --- | --- |
| `storageClasses` | Optional |

## Options

### `accessModes`

Access modes of the claim. `ReadWriteMany` and `ReadOnlyMany` need a
provisioner that supports shared mounts; the claim stays Pending
otherwise. `ReadWriteOncePod` cannot be combined with another mode.

- **Type:** `non-empty (list of (one of "ReadWriteOnce", "ReadOnlyMany", "ReadWriteMany", "ReadWriteOncePod"))`
- **Default:**

  ```nix
  [
    "ReadWriteOnce"
  ]
  ```

### `extraSpec`

Merged into the claim's `spec`, for fields without an option of their
own: `volumeMode`, `dataSource`, `dataSourceRef`, `selector`,
`volumeName`, and `volumeAttributesClassName`. `storageClassName`,
`accessModes`, and `resources.requests.storage` are set by their
options and refused here.

- **Type:** `attribute set of anything`
- **Default:** `{ }`
- **Example:** `{ volumeMode = "Block"; }`

### `size`

Requested capacity, as a Kubernetes quantity such as "20Gi"; an
integer is a number of bytes. Must be at least one byte.
Required: a generic claim cannot know how much its consumer stores.
Rendered as `spec.resources.requests.storage` and published as
`out.size`, both as strings. The apiserver accepts an increase only
when the class allows volume expansion, and refuses a decrease.

- **Type:** `Kubernetes quantity, such as "500m" or "1Gi" (a non-negative decimal or integer with an optional suffix m, k, M, G, T, P, E, Ki, Mi, Gi, Ti, Pi or Ei)`
- **Example:** `"20Gi"`

### `storageClassName`

StorageClass of the claim. Null takes `out.storageClassName` from the
`storageClasses` dependency. `""` requests no class, for binding to a
pre-provisioned PersistentVolume named in `extraSpec.volumeName`. The
apiserver refuses a change once the claim exists.

- **Type:** `null or string`
- **Default:** `null`
- **Example:** `"local-path-retain"`