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

Add flavor for CAPI. #203

Merged
merged 9 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
33 changes: 27 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ else ifeq ($(MINI_LAB_FLAVOR),sonic)
LAB_MACHINES=machine01,machine02
LAB_TOPOLOGY=mini-lab.sonic.yaml
VRF=Vrf20
else ifeq ($(MINI_LAB_FLAVOR),capms)
LAB_MACHINES=machine01,machine02,machine03
LAB_TOPOLOGY=mini-lab.capms.yaml
VRF=Vrf20
else
$(error Unknown flavor $(MINI_LAB_FLAVOR))
endif
Expand Down Expand Up @@ -120,6 +124,7 @@ cleanup-partition:
mkdir -p clab-mini-lab
sudo --preserve-env $(CONTAINERLAB) destroy --topo mini-lab.cumulus.yaml
sudo --preserve-env $(CONTAINERLAB) destroy --topo mini-lab.sonic.yaml
sudo --preserve-env $(CONTAINERLAB) destroy --topo mini-lab.capms.yaml
docker network rm --force mini_lab_ext

.PHONY: _privatenet
Expand Down Expand Up @@ -171,17 +176,25 @@ ssh-leaf02:
start-machines:
docker exec vms /mini-lab/manage_vms.py --names $(LAB_MACHINES) create

.PHONY: kill-machines
kill-machines:
docker exec vms /mini-lab/manage_vms.py --names $(LAB_MACHINES) kill

.PHONY: _password
_password: env
docker compose run $(DOCKER_COMPOSE_RUN_ARG) metalctl machine consolepassword $(MACHINE_UUID)

.PHONY: password-machine01
password-machine01:
@$(MAKE) --no-print-directory _password MACHINE_UUID=e0ab02d2-27cd-5a5e-8efc-080ba80cf258
@$(MAKE) --no-print-directory _password MACHINE_NAME=machine01 MACHINE_UUID=00000000-0000-0000-0000-000000000001

.PHONY: password-machine02
password-machine02:
@$(MAKE) --no-print-directory _password MACHINE_UUID=2294c949-88f6-5390-8154-fa53d93a3313
@$(MAKE) --no-print-directory _password MACHINE_NAME=machine02 MACHINE_UUID=00000000-0000-0000-0000-000000000002

.PHONY: password-machine0%
password-machine0%:
@$(MAKE) --no-print-directory _password MACHINE_NAME=machine0$* MACHINE_UUID=00000000-0000-0000-0000-00000000000$*

.PHONY: _free-machine
_free-machine: env
Expand All @@ -191,11 +204,15 @@ _free-machine: env

.PHONY: free-machine01
free-machine01:
@$(MAKE) --no-print-directory _free-machine MACHINE_NAME=machine01 MACHINE_UUID=e0ab02d2-27cd-5a5e-8efc-080ba80cf258
@$(MAKE) --no-print-directory _free-machine MACHINE_NAME=machine01 MACHINE_UUID=00000000-0000-0000-0000-000000000001

.PHONY: free-machine02
free-machine02:
@$(MAKE) --no-print-directory _free-machine MACHINE_NAME=machine02 MACHINE_UUID=2294c949-88f6-5390-8154-fa53d93a3313
@$(MAKE) --no-print-directory _free-machine MACHINE_NAME=machine02 MACHINE_UUID=00000000-0000-0000-0000-000000000002

.PHONY: free-machine0%
free-machine0%:
@$(MAKE) --no-print-directory _free-machine MACHINE_NAME=machine0$* MACHINE_UUID=00000000-0000-0000-0000-00000000000$*

.PHONY: _console-machine
_console-machine:
Expand All @@ -204,11 +221,15 @@ _console-machine:

.PHONY: console-machine01
console-machine01:
@$(MAKE) --no-print-directory _console-machine CONSOLE_PORT=4000
@$(MAKE) --no-print-directory _console-machine CONSOLE_PORT=4001

