Skip to content

Commit 3e4da28

Browse files
Convert flavor and test ci templates to external cloud-provider
1 parent 4ad2d72 commit 3e4da28

File tree

102 files changed

+1779
-7271
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+1779
-7271
lines changed

Tiltfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ def deploy_worker_templates(template, substitutions):
365365
else:
366366
calico_values = "./templates/addons/calico/values.yaml"
367367
flavor_cmd += "; " + helm_cmd + " repo add projectcalico https://docs.tigera.io/calico/charts; " + helm_cmd + " --kubeconfig ./${CLUSTER_NAME}.kubeconfig install calico projectcalico/tigera-operator -f " + calico_values + " --namespace tigera-operator --create-namespace"
368-
if "external-cloud-provider" in flavor_name:
368+
if "intree-cloud-provider" not in flavor_name and "ipv6" not in flavor_name: # TODO: remove ipv6 once https://github.com/kubernetes-sigs/cloud-provider-azure/issues/3401 is fixed.
369369
flavor_cmd += "; " + helm_cmd + " --kubeconfig ./${CLUSTER_NAME}.kubeconfig install --repo https://raw.githubusercontent.com/kubernetes-sigs/cloud-provider-azure/master/helm/repo cloud-provider-azure --generate-name --set infra.clusterName=${CLUSTER_NAME}"
370370
local_resource(
371371
name = flavor_name,

docs/book/src/developers/kubernetes-developers.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,11 @@ $ export CNM_IMAGE_NAME=azure-node-controller-manager
4444
$ export IMAGE_TAG=canary
4545
```
4646

47-
Then, use the `external-cloud-provider` flavor to create a cluster:
47+
Then, create a cluster:
4848

4949
```bash
5050
$ export CLUSTER_NAME=my-cluster
51-
$ CLUSTER_TEMPLATE=cluster-template-external-cloud-provider.yaml \
52-
make create-workload-cluster
51+
$ make create-workload-cluster
5352
```
5453

5554
Once your cluster deploys, you should receive the kubeconfig to the workload cluster. Set your `KUBECONFIG` environment variable to point to the kubeconfig file, then use the official cloud-provider-azure Helm chart to deploy the cloud-provider-azure components using your custom built images:

docs/book/src/topics/addons.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ kubectl apply -f kube-flannel.yml
149149

150150
# External Cloud Provider
151151

152-
To deploy a cluster using [external cloud provider](https://github.com/kubernetes-sigs/cloud-provider-azure), create a cluster configuration with the [external cloud provider template](https://raw.githubusercontent.com/kubernetes-sigs/cluster-api-provider-azure/main/templates/cluster-template-external-cloud-provider.yaml).
152+
The "external" or "out-of-tree" cloud provider for Azure is the recommended cloud provider for CAPZ clusters. The "in-tree" cloud provider has been deprecated since v1.20 and only bug fixes are allowed in its Kubernetes repository directory.
153153

154-
After the cluster has provisioned, install the `cloud-provider-azure` components using the official helm chart:
154+
Below are instructions to install [external cloud provider](https://github.com/kubernetes-sigs/cloud-provider-azure) components on a self-managed cluster using the official helm chart. For more information see the official [`cloud-provider-azure` helm chart documentation](https://github.com/kubernetes-sigs/cloud-provider-azure/tree/master/helm/cloud-provider-azure).
155155

156156
Grab the CIDR ranges from your cluster by running this kubectl statement against the management cluster:
157157

@@ -180,7 +180,7 @@ kube-system cloud-node-manager-mfsdg
180180
kube-system cloud-node-manager-qrz74 1/1 Running 0 24s
181181
```
182182

183-
For more information see the official [`cloud-provider-azure` helm chart documentation](https://github.com/kubernetes-sigs/cloud-provider-azure/tree/master/helm/cloud-provider-azure).
183+
To know more about configuring cloud-provider-azure, see [Configuring the Kubernetes Cloud Provider for Azure](./cloud-provider-config.md).
184184

185185
## Storage Drivers
186186

docs/book/src/topics/machinepools.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ which provides the cloud provider-specific resource for orchestrating a group of
4242

4343
Azure Virtual Machine Scale Sets support two orchestration modes: `Uniform` and `Flexible`. CAPZ defaults to `Uniform` mode. See [VMSS Orchestration modes in Azure](https://learn.microsoft.com/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-orchestration-modes) for more information.
4444

45-
To use `Flexible` mode requires Kubernetes v1.26.0 or later with a workload cluster template like CAPZ's "external-cloud-provider-machinepool" flavor. Ensure that `orchestrationMode` on the `AzureMachinePool` spec is set:
45+
To use `Flexible` mode requires Kubernetes v1.26.0 or later. Ensure that `orchestrationMode` on the `AzureMachinePool` spec is set:
4646

4747
```yaml
4848
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
@@ -190,8 +190,5 @@ spec:
190190
permissions: "0644"
191191
joinConfiguration:
192192
nodeRegistration:
193-
kubeletExtraArgs:
194-
cloud-config: /etc/kubernetes/azure.json
195-
cloud-provider: azure
196193
name: '{{ ds.meta_data["local_hostname"] }}'
197194
```

hack/util.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ capz::util::should_build_kubernetes() {
4141
echo "false"
4242
}
4343

44+
capz::util::should_build_ccm() {
45+
if [[ -n "${TEST_CCM:-}" ]]; then
46+
echo "true" && return
47+
fi
48+
if [[ "${E2E_ARGS:-}" == "-kubetest.use-ci-artifacts" ]]; then
49+
echo "true" && return
50+
fi
51+
echo "false"
52+
}
53+
4454
# all test regions must support AvailabilityZones
4555
capz::util::get_random_region() {
4656
local REGIONS=("canadacentral" "eastus" "eastus2" "northeurope" "uksouth" "westeurope" "westus2" "westus3")

scripts/ci-conformance.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ else
5555
export KUBE_BUILD_CONFORMANCE="y"
5656
source "${REPO_ROOT}/scripts/ci-build-kubernetes.sh"
5757
fi
58+
59+
if [[ "$(capz::util::should_build_ccm)" == "true" ]]; then
60+
# shellcheck source=scripts/ci-build-azure-ccm.sh
61+
source "${REPO_ROOT}/scripts/ci-build-azure-ccm.sh"
62+
echo "Will use the ${IMAGE_REGISTRY}/${CCM_IMAGE_NAME}:${IMAGE_TAG} cloud-controller-manager image for external cloud-provider-cluster"
63+
echo "Will use the ${IMAGE_REGISTRY}/${CNM_IMAGE_NAME}:${IMAGE_TAG} cloud-node-manager image for external cloud-provider-azure cluster"
64+
fi
5865
fi
5966

6067
defaultTag=$(date -u '+%Y%m%d%H%M%S')

scripts/ci-entrypoint.sh

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ setup() {
5555
source "${REPO_ROOT}/scripts/ci-build-azure-ccm.sh"
5656
echo "Will use the ${IMAGE_REGISTRY}/${CCM_IMAGE_NAME}:${IMAGE_TAG} cloud-controller-manager image for external cloud-provider-cluster"
5757
echo "Will use the ${IMAGE_REGISTRY}/${CNM_IMAGE_NAME}:${IMAGE_TAG} cloud-node-manager image for external cloud-provider-azure cluster"
58+
59+
export CCM_IMG_ARGS=(--set cloudControllerManager.imageRepository="${IMAGE_REGISTRY}"
60+
--set cloudNodeManager.imageRepository="${IMAGE_REGISTRY}"
61+
--set cloudControllerManager.imageName="${CCM_IMAGE_NAME}"
62+
--set cloudNodeManager.imageName="${CNM_IMAGE_NAME}"
63+
--set-string cloudControllerManager.imageTag="${IMAGE_TAG}"
64+
--set-string cloudNodeManager.imageTag="${IMAGE_TAG}")
5865
fi
5966

6067
if [[ "$(capz::util::should_build_kubernetes)" == "true" ]]; then
@@ -115,11 +122,6 @@ select_cluster_template() {
115122
export CLUSTER_TEMPLATE="test/ci/cluster-template-prow.yaml"
116123
fi
117124

118-
if [[ -n "${TEST_CCM:-}" ]]; then
119-
# replace 'prow' with 'prow-external-cloud-provider' in the template name if testing out-of-tree
120-
export CLUSTER_TEMPLATE="${CLUSTER_TEMPLATE/prow/prow-external-cloud-provider}"
121-
fi
122-
123125
if [[ "${EXP_MACHINE_POOL:-}" == "true" ]]; then
124126
if [[ "${CLUSTER_TEMPLATE}" =~ "prow" ]]; then
125127
export CLUSTER_TEMPLATE="${CLUSTER_TEMPLATE/prow/prow-machine-pool}"
@@ -148,6 +150,18 @@ get_cidrs() {
148150
fi
149151
}
150152

153+
# get_cloud_provider determines if the Cluster is using an intree or external cloud-provider from the KubeadmConfigSpec.
154+
# any retryable operation in this function must return a non-zero exit code on failure so that we can
155+
# retry it using a `until get_cloud_provider; do sleep 5; done` pattern;
156+
# and any statement must be idempotent so that subsequent retry attempts can make forward progress.
157+
get_cloud_provider() {
158+
CLOUD_PROVIDER=$("${KUBECTL}" get kubeadmcontrolplane -l cluster.x-k8s.io/cluster-name="${CLUSTER_NAME}" -o=jsonpath='{.items[0].spec.kubeadmConfigSpec.clusterConfiguration.controllerManager.extraArgs.cloud-provider}')
159+
if [[ "${CLOUD_PROVIDER:-}" = "azure" ]]; then
160+
IN_TREE="true"
161+
export IN_TREE
162+
fi
163+
}
164+
151165
# install_calico installs Calico CNI componentry onto the Cluster
152166
# any retryable operation in this function must return a non-zero exit code on failure so that we can
153167
# retry it using a `until install_calico; do sleep 5; done` pattern;
@@ -205,18 +219,12 @@ install_cloud_provider_azure() {
205219
echo "Installing cloud-provider-azure components via helm"
206220
"${HELM}" upgrade cloud-provider-azure --install --repo https://raw.githubusercontent.com/kubernetes-sigs/cloud-provider-azure/master/helm/repo cloud-provider-azure \
207221
--set infra.clusterName="${CLUSTER_NAME}" \
208-
--set cloudControllerManager.imageRepository="${IMAGE_REGISTRY}" \
209-
--set cloudNodeManager.imageRepository="${IMAGE_REGISTRY}" \
210-
--set cloudControllerManager.imageName="${CCM_IMAGE_NAME}" \
211-
--set cloudNodeManager.imageName="${CNM_IMAGE_NAME}" \
212-
--set-string cloudControllerManager.imageTag="${IMAGE_TAG}" \
213-
--set-string cloudNodeManager.imageTag="${IMAGE_TAG}" \
214222
--set cloudControllerManager.replicas="${CCM_COUNT}" \
215223
--set cloudControllerManager.enableDynamicReloading="${ENABLE_DYNAMIC_RELOADING}" \
216224
--set cloudControllerManager.cloudConfig="${CLOUD_CONFIG}" \
217225
--set cloudControllerManager.cloudConfigSecretName="${CONFIG_SECRET_NAME}" \
218226
--set cloudControllerManager.logVerbosity="${CCM_LOG_VERBOSITY}" \
219-
--set-string cloudControllerManager.clusterCIDR="${CCM_CLUSTER_CIDR}"
227+
--set-string cloudControllerManager.clusterCIDR="${CCM_CLUSTER_CIDR}" "${CCM_IMG_ARGS[@]}"
220228
}
221229

222230
# wait_for_nodes returns when all nodes in the workload cluster are Ready.
@@ -265,7 +273,10 @@ install_addons() {
265273
sleep 5
266274
done
267275
# install cloud-provider-azure components, if using out-of-tree
268-
if [[ -n "${TEST_CCM:-}" ]]; then
276+
until get_cloud_provider; do
277+
sleep 5
278+
done
279+
if [[ -z "${IN_TREE:-}" ]]; then
269280
until install_cloud_provider_azure; do
270281
sleep 5
271282
done

templates/cluster-template-aad.yaml

Lines changed: 5 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/cluster-template-azure-bastion.yaml

Lines changed: 5 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/cluster-template-clusterclass.yaml

Lines changed: 5 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)