Skip to content

Commit

Permalink
build: Use goreman for starting locally. (#3074)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexec committed May 21, 2020
1 parent 5b5bae9 commit 784c138
Show file tree
Hide file tree
Showing 9 changed files with 204 additions and 39 deletions.
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ commands:
- checkout
- maybe_skip_job
- install_kustomize
- run:
name: Preemptively pull images
command: make pull-build-images test-images
background: true
- run:
name: Install and start K3S v1.0.1
command: curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.0.1 INSTALL_K3S_EXEC=--docker K3S_KUBECONFIG_MODE=644 sh -
background: true
- restore_go_cache
- install_golang
- run:
name: Preemptively pull images
command: make pull-build-images test-images
background: true
- restore_go_mod
- run: go mod download
- run:
Expand Down
56 changes: 21 additions & 35 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,12 @@ STATIC_BUILD ?= true
CI ?= false
DB ?= postgres
K3D := $(shell if [ "`which kubectl`" != '' ] && [ "`kubectl config current-context`" = "k3s-default" ]; then echo true; else echo false; fi)
# which components to start, useful if you want to disable them to debug
COMPONENTS := controller,argo-server
LOG_LEVEL := debug
ALWAYS_OFFLOAD_NODE_STATUS := true

ifeq ($(DB),no-db)
ALWAYS_OFFLOAD_NODE_STATUS := false
endif

ifeq ($(CI),true)
TEST_OPTS := -coverprofile=coverage.out
Expand Down Expand Up @@ -125,6 +128,10 @@ define docker_build
if [ $(K3D) = true ]; then k3d import-images $(IMAGE_NAMESPACE)/$(1):$(VERSION); fi
touch $(3)
endef
define docker_pull
docker pull $(1)
if [ $(K3D) = true ]; then k3d import-images $(1); fi
endef

.PHONY: build
build: status clis executor-image controller-image manifests/install.yaml manifests/namespace-install.yaml manifests/quick-start-postgres.yaml manifests/quick-start-mysql.yaml
Expand Down Expand Up @@ -310,32 +317,17 @@ $(VERSION_FILE):
@mkdir -p dist
touch $(VERSION_FILE)

dist/postgres.yaml: $(MANIFESTS) $(E2E_MANIFESTS) $(VERSION_FILE)
kustomize build --load_restrictor=none test/e2e/manifests/postgres | sed 's/:$(MANIFESTS_VERSION)/:$(VERSION)/' | sed 's/pns/$(E2E_EXECUTOR)/' > dist/postgres.yaml

dist/no-db.yaml: $(MANIFESTS) $(E2E_MANIFESTS) $(VERSION_FILE)
dist/$(DB).yaml: $(MANIFESTS) $(E2E_MANIFESTS) $(VERSION_FILE)
# We additionally disable ALWAYS_OFFLOAD_NODE_STATUS
kustomize build --load_restrictor=none test/e2e/manifests/no-db | sed 's/:$(MANIFESTS_VERSION)/:$(VERSION)/' | sed 's/pns/$(E2E_EXECUTOR)/' | sed 's/"true"/"false"/' > dist/no-db.yaml

dist/mysql.yaml: $(MANIFESTS) $(E2E_MANIFESTS) $(VERSION_FILE)
kustomize build --load_restrictor=none test/e2e/manifests/mysql | sed 's/:$(MANIFESTS_VERSION)/:$(VERSION)/' | sed 's/pns/$(E2E_EXECUTOR)/' > dist/mysql.yaml
kustomize build --load_restrictor=none test/e2e/manifests/$(DB) | sed 's/:$(MANIFESTS_VERSION)/:$(VERSION)/' | sed 's/pns/$(E2E_EXECUTOR)/' > dist/$(DB).yaml

.PHONY: install
install: dist/postgres.yaml dist/mysql.yaml dist/no-db.yaml
install: dist/$(DB).yaml
ifeq ($(K3D),true)
k3d start
endif
# Install quick-start
kubectl apply -f test/e2e/manifests/argo-ns.yaml
ifeq ($(DB),postgres)
kubectl -n argo apply -f dist/postgres.yaml
else
ifeq ($(DB),mysql)
kubectl -n argo apply -f dist/mysql.yaml
else
kubectl -n argo apply -f dist/no-db.yaml
endif
endif
kubectl -n argo apply -l app.kubernetes.io/part-of=argo --prune --force -f dist/$(DB).yaml

.PHONY: pull-build-images
pull-build-images:
Expand All @@ -354,43 +346,37 @@ test/e2e/images/argosay/v2/argosay: $(shell find test/e2e/images/argosay/v2/main

.PHONY: test-images
test-images:
docker pull argoproj/argosay:v1
docker pull argoproj/argosay:v2
docker pull python:alpine3.6
$(call docker_pull,argoproj/argosay:v1)
$(call docker_pull,argoproj/argosay:v2)
$(call docker_pull,python:alpine3.6)

.PHONY: stop
stop:
killall argo workflow-controller pf.sh kubectl || true

$(GOPATH)/bin/goreman:
go get github.com/mattn/goreman

.PHONY: start-aux
start-aux:
start-aux: $(GOPATH)/bin/goreman
kubectl config set-context --current --namespace=argo
kubectl -n argo wait --for=condition=Ready pod --all -l app --timeout 2m
./hack/port-forward.sh
# Check minio, postgres and mysql are in hosts file
grep '127.0.0.1 *minio' /etc/hosts
grep '127.0.0.1 *postgres' /etc/hosts
grep '127.0.0.1 *mysql' /etc/hosts
ifneq ($(findstring controller,$(COMPONENTS)),)
ALWAYS_OFFLOAD_NODE_STATUS=true OFFLOAD_NODE_STATUS_TTL=30s WORKFLOW_GC_PERIOD=30s UPPERIO_DB_DEBUG=1 ARCHIVED_WORKFLOW_GC_PERIOD=30s ./dist/workflow-controller --executor-image argoproj/argoexec:$(VERSION) --namespaced --loglevel $(LOG_LEVEL) &
endif
ifneq ($(findstring argo-server,$(COMPONENTS)),)
UPPERIO_DB_DEBUG=1 ./dist/argo --loglevel $(LOG_LEVEL) server --namespaced --auth-mode client --secure &
endif
env ALWAYS_OFFLOAD_NODE_STATUS=$(ALWAYS_OFFLOAD_NODE_STATUS) LOG_LEVEL=$(LOG_LEVEL) VERSION=$(VERSION) goreman -set-ports=false -logtime=false start

.PHONY: start
start: status stop install controller cli executor-image start-aux wait env

.PHONY: wait
wait:
ifneq ($(findstring controller,$(COMPONENTS)),)
# Wait for workflow controller
until lsof -i :9090 > /dev/null ; do sleep 10s ; done
endif
ifneq ($(findstring argo-server,$(COMPONENTS)),)
# Wait for Argo Server
until lsof -i :2746 > /dev/null ; do sleep 10s ; done
endif

define print_env
export ARGO_SERVER=localhost:2746
Expand Down
2 changes: 2 additions & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
controller: ALWAYS_OFFLOAD_NODE_STATUS=${ALWAYS_OFFLOAD_NODE_STATUS} OFFLOAD_NODE_STATUS_TTL=30s WORKFLOW_GC_PERIOD=30s UPPERIO_DB_DEBUG=1 ARCHIVED_WORKFLOW_GC_PERIOD=30s ./dist/workflow-controller --executor-image argoproj/argoexec:${VERSION} --namespaced --loglevel ${LOG_LEVEL}
argo-server: UPPERIO_DB_DEBUG=1 ./dist/argo --loglevel ${LOG_LEVEL} server --namespaced --auth-mode client --secure
Loading

0 comments on commit 784c138

Please sign in to comment.