.PHONY: console-machine02
console-machine02:
@$(MAKE) --no-print-directory _console-machine CONSOLE_PORT=4001
@$(MAKE) --no-print-directory _console-machine CONSOLE_PORT=4002

.PHONY: console-machine0%
console-machine0%:
@$(MAKE) --no-print-directory _console-machine CONSOLE_PORT=400$*
Gerrit91 marked this conversation as resolved.
Show resolved Hide resolved

## SSH TARGETS FOR MACHINES ##
# Python code could be replaced by jq, but it is not preinstalled on Cumulus
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ After the deployment and waiting for a short amount of time, two machines in sta
docker compose run --rm metalctl machine ls

ID LAST EVENT WHEN AGE HOSTNAME PROJECT SIZE IMAGE PARTITION
e0ab02d2-27cd-5a5e-8efc-080ba80cf258   PXE Booting 3s
2294c949-88f6-5390-8154-fa53d93a3313 PXE Booting 5s
00000000-0000-0000-0000-000000000001   PXE Booting 3s
00000000-0000-0000-0000-000000000002 PXE Booting 5s
```

Wait until the machines reach the waiting state:
Expand All @@ -100,8 +100,8 @@ Wait until the machines reach the waiting state:
docker compose run --rm metalctl machine ls

ID LAST EVENT WHEN AGE HOSTNAME PROJECT SIZE IMAGE PARTITION
e0ab02d2-27cd-5a5e-8efc-080ba80cf258   Waiting 8s v1-small-x86 mini-lab
2294c949-88f6-5390-8154-fa53d93a3313   Waiting 8s v1-small-x86 mini-lab
00000000-0000-0000-0000-000000000001   Waiting 8s v1-small-x86 mini-lab
00000000-0000-0000-0000-000000000002   Waiting 8s v1-small-x86 mini-lab
```

Create a firewall and a machine with:
Expand Down Expand Up @@ -157,14 +157,14 @@ Two machines are now installed and have status "Phoned Home"
```bash
docker compose run --rm metalctl machine ls
ID LAST EVENT WHEN AGE HOSTNAME PROJECT SIZE IMAGE PARTITION
e0ab02d2-27cd-5a5e-8efc-080ba80cf258   Phoned Home 2s 21s machine 00000000-0000-0000-0000-000000000000 v1-small-x86 Ubuntu 20.04 20200331 mini-lab
2294c949-88f6-5390-8154-fa53d93a3313   Phoned Home 8s 18s fw 00000000-0000-0000-0000-000000000000 v1-small-x86 Firewall 2 Ubuntu 20200730 mini-lab
00000000-0000-0000-0000-000000000001   Phoned Home 2s 21s machine 00000000-0000-0000-0000-000000000000 v1-small-x86 Ubuntu 20.04 20200331 mini-lab
00000000-0000-0000-0000-000000000002   Phoned Home 8s 18s fw 00000000-0000-0000-0000-000000000000 v1-small-x86 Firewall 2 Ubuntu 20200730 mini-lab
```

Login with user name metal and the console password from

```bash
docker compose run --rm metalctl machine consolepassword e0ab02d2-27cd-5a5e-8efc-080ba80cf258
docker compose run --rm metalctl machine consolepassword 00000000-0000-0000-0000-000000000001
```

To remove the kind cluster, the switches and machines, run:
Expand All @@ -180,15 +180,15 @@ Reinstall a machine with
```bash
docker compose run --rm metalctl machine reinstall \
--image ubuntu-20.04 \
e0ab02d2-27cd-5a5e-8efc-080ba80cf258
00000000-0000-0000-0000-000000000001
```

### Free machine

Free a machine with `make free-machine01` or

```bash
docker compose run --rm metalctl machine rm e0ab02d2-27cd-5a5e-8efc-080ba80cf258
docker compose run --rm metalctl machine rm 00000000-0000-0000-0000-000000000001
```

## Flavors
Expand Down
2 changes: 1 addition & 1 deletion inventories/group_vars/control-plane/metal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ metal_api_sizes:
max: "{{ '4GB' | humanfriendly }}"
- type: storage
min: "{{ '1GB' | humanfriendly }}"
max: "{{ '10GB' | humanfriendly }}"
max: "{{ '100GB' | humanfriendly }}"

