Skip to content

Commit

Permalink
terratest #1
Browse files Browse the repository at this point in the history
  • Loading branch information
kuritka committed Dec 2, 2020
1 parent fefffbc commit 129f577
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ CLUSTER_GSLB2_HELM_ARGS ?= --set k8gb.clusterGeoTag='us' --set k8gb.extGslbClust

# terratest
GITACTION_TERRATEST_DOCKER_REPO_PORT ?= 5000
GITACTION_TERRATEST_DOCKER_REPO_NAME ?= kind-registry
GITACTION_TERRATEST_DOCKER_REPO_NAME ?= k3d-registry
GITACTION_TERRATEST_DOCKER_REPO_IMAGE ?= registry:2

ifndef NO_COLOR
Expand All @@ -32,8 +32,8 @@ NO_VALUE ?= no_value
# VARIABLES
###############################

# shell script inspects whether kind registry is running or not
KIND_REGISTRY_RUNNING ?= $(shell docker inspect -f '{{.State.Running}}' "test-gslb2-control-plane" || true)
# shell script inspects whether k3d registry is running or not
K3D_REGISTRY_RUNNING ?= $(shell docker inspect -f '{{.State.Running}}' "test-gslb2-control-plane" || true)

VERSION ?= $(shell helm show chart chart/k8gb/|awk '/appVersion:/ {print $$2}')

Expand Down Expand Up @@ -114,7 +114,7 @@ deploy-full-local-setup:
# triggered by terraform GitHub Action. Clusters already exists. GO is not installed yet
.PHONY: deploy-full-terratest-setup
deploy-full-terratest-setup:
@echo "\n$(YELLOW)create docker registry$(NC) see: https://kind.sigs.k8s.io/docs/user/local-registry/"
@echo "\n$(YELLOW)create local docker registry$(NC) $(GITACTION_TERRATEST_DOCKER_REPO_NAME)"
docker run -d --restart=always -p "$(GITACTION_TERRATEST_DOCKER_REPO_PORT):5000" --name "$(GITACTION_TERRATEST_DOCKER_REPO_NAME)" "$(GITACTION_TERRATEST_DOCKER_REPO_IMAGE)"

@echo "\n$(YELLOW)build k8gb docker and push to registry $(NC)"
Expand All @@ -125,13 +125,17 @@ deploy-full-terratest-setup:
@echo "\n$(YELLOW)Change version in Chart.yaml $(CYAN) $(VERSION) to $(COMMIT_HASH)$(NC)"
sed -i "s/$(VERSION)/$(COMMIT_HASH)/g" chart/k8gb/Chart.yaml

$(call deploy-local-cluster,$(CLUSTER_GSLB1),$(CLUSTER_GSLB2),control-plane,localhost:$(GITACTION_TERRATEST_DOCKER_REPO_PORT)/k8gb,)
$(call deploy-local-cluster,$(CLUSTER_GSLB2),$(CLUSTER_GSLB1),control-plane,localhost:$(GITACTION_TERRATEST_DOCKER_REPO_PORT)/k8gb,$(CLUSTER_GSLB2_HELM_ARGS))
@echo "\n$(YELLOW)Deploy $(CYAN) $(CLUSTER_GSLB1),$(CLUSTER_GSLB2)$(NC)"
docker network create --driver=bridge --subnet=172.16.0.0/24 $(CLUSTER_GSLB_NETWORK)
$(call create-local-cluster,$(CLUSTER_GSLB1),-p "80:80@agent[0]" -p "443:443@agent[0]" -p "5053:53/udp@agent[0]" )
$(call create-local-cluster,$(CLUSTER_GSLB2),-p "81:80@agent[0]" -p "444:443@agent[0]" -p "5054:53/udp@agent[0]" )
$(call deploy-local-cluster,$(CLUSTER_GSLB1),$(CLUSTER_GSLB2),localhost:$(GITACTION_TERRATEST_DOCKER_REPO_PORT)/k8gb,)
$(call deploy-local-cluster,$(CLUSTER_GSLB2),$(CLUSTER_GSLB1),localhost:$(GITACTION_TERRATEST_DOCKER_REPO_PORT)/k8gb,$(CLUSTER_GSLB2_HELM_ARGS))

@echo "\n$(YELLOW)Local cluster $(CYAN)$(CLUSTER_GSLB2) $(NC)"
kubectl get pods -A
@echo "\n$(YELLOW)Local cluster $(CYAN)$(CLUSTER_GSLB1) $(NC)"
kubectl config use-context kind-$(CLUSTER_GSLB1)
kubectl config use-context k3d-$(CLUSTER_GSLB1)
kubectl get pods -A

.PHONY: deploy-gslb-operator
Expand Down

0 comments on commit 129f577

Please sign in to comment.