1

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.

1 Answer 1

3

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:

2
  • You mean that if we have CRDv1 and CRDv2. The latter is the storage. Then we create a resource for V1 then it will be converted to V2 then stored as V2? I thought all the versions have its own separate lifecycle.
    – beatrice
    Oct 14, 2021 at 7:59
  • 1
    Yes, it will be. From the user's perspective, you will always get your desired version. Oct 14, 2021 at 8:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.