Skip to content

Commit c038d9a

Browse files
authored
Prepare for a Calico platform integ environment (#49255)
* updates to allow kind_provisioner to install cilium for ambient-sc setup Signed-off-by: Ian Rudie <[email protected]> * update to use calico for now instead Signed-off-by: Ian Rudie <[email protected]> * adding a new StrictHBONE test Signed-off-by: Ian Rudie <[email protected]> * revising kind_provisioner slightly Signed-off-by: Ian Rudie <[email protected]> * refined kind provisioning Signed-off-by: Ian Rudie <[email protected]> * adopt more minimal config, begin documenting maintenance, skip strict HBONE test Signed-off-by: Ian Rudie <[email protected]> * use explicit variable instead of checking which config file was used Signed-off-by: Ian Rudie <[email protected]> * adopt yq 4 syntax, case statement for CNI choice Signed-off-by: Ian Rudie <[email protected]> * linter for markdown Signed-off-by: Ian Rudie <[email protected]> * rename test to better suite it's purpose Signed-off-by: Ian Rudie <[email protected]> * no need to modify ambient-sc.yaml since we're using yq to alter it now Signed-off-by: Ian Rudie <[email protected]> * skip with link to issue for tracking Signed-off-by: Ian Rudie <[email protected]> --------- Signed-off-by: Ian Rudie <[email protected]>
1 parent 751d3d8 commit c038d9a

File tree

5 files changed

+5247
-1
lines changed

5 files changed

+5247
-1
lines changed

common/scripts/kind_provisioner.sh

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,41 @@ EOF
182182
fi
183183
fi
184184

185+
KIND_WAIT_FLAG="--wait=180s"
186+
KIND_DISABLE_CNI="false"
187+
if [[ -n "${KUBERNETES_CNI:-}" ]]; then
188+
unset KIND_WAIT_FLAG
189+
KIND_DISABLE_CNI="true"
190+
fi
191+
185192
# Create KinD cluster
186-
if ! (kind create cluster --name="${NAME}" --config "${CONFIG}" -v4 --retain --image "${IMAGE}" --wait=180s); then
193+
if ! (yq eval "${CONFIG}" --expression ".networking.disableDefaultCNI = ${KIND_DISABLE_CNI}" | \
194+
kind create cluster --name="${NAME}" -v4 --retain --image "${IMAGE}" ${KIND_WAIT_FLAG:+"$KIND_WAIT_FLAG"} --config -); then
187195
echo "Could not setup KinD environment. Something wrong with KinD setup. Exporting logs."
188196
return 9
189197
fi
190198
# Workaround kind issue causing taints to not be removed in 1.24
191199
kubectl taint nodes "${NAME}"-control-plane node-role.kubernetes.io/control-plane- || true
192200

201+
# Determine what CNI to install
202+
case "${KUBERNETES_CNI:-}" in
203+
204+
"calico")
205+
echo "Installing Calico CNI"
206+
install_calico "" "$(dirname "$CONFIG")"
207+
;;
208+
209+
"")
210+
# perfectly fine, we accepted the default KinD CNI
211+
;;
212+
213+
*)
214+
# we don't know what to do but we've got no CNI, return non-zero
215+
echo "${KUBERNETES_CNI} is not recognized. Supported options are \"calico\" or do not set the variable to use default."
216+
return 1
217+
;;
218+
esac
219+
193220
# If metrics server configuration directory is specified then deploy in
194221
# the cluster just created
195222
if [[ -n ${METRICS_SERVER_CONFIG_DIR:-} ]]; then
@@ -362,6 +389,17 @@ function connect_kind_clusters() {
362389
fi
363390
}
364391

392+
function install_calico {
393+
local KUBECONFIG="${1}"
394+
local CONFIG_DIR="${2}"
395+
396+
echo "Setting up ambient cluster, Calico CNI will be used."
397+
kubectl --kubeconfig="$KUBECONFIG" apply -f "${CONFIG_DIR}"/calico.yaml
398+
399+
kubectl --kubeconfig="$KUBECONFIG" wait --for condition=ready -n kube-system pod -l k8s-app=calico-node --timeout 90s
400+
kubectl --kubeconfig="$KUBECONFIG" wait --for condition=ready -n kube-system pod -l k8s-app=calico-kube-controllers --timeout 90s
401+
}
402+
365403
function install_metallb() {
366404
KUBECONFIG="${1}"
367405
kubectl --kubeconfig="$KUBECONFIG" apply -f "${COMMON_SCRIPTS}/metallb-native.yaml"

prow/config/calico.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
The calico.yaml file is from [https://raw.githubusercontent.com/projectcalico/calico/v3.27.0/manifests/calico.yaml](https://raw.githubusercontent.com/projectcalico/calico/v3.27.0/manifests/calico.yaml)
2+
3+
Once downloaded, run the following sed command to replace the default docker.io images with istio-testing's copies of them:
4+
5+
```shell
6+
sed -ie "s?docker.io?gcr.io/istio-testing?g" calico.yaml
7+
```
8+
9+
In order to upgrade versions of calico we'll need to update the version below and then have someone with the ability to push run the following:
10+
11+
```shell
12+
export VERSION=v3.27.0
13+
14+
crane cp {docker.io,gcr.io/istio-testing}/calico/cni:"${VERSION}"
15+
crane cp {docker.io,gcr.io/istio-testing}/calico/node:"${VERSION}"
16+
crane cp {docker.io,gcr.io/istio-testing}/calico/kube-controllers:"${VERSION}"
17+
```

0 commit comments

Comments
 (0)