metal_api_partitions:
- id: mini-lab
Expand Down
57 changes: 57 additions & 0 deletions mini-lab.capms.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# flavor for mini-lab cluster-api-provider-metal-stack
name: mini-lab
prefix: ""

mgmt:
network: bridge

topology:
nodes:
mini_lab_ext:
kind: bridge
leaf01:
kind: linux
image: ${MINI_LAB_SONIC_IMAGE}
labels:
ansible-group: sonic
binds:
- /dev:/dev
- files/ssh/id_rsa.pub:/authorized_keys
leaf02:
kind: linux
image: ${MINI_LAB_SONIC_IMAGE}
labels:
ansible-group: sonic
binds:
- /dev:/dev
- files/ssh/id_rsa.pub:/authorized_keys
inet:
kind: linux
image: quay.io/frrouting/frr:10.0.1
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
env:
QEMU_MACHINE_CPU_CORES: 2
QEMU_MACHINE_DISK_SIZE: 20G
links:
- endpoints: ["inet:ext", "mini_lab_ext:inet"]
mtu: 9000
- endpoints: ["leaf01:Ethernet0", "vms:lan0"]
- endpoints: ["leaf02:Ethernet0", "vms:lan1"]
- endpoints: ["leaf01:Ethernet1", "vms:lan2"]
- endpoints: ["leaf02:Ethernet1", "vms:lan3"]
- endpoints: ["leaf01:Ethernet2", "vms:lan4"]
- endpoints: ["leaf02:Ethernet2", "vms:lan5"]
- endpoints: ["leaf01:Ethernet120", "inet:eth1"]
- endpoints: ["leaf02:Ethernet120", "inet:eth2"]
29 changes: 21 additions & 8 deletions scripts/manage_vms.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,33 @@
VMS = {
"machine01": {
"name": "machine01",
"uuid": "e0ab02d2-27cd-5a5e-8efc-080ba80cf258",
"uuid": "00000000-0000-0000-0000-000000000001",
"disk-path": "/machine01.img",
"disk-size": "5G",
"memory": "2G",
"disk-size": os.getenv("QEMU_MACHINE_DISK_SIZE", default="5G"),
"memory": os.getenv("QEMU_MACHINE_MEMORY", default="2G"),
"cores": os.getenv("QEMU_MACHINE_CPU_CORES", default="1"),
"lan_indices": [0, 1],
"serial-port": 4000,
"serial-port": 4001,
},
"machine02": {
"name": "machine02",
"uuid": "2294c949-88f6-5390-8154-fa53d93a3313",
"uuid": "00000000-0000-0000-0000-000000000002",
"disk-path": "/machine02.img",
"disk-size": "5G",
"memory": "2G",
"disk-size": os.getenv("QEMU_MACHINE_DISK_SIZE", default="5G"),
"memory": os.getenv("QEMU_MACHINE_MEMORY", default="2G"),
"cores": os.getenv("QEMU_MACHINE_CPU_CORES", default="1"),
"lan_indices": [2, 3],
"serial-port": 4001,
"serial-port": 4002,
},
"machine03": {
"name": "machine03",
"uuid": "00000000-0000-0000-0000-000000000003",
"disk-path": "/machine03.img",
"disk-size": os.getenv("QEMU_MACHINE_DISK_SIZE", default="5G"),
"memory": os.getenv("QEMU_MACHINE_MEMORY", default="2G"),
"cores": os.getenv("QEMU_MACHINE_CPU_CORES", default="1"),
"lan_indices": [4, 5],
"serial-port": 4003,
},
}

Expand Down Expand Up @@ -123,6 +135,7 @@ def _start_vm(machine):
"-uuid", machine.get("uuid"),
"-m", machine.get("memory"),
"-cpu", "host",
"-smp", "cores=" + machine.get("cores"),
"-display", "none",
"-enable-kvm",
"-machine", "q35",
Expand Down