Skip to content

Commit b2f6060

Browse files
Update to maintained dependencies (#145)
* Replace unmaintained `docker-compose` with `docker compose` * Set selinux labels for docker.sock * Migrate to Compose specification To override `compose.yaml` use `compose.override.yaml` * Upgrade to kind 0.20.0 * Remove restriction to outdated containerlab Issue with ignite was fixed in srl-labs/containerlab#1667
1 parent 7db403d commit b2f6060

File tree

5 files changed

+31
-40
lines changed

5 files changed

+31
-40
lines changed

Makefile

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ KINDCONFIG := $(or $(KINDCONFIG),control-plane/kind.yaml)
88
KUBECONFIG := $(shell pwd)/.kubeconfig
99

1010
# Default values
11-
DOCKER_COMPOSE_OVERRIDE=
12-
DOCKER_COMPOSE=$(shell if which docker-compose > /dev/null; then echo 'docker-compose'; else echo 'docker compose'; fi)
1311
CONTAINERLAB=$(shell which containerlab)
1412

1513
# extra vars can be used by projects that built on the mini-lab, which want to override default configuration
@@ -45,7 +43,7 @@ endif
4543
.PHONY: up
4644
up: env control-plane-bake partition-bake
4745
@chmod 600 files/ssh/id_rsa
48-
$(DOCKER_COMPOSE) up --remove-orphans --force-recreate control-plane partition
46+
docker compose up --remove-orphans --force-recreate control-plane partition
4947
@$(MAKE) --no-print-directory start-machines
5048
# for some reason an allocated machine will not be able to phone home
5149
# without restarting the metal-core
@@ -62,7 +60,7 @@ down: cleanup
6260

6361
.PHONY: control-plane
6462
control-plane: control-plane-bake env
65-
$(DOCKER_COMPOSE) up --remove-orphans --force-recreate control-plane
63+
docker compose up --remove-orphans --force-recreate control-plane
6664

6765
.PHONY: control-plane-bake
6866
control-plane-bake:
@@ -75,7 +73,7 @@ control-plane-bake:
7573

7674
.PHONY: partition
7775
partition: partition-bake
78-
$(DOCKER_COMPOSE) -f docker-compose.yml $(DOCKER_COMPOSE_OVERRIDE) up --remove-orphans --force-recreate partition
76+
docker compose up --remove-orphans --force-recreate partition
7977

8078
.PHONY: partition-bake
8179
partition-bake:
@@ -115,7 +113,7 @@ cleanup: cleanup-control-plane cleanup-partition
115113
.PHONY: cleanup-control-plane
116114
cleanup-control-plane:
117115
kind delete cluster --name metal-control-plane
118-
$(DOCKER_COMPOSE) down
116+
docker compose down
119117
rm -f $(KUBECONFIG)
120118

121119
.PHONY: cleanup-partition
@@ -124,19 +122,19 @@ cleanup-partition:
124122

125123
.PHONY: _privatenet
126124
_privatenet: env
127-
$(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
125+
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
128126

129127
.PHONY: machine
130128
machine: _privatenet
131-
$(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 }}')
129+
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 }}')
132130

133131
.PHONY: firewall
134132
firewall: _ips _privatenet
135-
$(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 }}')
133+
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 }}')
136134

137135
.PHONY: ls
138136
ls: env
139-
$(DOCKER_COMPOSE) run $(DOCKER_COMPOSE_TTY_ARG) metalctl machine ls
137+
docker compose run $(DOCKER_COMPOSE_TTY_ARG) metalctl machine ls
140138

141139
## SWITCH MANAGEMENT ##
142140

@@ -156,7 +154,7 @@ start-machines:
156154

157155
.PHONY: _password
158156
_password: env
159-
$(DOCKER_COMPOSE) run $(DOCKER_COMPOSE_TTY_ARG) metalctl machine consolepassword $(MACHINE_UUID)
157+
docker compose run $(DOCKER_COMPOSE_TTY_ARG) metalctl machine consolepassword $(MACHINE_UUID)
160158

161159
.PHONY: password-machine01
162160
password-machine01:
@@ -172,7 +170,7 @@ password-machine03:
172170

173171
.PHONY: _free-machine
174172
_free-machine: env
175-
$(DOCKER_COMPOSE) run $(DOCKER_COMPOSE_TTY_ARG) metalctl machine rm $(MACHINE_UUID)
173+
docker compose run $(DOCKER_COMPOSE_TTY_ARG) metalctl machine rm $(MACHINE_UUID)
176174
docker exec vms /mini-lab/manage_vms.py --names $(MACHINE_NAME) kill --with-disks
177175
docker exec vms /mini-lab/manage_vms.py --names $(MACHINE_NAME) create
178176

README.md

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ The mini-lab is a small, virtual setup to locally run the metal-stack. It deploy
2121

