Skip to content

Commit 992d8d1

Browse files
jeanduplessisclaude
andcommitted
Clarify CRD versioning details based on review feedback
Address review comments from PR #539: - Clarify that Upjet does not generate default values in CRD schema - Fix statement about CRD generation (only latest version is generated) - Add distinction between storage version and hub version - Document SetCRDStorageVersion and SetCRDHubVersion configuration options 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent f1b38b0 commit 992d8d1

File tree

1 file changed

+33
-10
lines changed

1 file changed

+33
-10
lines changed

docs/managing-crd-versions.md

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@ version:
5757
- The existing version stays backward compatible
5858
- Old manifests continue to work without modification
5959

60-
2. **Optional Fields with Defaults**: New fields that have default values
61-
- Resources will function with or without the new field specified
60+
2. **Optional Fields with Defaults**: New fields that have default values in the
61+
Terraform provider schema
62+
- Note: Upjet does not generate default values in the CRD schema itself, even
63+
when defaults exist in the Terraform schema
64+
- Defaults are applied at runtime by the Terraform provider or cloud provider
65+
- Resources will function with or without the new field specified in the manifest
6266

6367
3. **Additional Enum Values**: Adding new allowed values to existing fields
6468
- Existing values remain valid
@@ -67,12 +71,16 @@ version:
6771

6872
### Non-Breaking Changes (Backward Compatible)
6973

70-
When new fields are **optional** or have **default values**, no version bump is
71-
necessary. The existing API version remains backward compatible because:
74+
When new fields are **optional** or have **default values in the Terraform
75+
provider schema**, no version bump is necessary. The existing API version
76+
remains backward compatible because:
7277

7378
- Old manifests that don't specify the new fields continue to work
74-
- The Terraform provider handles the absence of these fields gracefully
75-
- Late initialization can populate sensible defaults
79+
- The Terraform provider handles the absence of these fields gracefully at
80+
runtime (applying defaults when needed)
81+
- Late initialization can populate sensible defaults from the provider state
82+
- Note: While defaults exist in the Terraform schema, they are not reflected in
83+
the generated CRD schema itself
7684

7785
**Example**: Adding an optional `encryption_enabled` field to a database
7886
resource doesn't break existing manifests that don't specify this field.
@@ -146,9 +154,17 @@ func Configure(p *config.Provider) {
146154
```
147155

148156
This configuration will:
149-
1. Generate CRDs for all three versions: `v1alpha1`, `v1alpha2`, and `v1beta1`
150-
2. Mark `v1beta1` as the storage version (hub)
151-
3. Create conversion webhooks to translate between versions
157+
1. Generate the CRD for the latest version (`v1beta1`)
158+
2. Mark the previous versions (`v1alpha1`, `v1alpha2`) as served API versions
159+
3. Set `v1beta1` as both the storage version and hub version (by default, both
160+
are set to `r.Version`)
161+
4. Create conversion webhooks to translate between versions
162+
163+
**Note**: The storage version and hub version are different concepts, though by
164+
default both are set to `r.Version`. They can be configured independently using:
165+
- `SetCRDStorageVersion`: Configures which version is used for persistence
166+
- `SetCRDHubVersion`: Configures which version is used as the hub in the
167+
hub-and-spoke conversion pattern
152168

153169
## Conversion Strategies
154170

@@ -163,13 +179,20 @@ Kubernetes uses a "hub-and-spoke" conversion model:
163179
v1alpha1 ←→ v1beta1 (hub) ←→ v1alpha2
164180
```
165181

166-
- **Hub**: The storage version (usually the latest stable version)
182+
- **Hub**: The central version used for all conversions (by default set to
183+
`r.Version`, usually the latest stable version)
167184
- **Spokes**: Other versions that convert to/from the hub
185+
- **Storage Version**: The version used to persist objects in etcd (by default
186+
also set to `r.Version`, but can be configured separately)
168187

169188
All conversion happens through the hub version:
170189
- `v1alpha1``v1beta1``v1alpha2`
171190
- Never directly `v1alpha1``v1alpha2`
172191

192+
**Note**: While the hub version and storage version are often the same (both
193+
default to `r.Version`), they serve different purposes and can be configured
194+
independently if needed.
195+
173196
### API-Level Converters
174197

175198
Configure conversion functions for API schema changes:

0 commit comments

Comments
 (0)