Pod Inline Volume Support
|Status||Min K8s Version||Max K8s Version|
Traditionally, volumes that are backed by CSI drivers can only be used with a
PersistentVolumeClaim object combination. This feature supports ephemeral storage use cases and allows CSI volumes to be specified directly in the pod specification. At runtime, nested inline volumes follow the ephemeral lifecycle of their associated pods where the driver handles all phases of volume operations as pods are created and destroyed.
See the design document for futher information.
Example of inline CSI pod spec
A pod spec with an ephemeral inline CSI volume. Note that because the volume is expected to be ephemeral, the volumeHandle is not provided. Instead, an ID will be generated by kubelet as volume is mounted for pod use. The generated ID is passed to the CSI driver at
apiVersion: v1 kind: Pod metadata: name: some-pod spec: containers: ... volumes: - name: vol csi: driver: inline.storage.kubernetes.io volumeAttributes: foo: bar
Implementing inline ephemeral support
Drivers must be modified (or implemented specifically) to support inline ephemeral workflows. When Kubernetes encounters an inline CSI volume embedded in a pod spec, it treats that volume differently. Mainly, the driver will only receive
NodePublish, during the volume's mount phase, and
NodeUnpublish when the pod is going away and the volume is unmounted. To support inline, a driver must implement the followings:
- Identity service
- Node service
Kubernetes 1.16 only allows using a CSI driver for an inline volume if
CSIDriverInfo object explicitly declares
that the driver supports that kind of usage in its
volumeLifecycleModes field. This is a safeguard against accidentally
using a driver the wrong way.
To use inline volume, Kubernetes 1.15 binaries must start with the
CSIInlineVolume feature gate enabled:
Kubernetes >= 1.16 no longer needs this as the feature is enabled by default.
- CSI Hostpath driver - an example driver that supports both modes and determines the mode on a case-by-case basis (for Kubernetes 1.16) or can be deployed with support for just one of the two modes (for Kubernetes 1.15).
- Image populator plugin - an example CSI driver plugin that uses a container image as a volume.