Blog: Kubernetes 1.24: Volume Populators Graduate to Beta

Ben Swartzlander (NetApp)

The volume populators feature is now two releases old and entering beta! The AnyVolumeDataSouce feature
gate defaults to enabled in Kubernetes v1.24, which means that users can specify any custom resource
as the data source of a PVC.

An earlier blog article detailed how the
volume populators feature works. In short, a cluster administrator can install a CRD and
associated populator controller in the cluster, and any user who can create instances of
the CR can create pre-populated volumes by taking advantage of the populator.

Multiple populators can be installed side by side for different purposes. The SIG storage
community is already seeing some implementations in public, and more prototypes should
appear soon.

Cluster administrations are strongly encouraged to install the
volume-data-source-validator controller and associated VolumePopulator CRD before installing
any populators so that users can get feedback about invalid PVC data sources.

New Features

The lib-volume-populator library
on which populators are built now includes metrics to help operators monitor and detect
problems. This library is now beta and latest release is v1.0.1.

The volume data source validator
controller also has metrics support added, and is in beta. The VolumePopulator CRD is
beta and the latest release is v1.0.1.

Trying it out

To see how this works, you can install the sample “hello” populator and try it

First install the volume-data-source-validator controller.

kubectl apply -f
kubectl apply -f
kubectl apply -f

Next install the example populator.

kubectl apply -f
kubectl apply -f

Your cluster now has a new CustomResourceDefinition that provides a test API named Hello.
Create an instance of the Hello custom resource, with some text:

kind: Hello
 name: example-hello
 fileName: example.txt
 fileContents: Hello, world!

Create a PVC that refers to that CR as its data source.

apiVersion: v1
kind: PersistentVolumeClaim
 name: example-pvc
 - ReadWriteOnce
 storage: 10Mi
 kind: Hello
 name: example-hello
 volumeMode: Filesystem

Next, run a Job that reads the file in the PVC.

apiVersion: batch/v1
kind: Job
 name: example-job
 - name: example-container
 image: busybox:latest
 - cat
 - /mnt/example.txt
 - name: vol
 mountPath: /mnt
 restartPolicy: Never
 - name: vol
 claimName: example-pvc

Wait for the job to complete (including all of its dependencies).

kubectl wait --for=condition=Complete job/example-job

And last examine the log from the job.

kubectl logs job/example-job

The output should be:

Hello, world!

Note that the volume already contained a text file with the string contents from
the CR. This is only the simplest example. Actual populators can set up the volume
to contain arbitrary contents.

How to write your own volume populator

Developers interested in writing new poplators are encouraged to use the
lib-volume-populator library
and to only supply a small controller wrapper around the library, and a pod image
capable of attaching to volumes and writing the appropriate data to the volume.

Individual populators can be extremely generic such that they work with every type
of PVC, or they can do vendor specific things to rapidly fill a volume with data
if the volume was provisioned by a specific CSI driver from the same vendor, for
example, by communicating directly with the storage for that volume.

How can I learn more?

The enhancement proposal,
Volume Populators, includes lots of detail about the history and technical implementation
of this feature.

Volume populators and data sources, within the documentation topic about persistent volumes,
explains how to use this feature in your cluster.

Please get involved by joining the Kubernetes storage SIG to help us enhance this
feature. There are a lot of good ideas already and we’d be thrilled to have more!

Originally posted on Kubernetes – Production-Grade Container Orchestration

Deja una respuesta

Tu dirección de correo electrónico no será publicada.