@@ -84,9 +84,10 @@ You can use the various validator attributes to customize your crd:
84
84
- ` Required ` : The field is listed in the required fields
85
85
- ` PreserveUnknownFields ` : Set the ` X-Kubernetes-Preserve-Unknown-Fields ` to ` true `
86
86
87
- _ NOTE on ` Description ` _ : if your project generates the XML documentation files
88
- for the result, the crd generator also searches for those files and a possible
89
- ` <summary> ` tag in the xml documentation. The attribute will take precedence though.
87
+ > [ !NOTE]
88
+ > For ` Description ` : if your project generates the XML documentation files
89
+ > for the result, the crd generator also searches for those files and a possible
90
+ > ` <summary> ` tag in the xml documentation. The attribute will take precedence though.
90
91
91
92
``` csharp
92
93
public class MappingSpec
@@ -101,4 +102,114 @@ In the example above, the text of the attribute will be used.
101
102
102
103
## Multi-Version Entities
103
104
104
- TODO
105
+ You can manage multiple versions of a CRD. To do this, you can
106
+ specify multiple classes as the "same" entity, but with different
107
+ versions.
108
+
109
+ To mark multiple entity classes as the same, use exactly the same
110
+ ` Kind ` , ` Group ` and ` PluralName ` and differ in the ` ApiVersion `
111
+ field.
112
+
113
+ ### Version priority
114
+
115
+ Sorting of the versions - and therefore determine which version should be
116
+ the ` storage version ` if no attribute is provided - is done by the kubernetes
117
+ rules of version sorting:
118
+
119
+ Priority is as follows:
120
+
121
+ 1 . General Availablility (i.e. ` V1Foobar ` , ` V2Foobar ` )
122
+ 2 . Beta Versions (i.e. ` V11Beta13Foobar ` , ` V2Beta1Foobar ` )
123
+ 3 . Alpha Versions (i.e. ` V16Alpha13Foobar ` , ` V2Alpha10Foobar ` )
124
+
125
+ The parsed version numbers are sorted by the highest first, this leads
126
+ to the following version priority:
127
+
128
+ ```
129
+ - v10
130
+ - v2
131
+ - v1
132
+ - v11beta2
133
+ - v10beta3
134
+ - v3beta1
135
+ - v12alpha1
136
+ - v11alpha2
137
+ ```
138
+
139
+ This can also be seen over at the
140
+ [ kubernetes documentation] ( https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definition-versioning/#version-priority ) .
141
+
142
+ ### Storage Version
143
+
144
+ To determine the storage version (of which one, and exactly one must exist)
145
+ the system uses the previously mentioned version priority to sort the versions
146
+ and picking the first one. To overwrite this behaviour, use the
147
+ < xref:KubeOps.Operator.Entities.Annotations.StorageVersionAttribute > .
148
+
149
+ > [ !WARNING]
150
+ > when multiple < xref:KubeOps.Operator.Entities.Annotations.StorageVersionAttribute >
151
+ > are used, the system will thrown an error.
152
+
153
+ To overwrite a version, annotate the entity class with the attribute.
154
+
155
+ ### Example
156
+
157
+ #### Normal multiversion entity
158
+
159
+ Note that the ` Kind `
160
+
161
+ ``` csharp
162
+ [KubernetesEntity (
163
+ ApiVersion = " v1" ,
164
+ Kind = " VersionedEntity" ,
165
+ Group = " kubeops.test.dev" ,
166
+ PluralName = " versionedentities" )]
167
+ public class V1VersionedEntity : CustomKubernetesEntity
168
+ {
169
+ }
170
+
171
+ [KubernetesEntity (
172
+ ApiVersion = " v1beta1" ,
173
+ Kind = " VersionedEntity" ,
174
+ Group = " kubeops.test.dev" ,
175
+ PluralName = " versionedentities" )]
176
+ public class V1Beta1VersionedEntity : CustomKubernetesEntity
177
+ {
178
+ }
179
+
180
+ [KubernetesEntity (
181
+ ApiVersion = " v1alpha1" ,
182
+ Kind = " VersionedEntity" ,
183
+ Group = " kubeops.test.dev" ,
184
+ PluralName = " versionedentities" )]
185
+ public class V1Alpha1VersionedEntity : CustomKubernetesEntity
186
+ {
187
+ }
188
+ ```
189
+
190
+ The resulting storage version would be ` V1VersionedEntity ` .
191
+
192
+ #### Overwritten storage version multiversion entity
193
+
194
+ ``` csharp
195
+ [KubernetesEntity (
196
+ ApiVersion = " v1" ,
197
+ Kind = " AttributeVersionedEntity" ,
198
+ Group = " kubeops.test.dev" ,
199
+ PluralName = " attributeversionedentities" )]
200
+ [StorageVersion ]
201
+ public class V1AttributeVersionedEntity : CustomKubernetesEntity
202
+ {
203
+ }
204
+
205
+ [KubernetesEntity (
206
+ ApiVersion = " v2" ,
207
+ Kind = " AttributeVersionedEntity" ,
208
+ Group = " kubeops.test.dev" ,
209
+ PluralName = " attributeversionedentities" )]
210
+ public class V2AttributeVersionedEntity : CustomKubernetesEntity
211
+ {
212
+ }
213
+ ```
214
+
215
+ The resulting storage version would be ` V1AttributeVersionedEntity ` .
0 commit comments