Commit 22a8cb2
authored
refactor(bumpup): CAPI bumps to v1.12.x (#1488)
# v1beta1/v1beta2 Cluster API Testing - Commands and Output
---
## How Has This Been Tested?
This change has been tested in three ways: (1) unit tests for the
conversion utilities, (2) a bash integration script against a live CAPI
cluster, and (3) manual cluster creation and verification. Below are the
exact commands run and how to verify the results.
### 1. Unit tests (conversion utilities)
**Command:**
```bash
cd common && go test ./pkg/capi/utils/... -v -run 'TestConvert|TestConvertRoundtrip|TestConvertUpdateSimulation'
```
**Expected output:** All four tests should PASS:
- `TestConvertV1Beta1ClusterToV1Beta2`
- `TestConvertV1Beta2ClusterToV1Beta1`
- `TestConvertRoundtrip`
- `TestConvertUpdateSimulation`
**Verification:** Exit code 0; `PASS` for each test. Run from the repo
root or from `common/`.
---
### 2. Integration test script (live CAPI cluster)
**Prerequisites:**
- `kubectl` configured against a cluster with CAPI CRDs and conversion
webhooks
- ClusterClass `docker-quick-start` (or set `CLUSTER_CLASS` env var)
**Option A – Use an existing e2e bootstrap cluster** (after leaving it
running):
```bash
make e2e-test E2E_LABEL='provider:Docker' E2E_SKIP_CLEANUP=true
# After e2e finishes, KUBECONFIG points at the bootstrap cluster
./hack/test-v1beta1-v1beta2-cluster.sh v1beta-test
```
**Option B – Use a dev Kind cluster** (after deploying CAREN locally):
```bash
make dev.run-on-kind
eval $(make kind.kubeconfig)
./hack/test-v1beta1-v1beta2-cluster.sh v1beta-test
```
**What the script does:**
1. Creates a v1beta1 Cluster with `spec.topology.class:
docker-quick-start` and `version: v1.29.0`
2. Fetches the Cluster as v1beta2 and checks
`spec.topology.classRef.name` and `spec.topology.version`
3. Applies an updated v1beta1 manifest with `version: v1.30.0`
(simulates a GitOps update)
4. Confirms the v1beta2 resource now has `version: v1.30.0`
5. Cleans up the test Cluster and namespace
**Verification:** Script exits 0; log line `PASS: v1beta2 Cluster has
updated version: v1.30.0`.
---
### 3. Manual cluster creation and verification
**Create a management cluster and workload cluster** (from repo root):
```bash
make dev.run-on-kind
eval $(make kind.kubeconfig)
export CLUSTER_NAME=docker-cluster-capi112
export CLUSTER_FILE=examples/capi-quick-start/docker-cluster-cilium-helm-addon.yaml
export KUBERNETES_VERSION=v1.30.5
clusterctl generate cluster ${CLUSTER_NAME} \
--from ${CLUSTER_FILE} \
--kubernetes-version ${KUBERNETES_VERSION} \
--worker-machine-count 1 | \
kubectl apply --server-side -f -
```
**Wait for control plane and verify Cluster version:**
```bash
kubectl wait clusters/${CLUSTER_NAME} --for=condition=ControlPlaneInitialized --timeout=5m
kubectl get cluster ${CLUSTER_NAME} -o jsonpath='{.apiVersion}' && echo
kubectl get cluster ${CLUSTER_NAME} -o jsonpath='{.spec.topology.classRef.name}' && echo
```
**Expected:** The Cluster uses v1beta2 storage (or shows conversion);
`classRef.name` is set correctly. Runtime hooks process the Cluster
without errors.
**Cleanup:**
```bash
kubectl delete cluster ${CLUSTER_NAME}
make kind.delete
```
---
### 4. envtest limitation
The project’s envtest setup uses v1beta2-only storage and no conversion
webhooks, so:
- v1beta2 Cluster objects can be created and updated directly in envtest
- v1beta1 Cluster creation in envtest is not supported (no v1beta1 →
v1beta2 conversion)
- Full v1beta1 ↔ v1beta2 behavior is validated via unit tests and the
integration script against a real CAPI cluster
---
## 1. Conversion Unit Tests
### Command
```bash
cd common && go test ./pkg/capi/utils/... -v -run 'TestConvert|TestConvertRoundtrip|TestConvertUpdateSimulation'
```
### Output
```
=== RUN TestConvertV1Beta1ClusterToV1Beta2
=== PAUSE TestConvertV1Beta1ClusterToV1Beta2
=== RUN TestConvertV1Beta2ClusterToV1Beta1
=== PAUSE TestConvertV1Beta2ClusterToV1Beta1
=== RUN TestConvertRoundtrip
=== PAUSE TestConvertRoundtrip
=== RUN TestConvertUpdateSimulation
=== PAUSE TestConvertUpdateSimulation
=== CONT TestConvertV1Beta1ClusterToV1Beta2
=== CONT TestConvertRoundtrip
=== CONT TestConvertV1Beta2ClusterToV1Beta1
=== CONT TestConvertUpdateSimulation
--- PASS: TestConvertV1Beta1ClusterToV1Beta2 (0.00s)
--- PASS: TestConvertUpdateSimulation (0.00s)
--- PASS: TestConvertV1Beta2ClusterToV1Beta1 (0.00s)
--- PASS: TestConvertRoundtrip (0.00s)
PASS
ok github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/utils 1.656s
```
### Tests Coverage
| Test | Description |
|------|-------------|
| `TestConvertV1Beta1ClusterToV1Beta2` | Converts v1beta1 Cluster
(topology.class) → v1beta2 (topology.classRef) |
| `TestConvertV1Beta2ClusterToV1Beta1` | Converts v1beta2 → v1beta1 |
| `TestConvertRoundtrip` | v1beta1 → v1beta2 → v1beta1 roundtrip
preserves data |
| `TestConvertUpdateSimulation` | Simulates GitOps update: change
v1beta1, convert to v1beta2, verify change reflects |
---
## 2. Example v1beta1 Cluster (Input)
```yaml
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
name: test-cluster
namespace: default
spec:
topology:
class: docker-quick-start # v1beta1: string
version: v1.30.0
controlPlane:
replicas: 3
```
---
## 3. Resulting v1beta2 Cluster (Storage Representation)
When the above v1beta1 Cluster is applied to a cluster with CAPI CRDs
(and conversion webhooks), the API server converts it for storage. The
equivalent v1beta2 representation:
```yaml
apiVersion: cluster.x-k8s.io/v1beta2
kind: Cluster
metadata:
name: test-cluster
namespace: default
spec:
topology:
classRef: # v1beta2: object
name: docker-quick-start
version: v1.30.0
controlPlane:
replicas: 3
```
**Key difference:** v1beta1 uses `spec.topology.class` (string); v1beta2
uses `spec.topology.classRef.name` (object reference). CAPI conversion
handles this automatically at API boundaries.
---
## 4. GitOps Update Flow
1. **Create** v1beta1 Cluster (version v1.29.0)
2. **Read** stored resource as v1beta2 → has `classRef` and version
v1.29.0
3. **Update** v1beta1 manifest (version v1.30.0) and apply
4. **Verify** v1beta2 reflects the change (version v1.30.0)
The conversion logic ensures that when you update the v1beta1 manifest
and apply, the underlying stored object (v1beta2) is updated correctly.
---
## 5. Integration Test Script
Run against a CAPI-enabled cluster:
```bash
./hack/test-v1beta1-v1beta2-cluster.sh [NAMESPACE]
```
**Prerequisites:**
- `kubectl` pointing to a cluster with CAPI CRDs and conversion webhooks
- ClusterClass `docker-quick-start` (or set `CLUSTER_CLASS` env var)
**Sample run (no cluster available):**
```
[18:17:20] === v1beta1/v1beta2 Cluster API Version Test ===
[18:17:20] Namespace: v1beta-test
[18:17:20] Cluster: v1beta-test-cluster
[18:17:20] ClusterClass: docker-quick-start
error: error validating "STDIN": error validating data: failed to download openapi: ...
```
*(Failure expected when no cluster is configured.)*
**What it does:**
1. Creates a v1beta1 Cluster
2. Fetches it as v1beta2
3. Updates the v1beta1 manifest (version change)
4. Verifies v1beta2 reflects the update
5. Cleans up
---
## 6. envtest Note
The project's envtest environment uses **v1beta2-only storage** (no
conversion webhooks). Therefore:
- You can create/update v1beta2 Cluster objects directly in envtest
- v1beta1 Cluster creation would fail in envtest (no v1beta1 → v1beta2
conversion)
- Full v1beta1 ↔ v1beta2 behavior is exercised in real CAPI clusters or
via the conversion unit tests above
---
## 7. Conversion Utilities
Located in `common/pkg/capi/utils/utils.go`:
```go
// ConvertV1Beta1ClusterToV1Beta2 - used by runtime hooks when receiving v1beta1 requests
func ConvertV1Beta1ClusterToV1Beta2(src *clusterv1beta1.Cluster) (*clusterv1beta2.Cluster, error)
// ConvertV1Beta2ClusterToV1Beta1 - reverse conversion
func ConvertV1Beta2ClusterToV1Beta1(src *clusterv1beta2.Cluster) (*clusterv1beta1.Cluster, error)
```
These are used by lifecycle handlers (CCM, CSI, CNI, registry, etc.)
when the CAPI runtime hooks receive v1beta1 Cluster in requests; they
convert to v1beta2 for internal processing.1 parent dd5bf9a commit 22a8cb2
File tree
406 files changed
+7323
-4594
lines changed- api
- external
- github.com/nutanix-cloud-native/cluster-api-provider-nutanix/api/v1beta1
- sigs.k8s.io
- cluster-api-addon-provider-helm/api/v1alpha1
- cluster-api-provider-aws/v2
- api/v1beta2
- bootstrap/eks/api/v1beta2
- controlplane/eks/api/v1beta2
- v1alpha1
- crds
- variables
- charts/cluster-api-runtime-extensions-nutanix
- defaultclusterclasses
- templates
- csi/aws-ebs/manifests
- cmd
- common
- pkg
- capi
- clustertopology
- handlers
- lifecycle
- mutation
- patches
- matchers
- selectors
- variables
- utils
- server
- testutils
- capitest
- request
- openapi
- examples/capi-quick-start
- hack
- addons/helm-chart-bundler
- examples
- bases
- aws/cluster
- docker
- clusterclass
- cluster
- eks/cluster
- nutanix/cluster
- overlays/clusterclasses
- aws
- docker
- eks
- nutanix
- patches/nutanix
- flakes
- third-party
- caaph
- capa
- capx
- tools
- clusterclass-v1beta2
- fetch-images
- internal/test
- builder
- envtest
- request
- make
- pkg
- controllers
- enforceclusterautoscalerlimits
- failuredomainrollout
- namespacesync
- handlers
- aws
- clusterconfig
- mutation
- ami
- cni/calico
- controlplaneloadbalancer
- iaminstanceprofile
- identityref
- instancetype
- network
- placementgroupnfd
- placementgroup
- region
- securitygroups
- tags
- volumes
- workerconfig
- docker
- clusterconfig
- mutation/customimage
- workerconfig
- eks
- clusterconfig
- mutation
- ami
- iaminstanceprofile
- identityref
- instancetype
- network
- placementgroupnfd
- placementgroup
- region
- securitygroups
- tags
- testutils
- volumes
- workerconfig
- generic
- clusterconfig
- mutation
- generic
- httpproxy
- imageregistries/credentials
- kubeproxymode
- mirrors
- ntp
- taints
- users
- kubeadm
- auditpolicy
- autorenewcerts
- containerdapplypatchesandrestart
- containerdmetrics
- containerdunprivilegedports
- controlplanevirtualip
- providers
- coredns
- encryptionatrest
- etcd
- externalcloudprovider
- extraapiservercertsans
- kubernetesimagerepository
- noderegistration
- parallelimagepulls
- lifecycle
- addons
- ccm
- aws
- nutanix
- clusterautoscaler
- cni
- calico
- cilium
- multus
- cosi
- csi
- awsebs
- localpath
- nutanix
- snapshotcontroller
- utils
- ingress/awsloadbalancercontroller
- konnectoragent
- nfd
- registry
- cncfdistribution
- syncer
- utils
- servicelbgc
- serviceloadbalancer
- metallb
- nutanix
- clusterconfig
- mutation
- controlplaneendpoint
- controlplanefailuredomains
- machinedetails
- prismcentralendpoint
- workerconfig
- utils
- v4/generic/mutation/auditpolicy
- webhook
- addons/registry
- cluster
- preflight
- generic
- nutanix
- skip
- test
- e2e
- framework
- helpers
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
406 files changed
+7323
-4594
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
68 | | - | |
| 67 | + | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
154 | 158 | | |
155 | 159 | | |
156 | 160 | | |
| |||
Lines changed: 169 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
Lines changed: 16 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
31 | | - | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
38 | | - | |
| 40 | + | |
39 | 41 | | |
40 | 42 | | |
41 | | - | |
| 43 | + | |
42 | 44 | | |
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
46 | 51 | | |
47 | 52 | | |
48 | 53 | | |
49 | 54 | | |
50 | | - | |
| 55 | + | |
51 | 56 | | |
52 | 57 | | |
53 | 58 | | |
54 | 59 | | |
55 | 60 | | |
56 | 61 | | |
57 | | - | |
58 | | - | |
59 | | - | |
| 62 | + | |
| 63 | + | |
60 | 64 | | |
61 | 65 | | |
62 | | - | |
63 | 66 | | |
64 | 67 | | |
65 | 68 | | |
66 | 69 | | |
67 | 70 | | |
68 | | - | |
| 71 | + | |
69 | 72 | | |
70 | 73 | | |
71 | 74 | | |
72 | 75 | | |
73 | | - | |
| 76 | + | |
74 | 77 | | |
75 | 78 | | |
76 | 79 | | |
| |||
81 | 84 | | |
82 | 85 | | |
83 | 86 | | |
84 | | - | |
| 87 | + | |
85 | 88 | | |
86 | 89 | | |
87 | 90 | | |
88 | 91 | | |
89 | 92 | | |
90 | 93 | | |
91 | | - | |
| 94 | + | |
92 | 95 | | |
93 | 96 | | |
94 | 97 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
| |||
69 | 71 | | |
70 | 72 | | |
71 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
72 | 77 | | |
73 | 78 | | |
74 | 79 | | |
75 | 80 | | |
| 81 | + | |
76 | 82 | | |
77 | 83 | | |
78 | 84 | | |
| |||
Lines changed: 37 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
| 97 | + | |
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
106 | 121 | | |
107 | 122 | | |
108 | 123 | | |
| |||
156 | 171 | | |
157 | 172 | | |
158 | 173 | | |
159 | | - | |
| 174 | + | |
160 | 175 | | |
161 | 176 | | |
162 | 177 | | |
163 | 178 | | |
164 | | - | |
| 179 | + | |
165 | 180 | | |
166 | 181 | | |
167 | 182 | | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
168 | 199 | | |
169 | 200 | | |
170 | 201 | | |
| |||
0 commit comments