From b1f43b0789e460db8945b231719811a44372a300 Mon Sep 17 00:00:00 2001 From: Matei David Date: Thu, 10 Aug 2023 23:19:04 +0100 Subject: [PATCH] Add `just` recipe to configure flat network multicluster (#11187) Our CI infrastructure does not currently support running two k3d clusters in a flat network, for testing purposes. The process of bridging two k3d clusters is quite simple (assuming one node for each cluster). For each node, a network route has to be added to route to the other node's cluster CIDR. This change adds a `just` recipe to configure two running clusters to participate in a flat network. Routes are added by executing `ip route add` in each respective server's docker container. Additionally, to support this, target clusters now run with a different pod CIDR (to ensure there isn't any overlap between the two). Signed-off-by: Matei David --- justfile | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/justfile b/justfile index 1b8a6d8c74063..6440d63963bed 100644 --- a/justfile +++ b/justfile @@ -464,7 +464,7 @@ _linkerd-viz-uninit: ## linkerd multicluster ## -_mc-target-k3d-flags := "--k3s-arg --disable='local-storage,metrics-server@server:*'" +_mc-target-k3d-flags := "--k3s-arg --disable='local-storage,metrics-server@server:*' --k3s-arg '--cluster-cidr=10.23.0.0/24@server:*'" linkerd-mc-install: _linkerd-init {{ _linkerd }} mc install --set='linkerdVersion={{ linkerd-tag }}' \ @@ -502,10 +502,6 @@ _mc-target-load: _mc-load # Run the multicluster tests with cluster setup -# -# The multicluster test does its own installation of control planes/etc, so -# we don't do any setup beyond ensuring the cluster is present with images -# loaded. mc-test: mc-test-load mc-test-run mc-test-build: @@ -514,6 +510,19 @@ mc-test-build: mc-test-load: _mc-load _mc-target-load +k3d-source-server := "k3d-" + k3d-name + "-server-0" +k3d-target-server := "k3d-" + k3d-name + "-target-server-0" + +_mc-route-output-fmt := "-o jsonpath='ip route add {.spec.podCIDR} via {.status.addresses[?(.type==\"InternalIP\")].address}'" +_mc-print-source-route := _kubectl + " " + "get node " + k3d-source-server + " " + _mc-route-output-fmt +_mc-print-target-route := "kubectl --context=k3d-" + k3d-name + "-target "+ "get node " + k3d-target-server + " " + _mc-route-output-fmt + +# Allow two k3d server nodes to participate in a flat network +mc-flat-network-init: + @docker exec -it k3d-{{k3d-name}}-server-0 `{{_mc-print-target-route}}` + @docker exec -it k3d-{{k3d-name}}-target-server-0 `{{_mc-print-source-route}}` + + # Run the multicluster tests without any setup mc-test-run: LINKERD_DOCKER_REGISTRY='{{ DOCKER_REGISTRY }}' \