Skip to content

Commit

Permalink
Make it possible to start control-plane and partition on its own
Browse files Browse the repository at this point in the history
  • Loading branch information
simcod committed Jun 24, 2024
1 parent ad2e782 commit ac66282
Showing 1 changed file with 28 additions and 15 deletions.
43 changes: 28 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Commands
YQ=docker run --rm -i -v $(shell pwd):/workdir mikefarah/yq:4

USER := $(USER)
KUBECONFIG := $(shell pwd)/.kubeconfig

MKE2FS_CONFIG := $(shell pwd)/mke2fs.conf
Expand Down Expand Up @@ -37,7 +38,7 @@ else
endif

.PHONY: up
up: env partition-bake
up: env only-control-plane only-partition
@chmod 600 files/ssh/id_rsa
docker compose up --remove-orphans --force-recreate control-plane partition
@$(MAKE) --no-print-directory start-machines
Expand All @@ -55,21 +56,28 @@ restart: down up
down: cleanup

.PHONY: control-plane
control-plane: env
control-plane: only-control-plane env
docker compose up --remove-orphans --force-recreate control-plane

.PHONY: partition
partition: partition-bake
partition: only-partition
docker compose up --remove-orphans --force-recreate partition

.PHONY: partition-bake
partition-bake:
.PHONY: only-control-plane
only-control-plane:
@if ! sudo $(CONTAINERLAB) --topo $(LAB_TOPOLOGY) inspect | grep -i metal-control-plane > /dev/null; then \
sudo --preserve-env $(CONTAINERLAB) deploy --topo $(LAB_TOPOLOGY) --node-filter metal-control-plane --reconfigure && \
./scripts/deactivate_offloading.sh && \
sudo chown $(USER):$(USER) $(KUBECONFIG); fi

.PHONY: only-partition
only-partition:
docker pull $(MINI_LAB_VM_IMAGE)
ifeq ($(MINI_LAB_FLAVOR),sonic)
docker pull $(MINI_LAB_SONIC_IMAGE)
endif
@if ! sudo $(CONTAINERLAB) --topo $(LAB_TOPOLOGY) inspect | grep -i leaf01 > /dev/null; then \
sudo --preserve-env $(CONTAINERLAB) deploy --topo $(LAB_TOPOLOGY) --reconfigure && \
sudo --preserve-env $(CONTAINERLAB) deploy --topo $(LAB_TOPOLOGY) --node-filter leaf01,leaf02,inet,vms --reconfigure && \
./scripts/deactivate_offloading.sh; fi

.PHONY: env
Expand Down Expand Up @@ -98,19 +106,24 @@ fwrules: _ips
eval "sudo -- iptables -t nat -I LIBVIRT_PRT -s 10.0.1.0/24 ! -d 10.0.1.0/24 -j MASQUERADE"

.PHONY: cleanup
cleanup: cleanup-control-plane cleanup-partition
cleanup: cleanup-only-control-plane cleanup-only-partition

.PHONY: cleanup-control-plane
cleanup-control-plane:
.PHONY: cleanup-only-control-plane
cleanup-only-control-plane:
docker rm -f metal-control-plane-control-plane
docker compose down

.PHONY: cleanup-partition
cleanup-partition:
mkdir -p clab-mini-lab
sudo $(CONTAINERLAB) destroy --topo mini-lab.cumulus.yaml
sudo $(CONTAINERLAB) destroy --topo mini-lab.sonic.yaml
rm -f $(KUBECONFIG)

.PHONY: cleanup-only-partition
cleanup-only-partition:
ifeq ($(MINI_LAB_FLAVOR),cumulus)
sudo --preserve-env $(CONTAINERLAB) destroy --topo $(LAB_TOPOLOGY)
else ifeq ($(MINI_LAB_FLAVOR),sonic)
sudo --preserve-env $(CONTAINERLAB) destroy --topo $(LAB_TOPOLOGY) --node-filter leaf01,leaf02,inet,vms
else
$(error Unknown flavor $(MINI_LAB_FLAVOR))
endif

.PHONY: _privatenet
_privatenet: env
docker compose run $(DOCKER_COMPOSE_TTY_ARG) metalctl network list --name user-private-network | grep user-private-network || docker compose run $(DOCKER_COMPOSE_TTY_ARG) metalctl network allocate --partition mini-lab --project 00000000-0000-0000-0000-000000000000 --name user-private-network
Expand Down

0 comments on commit ac66282

Please sign in to comment.