Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test internet connectivity of the machines #159

Merged
merged 32 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9b99457
Use frr container for internet vrf
robertvolkmann Apr 19, 2024
2f64ff9
Allow ssh into firewall and machine
robertvolkmann Apr 19, 2024
44beae2
Add pink test
robertvolkmann Apr 19, 2024
8740f95
Merge branch 'master' into ping-test
robertvolkmann Apr 19, 2024
98f84c9
Add comments
robertvolkmann Apr 19, 2024
8e94a0e
Increase retry time
robertvolkmann Apr 19, 2024
a0f743c
Merge branch 'master' into ping-test
robertvolkmann May 16, 2024
de5854d
Allow ssh over link local addresses into the machines
robertvolkmann Jun 7, 2024
d419b18
Merge branch 'master' into ping-test
robertvolkmann Jul 3, 2024
259e9e4
Try older firewall image
robertvolkmann Jul 12, 2024
de2f282
sudo is required for ping
robertvolkmann Jul 12, 2024
9ee5a00
Use last working firewall image
robertvolkmann Jul 12, 2024
2cd0967
Define firewall rules
robertvolkmann Jul 15, 2024
61f22e3
Use curl instead of ping because CI env doesn't allow ICMP
robertvolkmann Jul 15, 2024
0039240
Revert "Use last working firewall image"
robertvolkmann Jul 15, 2024
da38b43
Revert "Try older firewall image"
robertvolkmann Jul 15, 2024
7be6174
Merge branch 'master' into ping-test
robertvolkmann Jul 15, 2024
4e08b90
rename make target to test connectivity
robertvolkmann Jul 15, 2024
bc53bf1
adjust comment
robertvolkmann Jul 15, 2024
20775b3
Remove Internet VRF leftovers on the cumulus switches
robertvolkmann Jul 16, 2024
06fba33
Use linux bridge to simulate external network
robertvolkmann Jul 16, 2024
eb51cfc
Test for internet connectivity before testing ssh access
robertvolkmann Jul 16, 2024
fc1b921
Check SSH login doesn't work on CI
robertvolkmann Jul 16, 2024
275517f
Add ingress rule to allow SSH access
robertvolkmann Jul 17, 2024
cfdcaa3
Merge branch 'master' into ping-test
robertvolkmann Jul 17, 2024
c468983
Revert "Add ingress rule to allow SSH access"
robertvolkmann Jul 17, 2024
bd682dc
Only test outgoing internet connectivity
robertvolkmann Jul 17, 2024
b9c08e9
Test SSH access to the machine
robertvolkmann Jul 17, 2024
9e52625
Document that 203.0.113.0/24 is a reserved address block
robertvolkmann Jul 17, 2024
a3e4ea6
Use containerlab 0.56.0
robertvolkmann Jul 18, 2024
8a03d31
Set MTU for interface on the mini_lab_ext bridge to fix MTU mismatches
robertvolkmann Jul 18, 2024
6e3c704
Fix MTU vniInternet to 9000
robertvolkmann Jul 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 40 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ MINI_LAB_VM_IMAGE := $(or $(MINI_LAB_VM_IMAGE),ghcr.io/metal-stack/mini-lab-vms:
MINI_LAB_SONIC_IMAGE := $(or $(MINI_LAB_SONIC_IMAGE),ghcr.io/metal-stack/mini-lab-sonic:latest)

MACHINE_OS=ubuntu-22.04
MAX_RETRIES := 10

# Machine flavors
ifeq ($(MINI_LAB_FLAVOR),cumulus)
LAB_MACHINES=machine01,machine02
LAB_TOPOLOGY=mini-lab.cumulus.yaml
VRF=vrf20
else ifeq ($(MINI_LAB_FLAVOR),sonic)
LAB_MACHINES=machine01,machine02
LAB_TOPOLOGY=mini-lab.sonic.yaml
VRF=Vrf20
else
$(error Unknown flavor $(MINI_LAB_FLAVOR))
endif
Expand Down Expand Up @@ -133,11 +136,11 @@ _privatenet: env

.PHONY: machine
machine: _privatenet
docker compose run $(DOCKER_COMPOSE_TTY_ARG) metalctl machine create --description test --name test --hostname test --project 00000000-0000-0000-0000-000000000000 --partition mini-lab --image $(MACHINE_OS) --size v1-small-x86 --networks $(shell docker compose run $(DOCKER_COMPOSE_TTY_ARG) metalctl network list --name user-private-network -o template --template '{{ .id }}')
docker compose run $(DOCKER_COMPOSE_TTY_ARG) metalctl machine create --description test --name test --hostname test --project 00000000-0000-0000-0000-000000000000 --partition mini-lab --image $(MACHINE_OS) --size v1-small-x86 --userdata "@/tmp/ignition.json" --networks $(shell docker compose run $(DOCKER_COMPOSE_TTY_ARG) metalctl network list --name user-private-network -o template --template '{{ .id }}')

.PHONY: firewall
firewall: _ips _privatenet
docker compose run $(DOCKER_COMPOSE_TTY_ARG) metalctl firewall create --description fw --name fw --hostname fw --project 00000000-0000-0000-0000-000000000000 --partition mini-lab --image firewall-ubuntu-3.0 --size v1-small-x86 --networks internet-mini-lab,$(shell docker compose run $(DOCKER_COMPOSE_TTY_ARG) metalctl network list --name user-private-network -o template --template '{{ .id }}')
docker compose run $(DOCKER_COMPOSE_TTY_ARG) metalctl firewall create --description fw --name fw --hostname fw --project 00000000-0000-0000-0000-000000000000 --partition mini-lab --image firewall-ubuntu-3.0 --size v1-small-x86 --userdata "@/tmp/ignition.json" --networks internet-mini-lab,$(shell docker compose run $(DOCKER_COMPOSE_TTY_ARG) metalctl network list --name user-private-network -o template --template '{{ .id }}')

.PHONY: ls
ls: env
Expand Down Expand Up @@ -223,6 +226,41 @@ console-machine02:
console-machine03:
@$(MAKE) --no-print-directory _console-machine CONSOLE_PORT=4002

## SSH TARGETS FOR MACHINES ##
# Python code could be replaced by jq, but it is not preinstalled on Cumulus
.PHONY: ssh-fw
ssh-fw:
$(eval fw = $(shell ssh -F files/ssh/config leaf01 "vtysh -c 'show bgp neighbors fw json' | \
python3 -c 'import sys, json; data = json.load(sys.stdin); key = next(iter(data)); print(data[key][\"bgpNeighborAddr\"] + \"%\" + key)'" \
))
ssh -F files/ssh/config $(fw) $(COMMAND)

.PHONY: ssh-machine
ssh-machine:
$(eval machine = $(shell ssh -F files/ssh/config leaf01 "vtysh -c 'show bgp vrf $(VRF) neighbors test json' | \
python3 -c 'import sys, json; data = json.load(sys.stdin); key = next(iter(data)); print(data[key][\"bgpNeighborAddr\"] + \"%\" + key)'" \
))
ssh -F files/ssh/config $(machine) $(COMMAND)

.PHONY: ping-cloudflare
ping-cloudflare:
@echo "Attempting to ping 1.1.1.1..."
@for i in $$(seq 1 $(MAX_RETRIES)); do \
if $(MAKE) ssh-machine COMMAND="ping -c 1 1.1.1.1" > /dev/null 2>&1; then \
echo "Ping successful"; \
exit 0; \
else \
echo "Ping failed"; \
if [ $$i -lt $(MAX_RETRIES) ]; then \
echo "Retrying in 3 seconds..."; \
sleep 3; \
else \
echo "Max retries reached"; \
exit 1; \
fi; \
fi; \
done

## DEV TARGETS ##

.PHONY: dev-env
Expand Down
1 change: 1 addition & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ services:
- METALCTL_API_URL=http://api.172.17.0.1.nip.io:8080/metal
volumes:
- ./files/ssh:/root/.ssh:ro
- ./files/ignition.json:/tmp/ignition.json
network_mode: host
dns:
- 172.17.0.1
Expand Down
25 changes: 25 additions & 0 deletions files/ignition.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"ignition": {
"config": {},
"security": {},
"timeouts": {},
"version": "2.3.0"
},
"networkd": {},
"passwd": {},
"storage": {
"files": [
{
"filesystem": "root",
"path": "/etc/hosts.allow",
"append": true,
"contents": {
"source": "data:,ALL%3A%20%5Bfe80%3A%3A%5D%2F10%0D%0A",
majst01 marked this conversation as resolved.
Show resolved Hide resolved
"verification": {}
},
"mode": 644
}
]
},
"systemd": {}
}
17 changes: 17 additions & 0 deletions files/ssh/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Host leaf01
HostName leaf01
User root
IdentityFile files/ssh/id_rsa
PasswordAuthentication no
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
PubkeyAcceptedKeyTypes +ssh-rsa

