Skip to content

Commit

Permalink
Add targets to deploy/undeploy local registry
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Pavlov <[email protected]>
  • Loading branch information
Kshatrix committed Jun 5, 2024
1 parent c9d492a commit 5cb6028
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ hmc-chart-generate: kustomize helmify ## Generate hmc helm chart
##@ Deployment

KIND_CLUSTER_NAME ?= hmc-dev
KIND_NETWORK ?= kind
LOCAL_REGISTRY_NAME ?= hmc-local-registry
LOCAL_REGISTRY_PORT ?= 5001

Expand All @@ -149,15 +150,20 @@ undeploy-kind: kind

.PHONY: deploy-local-registry
deploy-local-registry:
@if [ ! "`$(CONTAINER_TOOL) ps -aq -f name=$(LOCAL_REGISTRY_NAME)`" ]; then \
$(CONTAINER_TOOL) run -d --restart=always -p "127.0.0.1:$(LOCAL_REGISTRY_PORT):5000" --network bridge --name "$(LOCAL_REGISTRY_NAME)" registry:2; \
fi
@if [ ! "$$($(CONTAINER_TOOL) ps -aq -f name=$(LOCAL_REGISTRY_NAME))" ]; then \
echo "Starting new local registry container $(LOCAL_REGISTRY_NAME)"; \
$(CONTAINER_TOOL) run -d --restart=always -p "127.0.0.1:$(LOCAL_REGISTRY_PORT):5000" --network bridge --name "$(LOCAL_REGISTRY_NAME)" registry:2; \
fi; \
if [ "$$($(CONTAINER_TOOL) inspect -f='{{json .NetworkSettings.Networks.$(KIND_NETWORK)}}' $(LOCAL_REGISTRY_NAME))" = 'null' ]; then \
$(CONTAINER_TOOL) network connect $(KIND_NETWORK) $(LOCAL_REGISTRY_NAME); \
fi

.PHONY: undeploy-local-registry
undeploy-local-registry:
@if [ "`$(CONTAINER_TOOL) ps -aq -f name=$(LOCAL_REGISTRY_NAME)`" ]; then \
$(CONTAINER_TOOL) rm -f "$(LOCAL_REGISTRY_NAME)"; \
fi
@if [ "$$($(CONTAINER_TOOL) ps -aq -f name=$(LOCAL_REGISTRY_NAME))" ]; then \
echo "Removing local registry container $(LOCAL_REGISTRY_NAME)"; \
$(CONTAINER_TOOL) rm -f "$(LOCAL_REGISTRY_NAME)"; \
fi

.PHONY: deploy-helm-controller
deploy-helm-controller: helm
Expand Down

0 comments on commit 5cb6028

Please sign in to comment.