Skip to content

Commit 25ba451

Browse files
committed
Separate the create and shutdown of local-registry from kind-cluster
1 parent 57e5d4b commit 25ba451

File tree

3 files changed

+44
-15
lines changed

3 files changed

+44
-15
lines changed

Makefile

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,12 +285,19 @@ release/docs:
285285

286286
# Other commands
287287

288-
.PHONY: kind-up
289-
kind-up:
288+
.PHONY: up/local-registry
289+
up/local-registry:
290+
./hack/create-local-registry.sh
291+
292+
.PHONY: up/kind-cluster
293+
up/kind-cluster:
290294
./hack/create-kind-cluster.sh pipecd
291295

292-
.PHONY: kind-down
293-
kind-down:
296+
.PHONY: up/local-cluster
297+
up/local-cluster: up/local-registry up/kind-cluster
298+
299+
.PHONY: down/local-cluster
300+
down/local-cluster:
294301
kind delete cluster --name pipecd
295302
docker container rm -f kind-registry 2>/dev/null
296303

hack/create-kind-cluster.sh

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,6 @@ CLUSTER=$1
3636
REG_NAME='kind-registry'
3737
REG_PORT='5001'
3838

39-
# Create registry container unless it already exists
40-
echo "Creating local registry container..."
41-
running="$(docker inspect -f '{{.State.Running}}' "${REG_NAME}" 2>/dev/null || true)"
42-
if [ "${running}" != 'true' ]; then
43-
docker run \
44-
-e REGISTRY_HTTP_ADDR=0.0.0.0:5001 \
45-
-d --restart=always -p "127.0.0.1:${REG_PORT}:5001" --name "${REG_NAME}" \
46-
registry:2
47-
fi
48-
4939
# Create a cluster with the local registry enabled in containerd
5040
REG_CONFIG_DIR="/etc/containerd/certs.d"
5141
cat <<EOF | kind create cluster --name ${CLUSTER} --config=-
@@ -57,7 +47,7 @@ containerdConfigPatches:
5747
config_path = "${REG_CONFIG_DIR}"
5848
EOF
5949

60-
# Connect the registry to the cluster network
50+
# Connect the local registry to the cluster network
6151
if [ "$(docker inspect -f='{{json .NetworkSettings.Networks.kind}}' "${REG_NAME}")" = 'null' ]; then
6252
docker network connect "kind" "${REG_NAME}"
6353
fi

hack/create-local-registry.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2025 The PipeCD Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -o errexit
18+
set -o nounset
19+
set -o pipefail
20+
21+
REG_NAME='kind-registry'
22+
REG_PORT='5001'
23+
24+
# Create registry container unless it already exists
25+
echo "Creating local registry container..."
26+
running="$(docker inspect -f '{{.State.Running}}' "${REG_NAME}" 2>/dev/null || true)"
27+
if [ "${running}" != 'true' ]; then
28+
docker run \
29+
-e REGISTRY_HTTP_ADDR=0.0.0.0:5001 \
30+
-d --restart=always -p "127.0.0.1:${REG_PORT}:5001" --name "${REG_NAME}" \
31+
registry:2
32+
fi

0 commit comments

Comments
 (0)