Host * !leaf01
User metal
IdentityFile files/ssh/id_rsa
PasswordAuthentication no
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
# bash could be replaced with ncat, but it is not preinstalled on Cumulus
ProxyCommand ssh -q -F files/ssh/config leaf01 'sudo ip vrf exec default bash -c "exec 3<>/dev/tcp/%h/%p; cat<&0 >&3 & cat<&3 >&1"'
3 changes: 2 additions & 1 deletion inventories/group_vars/cumulus/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ ports:
1: 100G
interfaces:
- name: swp1
uplinks: []
uplinks:
- name: swp31

# The best practice recommendation is to set an MTU of 9,216 for the inter-switch links,
# and an MTU of 9,000 for the server-facing ports, which don’t carry the VXLAN header.
Expand Down
15 changes: 13 additions & 2 deletions mini-lab.cumulus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ topology:
ansible-group: cumulus
binds:
- files/ssh/id_rsa.pub:/root/.ssh/authorized_keys
linux:
image: ${MINI_LAB_VM_IMAGE}

nodes:
leaf01:
Expand All @@ -26,8 +24,19 @@ topology:
kind: cvx
binds:
- apt-transport-https.tar.gz:/root/jessie-apt-transport-fix.tar.gz
inet:
kind: linux
image: quay.io/frrouting/frr:9.1.0
binds:
- files/inet/daemons:/etc/frr/daemons
- files/inet/frr.conf:/etc/frr/frr.conf
- files/inet/vtysh.conf:/etc/frr/vtysh.conf
- files/inet/network.sh:/root/network.sh
exec:
- sh /root/network.sh
vms:
kind: linux
image: ${MINI_LAB_VM_IMAGE}
binds:
- /dev:/dev
- scripts:/mini-lab
Expand All @@ -39,3 +48,5 @@ topology:
- endpoints: ["leaf02:swp2", "vms:lan3"]
- endpoints: ["leaf01:swp3", "vms:lan4"]
- endpoints: ["leaf02:swp3", "vms:lan5"]
- endpoints: ["leaf01:swp31", "inet:eth1"]
- endpoints: ["leaf02:swp31", "inet:eth2"]
3 changes: 3 additions & 0 deletions test/integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ echo "$phoned/$minPhoned machines have phoned home"

sleep 10

echo "Test connectivity to outside"
make ping-cloudflare

echo "Adding route to leaf01 and leaf02"
make route

Expand Down
Loading