You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/book/src/developers/development.md
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -507,6 +507,8 @@ To run E2E locally, set `AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET`, `AZURE_SUBSCRI
507
507
./scripts/ci-e2e.sh
508
508
```
509
509
510
+
Note: Users that have a restrictive environment and want to leverage API Server ILB in their flavors and to run e2e tests locally should refer to the detailed explanation in [running e2e tests locally leveraging apiserver ilb solution](./tilt-with-aks-as-mgmt-ilb.md#running-e2e-tests-locally-using-api-server-ilbs-networking-solution)
@@ -76,6 +77,158 @@ While the default Tilt setup recommends using a KIND cluster as the management c
76
77
- [apiserver-ilb](https://github.com/kubernetes-sigs/cluster-api-provider-azure/blob/main/templates/cluster-template-apiserver-ilb.yaml): VM-based default flavor that brings up native K8s clusters with Linux nodes.
77
78
- [apiserver-ilb-windows](https://github.com/kubernetes-sigs/cluster-api-provider-azure/blob/main/templates/cluster-template-windows-apiserver-ilb.yaml): VM-based flavor that brings up native K8s clusters with Linux and Windows nodes.
78
79
80
+
## Running e2e tests locally using API Server ILB's networking solution
81
+
82
+
Running an e2e test locally in a restricted environment calls for some workarounds in the prow templates and the e2e test itself.
83
+
84
+
1. We need to add the apiserver ILB with private endpoints and predeterimined CIDRs to the workload cluster's VNet & Subnets, and pre-kubeadm commands updating the `/etc/hosts` file of the nodes of the workload cluster.
85
+
86
+
2. Once the template has been modified to be run in local environment using AKS as management cluster, we need to be able to peer the vnets, create private DNS zone for the FQDN of the workload cluster and re-enable blocked NSG ports.
87
+
88
+
**Note:**
89
+
90
+
- The following guidance is only for debugging, and is not a recommendation for any production environment.
91
+
92
+
- The below steps are for self-managed templates only and do not apply to AKS workload clusters.
93
+
94
+
- If you are going to run the local tests from a dev machine in Azure, you will have to use user-assigned managed identity and assign it to the management cluster. Follow the below steps before proceeding.
95
+
1. Create a user-assigned managed identity
96
+
2. Assign that managed identity a contributor role to your subscription
97
+
3. Set `AZURE_CLIENT_ID_USER_ASSIGNED_IDENTITY`, `AZURE_OBJECT_ID_USER_ASSIGNED_IDENTITY`, and `AZURE_USER_ASSIGNED_IDENTITY_RESOURCE_ID` to the user-assigned managed identity.
98
+
99
+
#### Update prow template with apiserver ILB networking solution
100
+
101
+
There are three sections of a prow template that need an update.
102
+
103
+
1. AzureCluster
104
+
-`/spec/networkSpec/apiServerLB`
105
+
- Add FrontendIP
106
+
- Add an associated private IP to be leveraged by an internal ILB
107
+
-`/spec/networkSpec/vnet/cidrBlocks`
108
+
- Add VNet CIDR
109
+
-`/spec/networkSpec/subnets/0/cidrBlocks`
110
+
- Add Subnet CIDR for the control plane
111
+
-`/spec/networkSpec/subnets/1/cidrBlocks`
112
+
- Add Subnet CIDR for the worker node
113
+
2.`KubeadmConfigTemplate` - linux node; Identifiable by `name: .*-md-0`
114
+
-`/spec/template/spec/preKubeadmCommands/0`
115
+
- Add a prekubeadm command updating the `/etc/hosts` of worker nodes of type "linux".
116
+
3.`KubeadmConfigTemplate` - windows node; Identifiable by `name: .*-md-win`
117
+
-`/spec/template/spec/preKubeadmCommands/0`
118
+
- Add a prekubeadm command updating the `/etc/hosts` of worker nodes of type "windows".
119
+
120
+
A sample kustomize command for updating a prow template via its kustomization.yaml is pasted below.
#### Peer Vnets of the management cluster and the workload cluster
184
+
185
+
Peering VNets, creating a private DNS zone with the FQDN of the workload cluster, and updating NSGs of the management and workload clusters can be achieved by running `scripts/peer-vnets.sh`.
186
+
187
+
This script, `scripts/peer-vnets.sh`, should be run after triggering the test run locally and from a separate terminal.
188
+
189
+
#### Running the test locally
190
+
191
+
We recommend running each test individually while debugging the test failure. This implies that `GINKGO_FOCUS` is as unique as possible. So for instance if you want to run `periodic-cluster-api-provider-azure-e2e-main`'s "With 3 control-plane nodes and 2 Linux and 2 Windows worker nodes" test,
192
+
193
+
1. We first need to add the following environment variables to the test itself. For example:
The above lines should be added before the `clusterctl.ApplyClusterTemplateAndWait()` is invoked.
204
+
205
+
206
+
2. Open the terminal and run the below command:
207
+
208
+
```bash
209
+
GINKGO_FOCUS="With 3 control-plane nodes and 2 Linux and 2 Windows worker nodes" USE_LOCAL_KIND_REGISTRY=false SKIP_CLEANUP="true" SKIP_LOG_COLLECTION="true" REGISTRY="<>" MGMT_CLUSTER_TYPE="aks" EXP_APISERVER_ILB=true AZURE_LOCATION="<>" ARCH="amd64" scripts/ci-e2e.sh
210
+
```
211
+
212
+
**Note:**
213
+
214
+
- Set `MGMT_CLUSTER_TYPE` to `"aks"` to leverage `AKS` as the management cluster.
215
+
- Set `EXP_APISERVER_ILB` to `true` to enable the API Server ILB feature gate.
216
+
- Set `AZURE_CLIENT_ID_USER_ASSIGNED_IDENTITY`, `AZURE_OBJECT_ID_USER_ASSIGNED_IDENTITY` and `AZURE_USER_ASSIGNED_IDENTITY_RESOURCE_ID` to use the user-assigned managed identity instead of the AKS-created managed identity.
217
+
218
+
3. In a new terminal, wait for AzureClusters to be created by the above command. Check it using `kubectl get AzureClusters -A`. Note that this command will fail or will not output anything unless the above command, `GINKGO_FOCUS...`, has deployed the worker template and initiated workload cluster creation.
219
+
220
+
Once the worker cluster has been created, `export` the `CLUSTER_NAME` and `CLUSTER_NAMESPACE`.
221
+
It is recommended that `AZURE_INTERNAL_LB_PRIVATE_IP` is set an IP of `10.0.0.x`, say `10.0.0.101`, to avoid any test updates.
222
+
223
+
Then open a new terminal at the root of the cluster api provider azure repo and run the below command.
You will see that the test progresses in the first terminal window that invoked `GINKGO_FOCUS=....`
230
+
231
+
79
232
## Leveraging internal load balancer
80
233
81
234
By default using Tilt with Cluster API Provider Azure (CAPZ), the management cluster is exposed via a public endpoint. This works well for many development scenarios but presents challenges in environments with strict network security requirements.
@@ -127,4 +280,3 @@ By default using Tilt with Cluster API Provider Azure (CAPZ), the management clu
127
280
**Solution:**
128
281
- Use 3 control plane nodes in a stacked etcd setup.
129
282
- Using aks as management cluster sets `CONTROL_PLANE_MACHINE_COUNT` to 3 by default.
0 commit comments