Skip to content

Commit 6ea4200

Browse files
authored
Merge pull request #37267 from porridge/porridge/fix-27534
Improve CRD version conversion description
2 parents af94630 + 270c680 commit 6ea4200

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

content/en/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definition-versioning.md

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ spec:
356356

357357
### Version removal
358358

359-
An older API version cannot be dropped from a CustomResourceDefinition manifest until existing persisted data has been migrated to the newer API version for all clusters that served the older version of the custom resource, and the old version is removed from the `status.storedVersions` of the CustomResourceDefinition.
359+
An older API version cannot be dropped from a CustomResourceDefinition manifest until existing stored data has been migrated to the newer API version for all clusters that served the older version of the custom resource, and the old version is removed from the `status.storedVersions` of the CustomResourceDefinition.
360360

361361
```yaml
362362
apiVersion: apiextensions.k8s.io/v1
@@ -1021,42 +1021,54 @@ Example of a response from a webhook indicating a conversion request failed, wit
10211021

10221022
## Writing, reading, and updating versioned CustomResourceDefinition objects
10231023

1024-
When an object is written, it is persisted at the version designated as the
1024+
When an object is written, it is stored at the version designated as the
10251025
storage version at the time of the write. If the storage version changes,
10261026
existing objects are never converted automatically. However, newly-created
10271027
or updated objects are written at the new storage version. It is possible for an
10281028
object to have been written at a version that is no longer served.
10291029

1030-
When you read an object, you specify the version as part of the path. If you
1031-
specify a version that is different from the object's persisted version,
1032-
Kubernetes returns the object to you at the version you requested, but the
1033-
persisted object is neither changed on disk, nor converted in any way
1034-
(other than changing the `apiVersion` string) while serving the request.
1030+
When you read an object, you specify the version as part of the path.
10351031
You can request an object at any version that is currently served.
1032+
If you specify a version that is different from the object's stored version,
1033+
Kubernetes returns the object to you at the version you requested, but the
1034+
stored object is not changed on disk.
1035+
1036+
What happens to the object that is being returned while serving the read
1037+
request depends on what is specified in the CRD's `spec.conversion`:
1038+
- if the default `strategy` value `None` is specified, the only modifications
1039+
to the object are changing the `apiVersion` string and perhaps [pruning
1040+
unknown fields](/docs/concepts/extend-kubernetes/api-extension/custom-resources/custom-resource-definitions/#field-pruning)
1041+
(depending on the configuration). Note that this is unlikely to lead to good
1042+
results if the schemas differ between the storage and requested version.
1043+
In particular, you should not use this strategy if the same data is
1044+
represented in different fields between versions.
1045+
- if [webhook conversion](#webhook-conversion) is specified, then this
1046+
mechanism controls the conversion.
10361047

10371048
If you update an existing object, it is rewritten at the version that is
10381049
currently the storage version. This is the only way that objects can change from
10391050
one version to another.
10401051

10411052
To illustrate this, consider the following hypothetical series of events:
10421053

1043-
1. The storage version is `v1beta1`. You create an object. It is persisted in
1044-
storage at version `v1beta1`
1054+
1. The storage version is `v1beta1`. You create an object. It is stored at version `v1beta1`
10451055
2. You add version `v1` to your CustomResourceDefinition and designate it as
1046-
the storage version.
1056+
the storage version. Here the schemas for `v1` and `v1beta1` are identical,
1057+
which is typically the case when promoting an API to stable in the
1058+
Kubernetes ecosystem.
10471059
3. You read your object at version `v1beta1`, then you read the object again at
10481060
version `v1`. Both returned objects are identical except for the apiVersion
10491061
field.
1050-
4. You create a new object. It is persisted in storage at version `v1`. You now
1062+
4. You create a new object. It is stored at version `v1`. You now
10511063
have two objects, one of which is at `v1beta1`, and the other of which is at
10521064
`v1`.
1053-
5. You update the first object. It is now persisted at version `v1` since that
1065+
5. You update the first object. It is now stored at version `v1` since that
10541066
is the current storage version.
10551067

10561068
### Previous storage versions
10571069

10581070
The API server records each version which has ever been marked as the storage
1059-
version in the status field `storedVersions`. Objects may have been persisted
1071+
version in the status field `storedVersions`. Objects may have been stored
10601072
at any version that has ever been designated as a storage version. No objects
10611073
can exist in storage at a version that has never been a storage version.
10621074

0 commit comments

Comments
 (0)