diff --git a/Makefile b/Makefile index 4663571d..ec523ae2 100644 --- a/Makefile +++ b/Makefile @@ -111,10 +111,7 @@ kind-create: FORCE echo "Kind is not installed. Please install Kind manually."; \ exit 1; \ } - @kind get clusters | grep -q $(KIND_CLUSTER) || { \ - printf "\e[1;36m>> kind create cluster --name=$(KIND_CLUSTER)\e[0m\n"; \ - kind create cluster --name=$(KIND_CLUSTER); \ - } + KIND_CLUSTER_NAME=$(KIND_CLUSTER) CONTAINER_TOOL=$(CONTAINER_TOOL) ./hack/kind-with-registry.sh # Delete the Kind cluster created for local development and testing. kind-delete: FORCE @@ -123,7 +120,8 @@ kind-delete: FORCE exit 1; \ } @printf "\e[1;36m>> kind delete cluster --name=$(KIND_CLUSTER)\e[0m\n" - @kind delete cluster --name=$(KIND_CLUSTER) + KIND_EXPERIMENTAL_PROVIDER=$(CONTAINER_TOOL) kind delete cluster --name=$(KIND_CLUSTER) + $(CONTAINER_TOOL) stop kind-registry && $(CONTAINER_TOOL) rm kind-registry tilt-up: FORCE kind-create @command -v tilt >/dev/null 2>&1 || { \ diff --git a/Makefile.maker.yaml b/Makefile.maker.yaml index 5bb351ae..57293e76 100644 --- a/Makefile.maker.yaml +++ b/Makefile.maker.yaml @@ -149,10 +149,7 @@ verbatim: | echo "Kind is not installed. Please install Kind manually."; \ exit 1; \ } - @kind get clusters | grep -q $(KIND_CLUSTER) || { \ - printf "\e[1;36m>> kind create cluster --name=$(KIND_CLUSTER)\e[0m\n"; \ - kind create cluster --name=$(KIND_CLUSTER); \ - } + KIND_CLUSTER_NAME=$(KIND_CLUSTER) CONTAINER_TOOL=$(CONTAINER_TOOL) ./hack/kind-with-registry.sh # Delete the Kind cluster created for local development and testing. kind-delete: FORCE @@ -161,7 +158,8 @@ verbatim: | exit 1; \ } @printf "\e[1;36m>> kind delete cluster --name=$(KIND_CLUSTER)\e[0m\n" - @kind delete cluster --name=$(KIND_CLUSTER) + KIND_EXPERIMENTAL_PROVIDER=$(CONTAINER_TOOL) kind delete cluster --name=$(KIND_CLUSTER) + $(CONTAINER_TOOL) stop kind-registry && $(CONTAINER_TOOL) rm kind-registry tilt-up: FORCE kind-create @command -v tilt >/dev/null 2>&1 || { \ diff --git a/hack/kind-with-registry.sh b/hack/kind-with-registry.sh new file mode 100755 index 00000000..fabecd44 --- /dev/null +++ b/hack/kind-with-registry.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +# SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and IronCore contributors +# SPDX-License-Identifier: Apache-2.0 +set -o errexit +set -o nounset +set -o pipefail + +CONTAINER_TOOL="${CONTAINER_TOOL:-docker}" +KIND_CLUSTER_NAME="${KIND_CLUSTER_NAME:-kind}" +export KIND_EXPERIMENTAL_PROVIDER="${CONTAINER_TOOL}" + +# Exit early if the cluster already exists +if kind get clusters | grep -q "^${KIND_CLUSTER_NAME}$"; then + echo "Cluster ${KIND_CLUSTER_NAME} already exists" + exit 0 +fi + +# 1. Create registry container unless it already exists +REGISTRY_NAME='kind-registry' +REGISTRY_PORT="${KIND_REGISTRY_PORT:-5000}" +if [ "$("${CONTAINER_TOOL}" inspect -f '{{.State.Running}}' "${REGISTRY_NAME}" 2>/dev/null || true)" != 'true' ]; then + "${CONTAINER_TOOL}" run -d --restart=always -p "127.0.0.1:${REGISTRY_PORT}:5000" --network bridge --name "${REGISTRY_NAME}" registry:3 +fi + +# 2. Create kind cluster +cat <