Skip to content

Commit

Permalink
Add just recipe to configure flat network multicluster (#11187)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
mateiidavid authored Aug 10, 2023
1 parent 2d3f3d3 commit b1f43b0
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}' \
Expand Down Expand Up @@ -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:
Expand All @@ -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 }}' \
Expand Down

0 comments on commit b1f43b0

Please sign in to comment.