Add documentation of PV/PVC.storageClassName

This commit is contained in:
Jan Safranek
2017-03-06 09:36:05 +01:00
committed by Andrew Chen
parent 3be8f7493a
commit 146af29a90
+30 -31
View File
@@ -132,14 +132,13 @@ Each PV contains a spec and status, which is the specification and status of the
kind: PersistentVolume kind: PersistentVolume
metadata: metadata:
name: pv0003 name: pv0003
annotations:
volume.beta.kubernetes.io/storage-class: "slow"
spec: spec:
capacity: capacity:
storage: 5Gi storage: 5Gi
accessModes: accessModes:
- ReadWriteOnce - ReadWriteOnce
persistentVolumeReclaimPolicy: Recycle persistentVolumeReclaimPolicy: Recycle
storageClassName: slow
nfs: nfs:
path: /tmp path: /tmp
server: 172.17.0.2 server: 172.17.0.2
@@ -193,13 +192,14 @@ In the CLI, the access modes are abbreviated to:
### Class ### Class
A PV can have a class, which is specified by setting the A PV can have a class, which is specified by setting the
`volume.beta.kubernetes.io/storage-class` annotation to the name of a `storageClassName` attribute to the name of a
`StorageClass`. A PV of a particular class can only be bound to PVCs requesting `StorageClass`. A PV of a particular class can only be bound to PVCs requesting
that class. A PV with no annotation or its class annotation set to `""` has no that class. A PV with no `storageClassName` has no class and can only be bound
class and can only be bound to PVCs that request no particular class. to PVCs that request no particular class.
In the future after beta, the `volume.beta.kubernetes.io/storage-class` In the past, the annotation `volume.beta.kubernetes.io/storage-class` was used instead
annotation will become an attribute. of the `storageClassName` attribute. This annotation is still working, however
it will become fully deprecated in a future Kubernetes release.
### Reclaim Policy ### Reclaim Policy
@@ -231,14 +231,13 @@ kind: PersistentVolumeClaim
apiVersion: v1 apiVersion: v1
metadata: metadata:
name: myclaim name: myclaim
annotations:
volume.beta.kubernetes.io/storage-class: "slow"
spec: spec:
accessModes: accessModes:
- ReadWriteOnce - ReadWriteOnce
resources: resources:
requests: requests:
storage: 8Gi storage: 8Gi
storageClassName: slow
selector: selector:
matchLabels: matchLabels:
release: "stable" release: "stable"
@@ -266,20 +265,20 @@ All of the requirements, from both `matchLabels` and `matchExpressions` are ANDe
### Class ### Class
A claim can request a particular class by specifying the name of a A claim can request a particular class by specifying the name of a
`StorageClass`using the annotation `volume.beta.kubernetes.io/storage-class`. `StorageClass` using the attribute `storageClassName`.
Only PVs of the requested class, ones with the same annotation as the PVC, can Only PVs of the requested class, ones with the same `storageClassName` as the PVC, can
be bound to the PVC. be bound to the PVC.
PVCs don't necessarily have to request a class. A PVC with its annotation set PVCs don't necessarily have to request a class. A PVC with its `storageClasName` set
equal to `""` is always interpreted to be requesting a PV with no class, so it equal to `""` is always interpreted to be requesting a PV with no class, so it
can only be bound to PVs with no class (no annotation or one set equal to can only be bound to PVs with no class (no annotation or one set equal to
`""`). A PVC with no annotation is not quite the same and is treated differently `""`). A PVC with no `storageClassName` is not quite the same and is treated differently
by the cluster depending on whether the by the cluster depending on whether the
[`DefaultStorageClass` admission plugin](/docs/admin/admission-controllers/#defaultstorageclass) [`DefaultStorageClass` admission plugin](/docs/admin/admission-controllers/#defaultstorageclass)
is turned on. is turned on.
* If the admission plugin is turned on, the administrator may specify a * If the admission plugin is turned on, the administrator may specify a
default `StorageClass`. All PVCs that have no annotation can be bound only to default `StorageClass`. All PVCs that have no `storageClassName` can be bound only to
PVs of that default. Specifying a default `StorageClass` is done by setting the PVs of that default. Specifying a default `StorageClass` is done by setting the
annotation `storageclass.beta.kubernetes.io/is-default-class` equal to "true" in annotation `storageclass.beta.kubernetes.io/is-default-class` equal to "true" in
a `StorageClass` object. If the administrator does not specify a default, the a `StorageClass` object. If the administrator does not specify a default, the
@@ -287,17 +286,18 @@ cluster responds to PVC creation as if the admission plugin were turned off. If
more than one default is specified, the admission plugin forbids the creation of more than one default is specified, the admission plugin forbids the creation of
all PVCs. all PVCs.
* If the admission plugin is turned off, there is no notion of a default * If the admission plugin is turned off, there is no notion of a default
`StorageClass`. All PVCs that have no annotation can be bound only to PVs that `StorageClass`. All PVCs that have no `storageClassName` can be bound only to PVs that
have no class. In this case the PVCs that have no annotation are treated the have no class. In this case, the PVCs that have no `storageClassName` are treated the
same way as PVCs that have their annotation set to `""`. same way as PVCs that have their `storageClassName` set to `""`.
When a PVC specifies a `selector` in addition to requesting a `StorageClass`, When a PVC specifies a `selector` in addition to requesting a `StorageClass`,
the requirements are ANDed together: only a PV of the requested class and with the requirements are ANDed together: only a PV of the requested class and with
the requested labels may be bound to the PVC. Note that currently, a PVC with a the requested labels may be bound to the PVC. Note that currently, a PVC with a
non-empty `selector` can't have a PV dynamically provisioned for it. non-empty `selector` can't have a PV dynamically provisioned for it.
In the future after beta, the `volume.beta.kubernetes.io/storage-class` In the past, the annotation `volume.beta.kubernetes.io/storage-class` was used instead
annotation will become an attribute. of `storageClassName` attribute. This annotation is still working, however
it won't be supported in a future Kubernetes release.
## Claims As Volumes ## Claims As Volumes
@@ -343,7 +343,7 @@ for details.
```yaml ```yaml
kind: StorageClass kind: StorageClass
apiVersion: storage.k8s.io/v1beta1 apiVersion: storage.k8s.io/v1
metadata: metadata:
name: standard name: standard
provisioner: kubernetes.io/aws-ebs provisioner: kubernetes.io/aws-ebs
@@ -353,8 +353,7 @@ parameters:
### Provisioner ### Provisioner
Storage classes have a provisioner that determines what volume plugin is used Storage classes have a provisioner that determines what volume plugin is used
for provisioning PVs. This field must be specified. During beta, the available for provisioning PVs. This field must be specified.
provisioner types are `kubernetes.io/aws-ebs` and `kubernetes.io/gce-pd`.
### Parameters ### Parameters
Storage classes have parameters that describe volumes belonging to the storage Storage classes have parameters that describe volumes belonging to the storage
@@ -367,7 +366,7 @@ used.
```yaml ```yaml
kind: StorageClass kind: StorageClass
apiVersion: storage.k8s.io/v1beta1 apiVersion: storage.k8s.io/v1
metadata: metadata:
name: slow name: slow
provisioner: kubernetes.io/aws-ebs provisioner: kubernetes.io/aws-ebs
@@ -387,7 +386,7 @@ parameters:
```yaml ```yaml
kind: StorageClass kind: StorageClass
apiVersion: storage.k8s.io/v1beta1 apiVersion: storage.k8s.io/v1
metadata: metadata:
name: slow name: slow
provisioner: kubernetes.io/gce-pd provisioner: kubernetes.io/gce-pd
@@ -402,7 +401,7 @@ parameters:
#### Glusterfs #### Glusterfs
```yaml ```yaml
apiVersion: storage.k8s.io/v1beta1 apiVersion: storage.k8s.io/v1
kind: StorageClass kind: StorageClass
metadata: metadata:
name: slow name: slow
@@ -430,7 +429,7 @@ parameters:
```yaml ```yaml
kind: StorageClass kind: StorageClass
apiVersion: storage.k8s.io/v1beta1 apiVersion: storage.k8s.io/v1
metadata: metadata:
name: gold name: gold
provisioner: kubernetes.io/cinder provisioner: kubernetes.io/cinder
@@ -446,7 +445,7 @@ parameters:
```yaml ```yaml
kind: StorageClass kind: StorageClass
apiVersion: storage.k8s.io/v1beta1 apiVersion: storage.k8s.io/v1
metadata: metadata:
name: fast name: fast
provisioner: kubernetes.io/vsphere-volume provisioner: kubernetes.io/vsphere-volume
@@ -459,7 +458,7 @@ parameters:
#### Ceph RBD #### Ceph RBD
```yaml ```yaml
apiVersion: storage.k8s.io/v1beta1 apiVersion: storage.k8s.io/v1
kind: StorageClass kind: StorageClass
metadata: metadata:
name: fast name: fast
@@ -488,7 +487,7 @@ parameters:
#### Quobyte #### Quobyte
```yaml ```yaml
apiVersion: storage.k8s.io/v1beta1 apiVersion: storage.k8s.io/v1
kind: StorageClass kind: StorageClass
metadata: metadata:
name: slow name: slow
@@ -520,7 +519,7 @@ parameters:
```yaml ```yaml
kind: StorageClass kind: StorageClass
apiVersion: storage.k8s.io/v1beta1 apiVersion: storage.k8s.io/v1
metadata: metadata:
name: slow name: slow
provisioner: kubernetes.io/azure-disk provisioner: kubernetes.io/azure-disk
@@ -547,7 +546,7 @@ and need persistent storage, we recommend that you use the following pattern:
- If the user provides a storage class name, and the cluster is version 1.4 or newer, put that value into the `volume.beta.kubernetes.io/storage-class` annotation of the PVC. - If the user provides a storage class name, and the cluster is version 1.4 or newer, put that value into the `volume.beta.kubernetes.io/storage-class` annotation of the PVC.
This will cause the PVC to match the right storage class if the cluster has StorageClasses enabled by the admin. This will cause the PVC to match the right storage class if the cluster has StorageClasses enabled by the admin.
- If the user does not provide a storage class name or the cluster is version 1.3, then instead put a `volume.alpha.kubernetes.io/storage-class: default` annotation on the PVC. - If the user does not provide a storage class name or the cluster is version 1.3, then instead put a `volume.alpha.kubernetes.io/storage-class: default` annotation on the PVC.
- This will cause a PV to be automatically provisioned for the user with sane default characteristics on some clusters. - This will cause a PV to be automatically provisioned for the user with sane default characteristics on some clusters.
- Despite the word `alpha` in the name, the code behind this annotation has `beta` level support. - Despite the word `alpha` in the name, the code behind this annotation has `beta` level support.
- Do not use `volume.beta.kubernetes.io/storage-class:` with any value including the empty string since it will prevent DefaultStorageClass admission controller - Do not use `volume.beta.kubernetes.io/storage-class:` with any value including the empty string since it will prevent DefaultStorageClass admission controller
from running if enabled. from running if enabled.