Skip to content

Commit c6ffd64

Browse files
authored
test(cni): update k8s and calico (#14707)
We were stuck on k8s v1.27 because of k3d-io/k3d#1375, which is no longer an issue. This change removes that constraint and installs the latest version of Calico using the tigera-operator.
1 parent f89bc64 commit c6ffd64

File tree

3 files changed

+35
-19
lines changed

3 files changed

+35
-19
lines changed

bin/_test-helpers.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,7 @@ start_test() {
313313
config=("$name" "${config[@]}" --no-lb --k3s-arg --cluster-domain=custom.domain --k3s-arg '--disable=servicelb,traefik@server:0' --image "$k8s_version_max")
314314
;;
315315
cni-calico-deep)
316-
# This requires k8s v1.27.6-k3s1 because after that Calico won't work.
317-
# We have to use a config file because that version can't be set via the
318-
# --image flag.
319-
# See https://github.com/k3d-io/k3d/issues/1375
320-
config=("$name" "${config[@]}" --no-lb --k3s-arg --write-kubeconfig-mode=644 --k3s-arg --flannel-backend=none --k3s-arg --cluster-cidr=192.168.0.0/16 --k3s-arg '--disable=servicelb,traefik@server:0' --config "$testdir"/deep/calico-k3d.yml)
316+
config=("$name" "${config[@]}" --no-lb --k3s-arg --write-kubeconfig-mode=644 --k3s-arg --flannel-backend=none --k3s-arg --cluster-cidr=192.168.0.0/16 --k3s-arg '--disable=servicelb,traefik@server:0')
321317
;;
322318
multicluster)
323319
config=("${config[@]}" --network multicluster-test --image "$k8s_version_max")

test/integration/deep/calico-k3d.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

test/integration/deep/install_test.go

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,42 @@ func TestInstallCalico(t *testing.T) {
2727
return
2828
}
2929

30-
out, err := TestHelper.Kubectl("", []string{"apply", "-f", "https://k3d.io/v5.1.0/usage/advanced/calico.yaml"}...)
31-
if err != nil {
32-
testutil.AnnotatedFatalf(t, "'kubectl apply' command failed",
33-
"kubectl apply command failed\n%s", out)
34-
}
30+
// install Calico as per instructions on
31+
// https://k3d.io/v5.8.3/usage/advanced/calico/#1-create-the-cluster-without-flannel
32+
// there's a lot of waiting involved here as the various components come up, so the easiest
33+
// is to retry the steps until they succeed
34+
var out string
35+
err := testutil.RetryFor(time.Minute, func() error {
36+
var err error
37+
out, err = TestHelper.Kubectl("", []string{"apply", "-f", "https://raw.githubusercontent.com/projectcalico/calico/v3.31.0/manifests/tigera-operator.yaml"}...)
38+
if err != nil {
39+
return err
40+
}
41+
42+
deploys := map[string]testutil.DeploySpec{
43+
"tigera-operator": {
44+
Namespace: "tigera-operator",
45+
Replicas: 1,
46+
},
47+
}
48+
TestHelper.WaitRollout(t, deploys)
3549

36-
time.Sleep(10 * time.Second)
37-
o, err := TestHelper.Kubectl("", "--namespace=kube-system", "wait", "--for=condition=available", "--timeout=120s", "deploy/calico-kube-controllers")
50+
out, err = TestHelper.Kubectl("", []string{"apply", "-f", "https://raw.githubusercontent.com/projectcalico/calico/v3.31.0/manifests/custom-resources.yaml"}...)
51+
if err != nil {
52+
return err
53+
}
54+
55+
for _, system := range []string{"apiserver", "calico", "goldmane", "ippools", "whisker"} {
56+
out, err = TestHelper.Kubectl("", "wait", "--for=condition=available", "--timeout=120s", "tigerastatus", system)
57+
if err != nil {
58+
return err
59+
}
60+
}
61+
62+
return nil
63+
})
3864
if err != nil {
39-
testutil.AnnotatedFatalf(t, "failed to wait for condition=available for calico resources",
40-
"failed to wait for condition=available for calico resources: %s: %s", err, o)
65+
testutil.AnnotatedFatalf(t, "failed to install calico", "failed to install calico: %s: %s", err, out)
4166
}
4267
}
4368

0 commit comments

Comments
 (0)