2222
- Linux machine with hardware virtualization support
2323
- kvm as hypervisor for the VMs (you can check through the `kvm-ok` command)
24-
- [docker](https://www.docker.com/) >= 18.09 (for using kind and our deployment base image)
25-
- [docker-compose](https://docs.docker.com/compose/) >= 2.0 (for ease of use and for parallelizing control plane and partition deployment)
26-
- [kind](https://github.com/kubernetes-sigs/kind/releases) == v0.15.0 (for hosting the metal control plane on a kubernetes cluster v1.25)
27-
- [containerlab](https://containerlab.srlinux.dev/install/) == v0.25.1
24+
- [docker](https://www.docker.com/) >= 20.10.13 (for using kind and our deployment base image)
25+
- [kind](https://github.com/kubernetes-sigs/kind/releases) == v0.20.0 (for hosting the metal control plane)
26+
- [containerlab](https://containerlab.srlinux.dev/install/) >= v0.47.1
2827
- the lab creates a docker network on your host machine (`172.17.0.1`), this hopefully does not overlap with other networks you have
2928
- (recommended) haveged to have enough random entropy (only needed if the PXE process does not work)
3029

@@ -49,17 +48,12 @@ curl -fsSL https://get.docker.com | sh
4948
sudo usermod -G docker -a ${USER}
5049

5150
# Install containerlab
52-
bash -c "$(curl -sL https://get.containerlab.dev)" -- -v 0.25.1
51+
bash -c "$(curl -sL https://get.containerlab.dev)"
5352

5453
# Install kind (kubernetes in docker), for more details see https://kind.sigs.k8s.io/docs/user/quick-start/#installation
55-
sudo curl -Lo /usr/local/bin/kind "https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64"
54+
sudo curl -Lo /usr/local/bin/kind "https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-amd64"
5655
sudo chmod +x /usr/local/bin/kind
5756

58-
# Install docker-compose, for more details see https://docs.docker.com/compose/install/
59-
sudo curl -Lo /usr/local/bin/docker-compose "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)"
60-
sudo chmod +x /usr/local/bin/docker-compose
61-
```
62-
6357
The following ports are used statically on your host machine:
6458

6559
| Port | Bind Address | Description |
@@ -92,7 +86,7 @@ make
9286
After the deployment and waiting for a short amount of time, two machines in status `PXE booting` become visible through `metalctl machine ls`:
9387
9488
```bash
95-
docker-compose run --rm metalctl machine ls
89+
docker compose run --rm metalctl machine ls
9690
9791
ID LAST EVENT WHEN AGE HOSTNAME PROJECT SIZE IMAGE PARTITION
9892
e0ab02d2-27cd-5a5e-8efc-080ba80cf258   PXE Booting 3s
@@ -102,7 +96,7 @@ e0ab02d2-27cd-5a5e-8efc-080ba80cf258   PXE Booting 3s
10296
Wait until the machines reach the waiting state:
10397
10498
```bash
105-
docker-compose run --rm metalctl machine ls
99+
docker compose run --rm metalctl machine ls
106100
107101
ID LAST EVENT WHEN AGE HOSTNAME PROJECT SIZE IMAGE PARTITION
108102
e0ab02d2-27cd-5a5e-8efc-080ba80cf258   Waiting 8s v1-small-x86 mini-lab
@@ -119,13 +113,13 @@ make machine
119113
__Alternatively__, you may want to issue the `metalctl` commands on your own:
120114
121115
```bash
122-
docker-compose run --rm metalctl network allocate \
116+
docker compose run --rm metalctl network allocate \
123117
--partition mini-lab \
124118
--project 00000000-0000-0000-0000-000000000000 \
125119
--name user-private-network
126120
127121
# lookup the network ID and create a machine
128-
docker-compose run --rm metalctl machine create \
122+
docker compose run --rm metalctl machine create \
129123
--description test \
130124
--name machine \
131125
--hostname machine \
@@ -136,7 +130,7 @@ docker-compose run --rm metalctl machine create \
136130
--networks <network-ID>
137131
138132
# create a firewall that is also connected to the virtual internet-mini-lab network
139-
docker-compose run --rm metalctl machine create \
133+
docker compose run --rm metalctl machine create \
140134
--description fw \
141135
--name fw \
142136
--hostname fw \
@@ -160,7 +154,7 @@ machine login:
160154
Two machines are now installed and have status "Phoned Home"
161155
162156
```bash
163-
docker-compose run --rm metalctl machine ls
157+
docker compose run --rm metalctl machine ls
164158
ID LAST EVENT WHEN AGE HOSTNAME PROJECT SIZE IMAGE PARTITION
165159
e0ab02d2-27cd-5a5e-8efc-080ba80cf258   Phoned Home 2s 21s machine 00000000-0000-0000-0000-000000000000 v1-small-x86 Ubuntu 20.04 20200331 mini-lab
166160
2294c949-88f6-5390-8154-fa53d93a3313   Phoned Home 8s 18s fw 00000000-0000-0000-0000-000000000000 v1-small-x86 Firewall 2 Ubuntu 20200730 mini-lab
@@ -169,7 +163,7 @@ e0ab02d2-27cd-5a5e-8efc-080ba80cf258   Phoned Home 2s 21s machin
169163
Login with user name metal and the console password from
170164
171165
```bash
172-
docker-compose run --rm metalctl machine consolepassword e0ab02d2-27cd-5a5e-8efc-080ba80cf258
166+
docker compose run --rm metalctl machine consolepassword e0ab02d2-27cd-5a5e-8efc-080ba80cf258
173167
```
174168
175169
If you want to access the firewall with SSH or have internet connectivity from the firewall and machine, you'll need to have a static route configured that points to the leaf switches:
@@ -193,7 +187,7 @@ make cleanup
193187
Reinstall a machine with
194188

195189
```bash
196-
docker-compose run --rm metalctl machine reinstall \
190+
docker compose run --rm metalctl machine reinstall \
197191
--image ubuntu-20.04 \
198192
e0ab02d2-27cd-5a5e-8efc-080ba80cf258
199193
```
@@ -203,7 +197,7 @@ docker-compose run --rm metalctl machine reinstall \
203197
Free a machine with `make free-machine01` or
204198

205199
```bash
206-
docker-compose run --rm metalctl machine rm e0ab02d2-27cd-5a5e-8efc-080ba80cf258
200+
docker compose run --rm metalctl machine rm e0ab02d2-27cd-5a5e-8efc-080ba80cf258
207201
```
208202

209203
## Flavors

docker-compose.yml renamed to compose.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
---
2-
version: '3.7'
3-
42
services:
53
control-plane:
64
image: ghcr.io/metal-stack/metal-deployment-base:${DEPLOYMENT_BASE_IMAGE_TAG}
75
container_name: deploy-control-plane
86
volumes:
9-
- /var/run/docker.sock:/var/run/docker.sock
7+
- /var/run/docker.sock:/var/run/docker.sock:z
108
- .:/mini-lab
119
# for developing role dependencies
1210
# TODO: make this a switch
@@ -43,7 +41,7 @@ services:
4341
image: ghcr.io/metal-stack/metal-deployment-base:${DEPLOYMENT_BASE_IMAGE_TAG}
4442
container_name: deploy-partition
4543
volumes:
46-
- /var/run/docker.sock:/var/run/docker.sock
44+
- /var/run/docker.sock:/var/run/docker.sock:z
4745
- .:/mini-lab
4846
# for developing role dependencies
4947
# TODO: make this a switch

control-plane/kind.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ networking:
55
apiServerAddress: 0.0.0.0
66
nodes:
77
- role: control-plane
8+
image: kindest/node:v1.25.11@sha256:227fa11ce74ea76a0474eeefb84cb75d8dad1b08638371ecf0e86259b35be0c8
89
extraPortMappings:
910
- containerPort: 4443
1011
hostPort: 4443

test/integration.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ echo "Starting mini-lab"
55
make up
66

77
echo "Waiting for machines to get to waiting state"
8-
waiting=$(docker-compose run -T metalctl machine ls | grep Waiting | wc -l)
8+
waiting=$(docker compose run -T metalctl machine ls | grep Waiting | wc -l)
99
minWaiting=2
1010
declare -i attempts=0
1111
until [ "$waiting" -ge $minWaiting ]
@@ -16,7 +16,7 @@ do
1616
fi
1717
echo "$waiting/$minWaiting machines are waiting"
1818
sleep 5
19-
waiting=$(docker-compose run -T metalctl machine ls | grep Waiting | wc -l)
19+
waiting=$(docker compose run -T metalctl machine ls | grep Waiting | wc -l)
2020
attempts=$attempts+1
2121
done
2222
echo "$waiting/$minWaiting machines are waiting"
@@ -26,7 +26,7 @@ make firewall
2626
make machine
2727

2828
echo "Waiting for machines to get to Phoned Home state"
29-
phoned=$(docker-compose run -T metalctl machine ls | grep Phoned | wc -l)
29+
phoned=$(docker compose run -T metalctl machine ls | grep Phoned | wc -l)
3030
minPhoned=2
3131
declare -i attempts=0
3232
until [ "$phoned" -ge $minPhoned ]
@@ -37,7 +37,7 @@ do
3737
fi
3838
echo "$phoned/$minPhoned machines have phoned home"
3939
sleep 5
40-
phoned=$(docker-compose run -T metalctl machine ls | grep Phoned | wc -l)
40+
phoned=$(docker compose run -T metalctl machine ls | grep Phoned | wc -l)
4141
attempts+=1
4242
done
4343
echo "$phoned/$minPhoned machines have phoned home"

0 commit comments

Comments
 (0)