Skip to content

Commit 6ec1a44

Browse files
committed
kind-common, metallb: Avoid hard coding container runtime binary
Set OCI_BIN according to env. Some inspect operation that use formatting did not work in podman due to formatting differences comparing to docker. The format string is changes to a form that fits both docker and podman With the new format string, the index keyword is redundant hence removed. Signed-off-by: Or Mergi <[email protected]>
1 parent 0e00ae6 commit 6ec1a44

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

contrib/kind-common

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -174,16 +174,16 @@ EOF
174174
# Override GOBIN until https://github.com/metallb/metallb/issues/2218 is fixed.
175175
GOBIN="" inv dev-env -n ovn -b frr -p bgp -i "${ip_family}"
176176

177-
docker network rm -f clientnet
178-
docker network create --subnet="${METALLB_CLIENT_NET_SUBNET_IPV4}" ${ipv6_network} --driver bridge clientnet
179-
docker network connect clientnet frr
177+
$OCI_BIN network rm -f clientnet
178+
$OCI_BIN network create --subnet="${METALLB_CLIENT_NET_SUBNET_IPV4}" ${ipv6_network} --driver bridge clientnet
179+
$OCI_BIN network connect clientnet frr
180180
if [ "$PLATFORM_IPV6_SUPPORT" == true ]; then
181181
# Enable IPv6 forwarding in FRR
182-
docker exec frr sysctl -w net.ipv6.conf.all.forwarding=1
182+
$OCI_BIN exec frr sysctl -w net.ipv6.conf.all.forwarding=1
183183
fi
184184
# Note: this image let's us use it also for creating load balancer backends that can send big packets
185-
docker rm -f lbclient
186-
docker run --cap-add NET_ADMIN --user 0 -d --network clientnet --rm --name lbclient quay.io/itssurya/dev-images:metallb-lbservice
185+
$OCI_BIN rm -f lbclient
186+
$OCI_BIN run --cap-add NET_ADMIN --user 0 -d --network clientnet --rm --name lbclient quay.io/itssurya/dev-images:metallb-lbservice
187187
popd
188188
delete_metallb_dir
189189

@@ -197,18 +197,18 @@ EOF
197197
kubectl label node "$n" node.kubernetes.io/exclude-from-external-load-balancers-
198198
done
199199

200-
kind_network_v4=$(docker inspect -f '{{index .NetworkSettings.Networks "kind" "IPAddress"}}' frr)
200+
kind_network_v4=$($OCI_BIN inspect -f '{{.NetworkSettings.Networks.kind.IPAddress}}' frr)
201201
echo "FRR kind network IPv4: ${kind_network_v4}"
202-
kind_network_v6=$(docker inspect -f '{{index .NetworkSettings.Networks "kind" "GlobalIPv6Address"}}' frr)
202+
kind_network_v6=$($OCI_BIN inspect -f '{{.NetworkSettings.Networks.kind.GlobalIPv6Address}}' frr)
203203
echo "FRR kind network IPv6: ${kind_network_v6}"
204204
local client_network_v4 client_network_v6
205-
client_network_v4=$(docker inspect -f '{{index .NetworkSettings.Networks "clientnet" "IPAddress"}}' frr)
205+
client_network_v4=$($OCI_BIN inspect -f '{{.NetworkSettings.Networks.clientnet.IPAddress}}' frr)
206206
echo "FRR client network IPv4: ${client_network_v4}"
207-
client_network_v6=$(docker inspect -f '{{index .NetworkSettings.Networks "clientnet" "GlobalIPv6Address"}}' frr)
207+
client_network_v6=$($OCI_BIN inspect -f '{{.NetworkSettings.Networks.clientnet.GlobalIPv6Address}}' frr)
208208
echo "FRR client network IPv6: ${client_network_v6}"
209209

210210
local client_subnets
211-
client_subnets=$(docker network inspect clientnet -f '{{range .IPAM.Config}}{{.Subnet}}#{{end}}')
211+
client_subnets=$($OCI_BIN network inspect clientnet -f '{{range .IPAM.Config}}{{.Subnet}}#{{end}}')
212212
echo "${client_subnets}"
213213
local client_subnets_v4 client_subnets_v6
214214
client_subnets_v4=$(echo "${client_subnets}" | cut -d '#' -f 1)
@@ -219,21 +219,21 @@ EOF
219219
KIND_NODES=$(kind_get_nodes)
220220
for n in ${KIND_NODES}; do
221221
if [ "$PLATFORM_IPV4_SUPPORT" == true ]; then
222-
docker exec "${n}" ip route add "${client_subnets_v4}" via "${kind_network_v4}"
222+
$OCI_BIN exec "${n}" ip route add "${client_subnets_v4}" via "${kind_network_v4}"
223223
fi
224224
if [ "$PLATFORM_IPV6_SUPPORT" == true ]; then
225-
docker exec "${n}" ip -6 route add "${client_subnets_v6}" via "${kind_network_v6}"
225+
$OCI_BIN exec "${n}" ip -6 route add "${client_subnets_v6}" via "${kind_network_v6}"
226226
fi
227227
done
228228

229229
# for now, we only run one test with metalLB load balancer for which this
230230
# one svcVIP (192.168.10.0/fc00:f853:ccd:e799::) is more than enough since at a time we will only
231231
# have one load balancer service
232232
if [ "$PLATFORM_IPV4_SUPPORT" == true ]; then
233-
docker exec lbclient ip route add 192.168.10.0 via "${client_network_v4}" dev eth0
233+
$OCI_BIN exec lbclient ip route add 192.168.10.0 via "${client_network_v4}" dev eth0
234234
fi
235235
if [ "$PLATFORM_IPV6_SUPPORT" == true ]; then
236-
docker exec lbclient ip -6 route add fc00:f853:ccd:e799:: via "${client_network_v6}" dev eth0
236+
$OCI_BIN exec lbclient ip -6 route add fc00:f853:ccd:e799:: via "${client_network_v6}" dev eth0
237237
fi
238238
sleep 30
239239
}
@@ -254,14 +254,14 @@ install_plugins() {
254254
}
255255

256256
destroy_metallb() {
257-
if docker ps --format '{{.Names}}' | grep -Eq '^lbclient$'; then
258-
docker stop lbclient
257+
if $OCI_BIN ps --format '{{.Names}}' | grep -Eq '^lbclient$'; then
258+
$OCI_BIN stop lbclient
259259
fi
260-
if docker ps --format '{{.Names}}' | grep -Eq '^frr$'; then
261-
docker stop frr
260+
if $OCI_BIN ps --format '{{.Names}}' | grep -Eq '^frr$'; then
261+
$OCI_BIN stop frr
262262
fi
263-
if docker network ls --format '{{.Name}}' | grep -q '^clientnet$'; then
264-
docker network rm clientnet
263+
if $OCI_BIN network ls --format '{{.Name}}' | grep -q '^clientnet$'; then
264+
$OCI_BIN network rm clientnet
265265
fi
266266
delete_metallb_dir
267267
}

0 commit comments

Comments
 (0)