Skip to content

Commit

Permalink
Update kind-with-registry.sh to be reusable
Browse files Browse the repository at this point in the history
- Make the registry port configurable
- The run command complained it couldn't start a new container, so
delete the old one first to allow it to run.
- Remove `kind version` because it's already run in `make test-cluster`

Signed-off-by: Dale Haiducek <[email protected]>
  • Loading branch information
dhaiducek committed Nov 2, 2023
1 parent 87b5d7d commit 658d7fa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ jobs:
- name: Create K8s KinD Cluster
run: |
kind version
make test-cluster
- name: Build and Push Test Container Image to KIND node
Expand Down Expand Up @@ -123,7 +122,6 @@ jobs:
- name: Create K8s KinD Cluster
run: |
kind version
make test-cluster
- name: Build and Push Test Container Image to KIND node
Expand Down
13 changes: 10 additions & 3 deletions scripts/kind-with-registry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@ set -o errexit
KIND_CLUSTER_NAME="${KIND_CLUSTER_NAME:-kind}"
KIND_IMG_TAG="${KIND_IMG_TAG:-}"

# create registry container unless it already exists
# create registry container unless it's already running
reg_name='kind-registry'
reg_port='5000'
running="$(docker inspect -f '{{.State.Running}}' "${reg_name}" 2>/dev/null || true)"
reg_port=${REGISTRY_PORT:-'5000'}
echo "Checking for running ${reg_name} container..."
running="$(docker inspect -f '{{.State.Running}}' "${reg_name}" || true)"
if [ "${running}" != 'true' ]; then
REG_CONTAINER_ID="$(docker inspect -f '{{.Id}}' "${reg_name}" || true)"
if [[ -n "${REG_CONTAINER_ID}" ]]; then
echo "Removing existing container:"
docker rm ${REG_CONTAINER_ID}
fi
echo "Starting new ${reg_name} container:"
docker run \
-d --restart=always -p "${reg_port}:5000" --name "${reg_name}" \
registry:2
Expand Down

0 comments on commit 658d7fa

Please sign in to comment.