Home > OS >  What does 'storage' means in Kubernetes CRD?
What does 'storage' means in Kubernetes CRD?

Time:10-16

There is a field in the CRD called 'storage'

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
spec:
      ...
      versions:
      - name: v1
        # Each version can be enabled/disabled by Served flag.
        served: true
        # One and only one version must be marked as the storage version.
        storage: true
      ...

What does this mean?
All the documentation says is the above comment:

 One and only one version must be marked as the storage version.

It just doesn't help at all.

CodePudding user response:

A k8s resource (including custom resource) can have support for multiple API versions (say v1beta1, v1, etc.) at once. It's there for various reasons such as API stability and backward compatibility.

As you know, on the creation of a resource's object, the k8s store it on persistent storage such as etcd. The version with storage: true indicates that this version should be used when persisting the resources to storage. It's inconvenient to store multiple copies of an object. That's why One and only one version must be marked as the storage version. On-demand of other versions with storage: false a conversion webhook should be used to toggle in-between versions with recommended schema changes and custom logic.

Ref:

  • Related