From d9f18af701726d4c6e9fa8f28d033af0ad572cc6 Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Thu, 19 Oct 2023 21:48:05 -0500 Subject: [PATCH] Add deployment and debugging Makefile targets Signed-off-by: Dean Troyer --- Makefile | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/Makefile b/Makefile index c706701..184b78e 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,40 @@ # virtual-kubelet-saladcloud +# Standard Development Targets +# build - build the project, binaries go into ./bin +# build-image - build a Docker image with the virtual-kubelet binary +# clean - clean up built binaries and cached Go artifacts +# lint - run golangci-lint (set args in LINT_ARGS) +# tidy - "go mod tidy" + +# Deployment and Debug Targets +# install - install the Docker image into the current k8s environment +# (add additional args in INSTALL_ARGS) +# dry-install - run install with --dry-run +# uninstall - delete the Docker image deployment from the current k8s environment +# run - run bin/virtual-kubelet in the foreground using the SCE_* environment variables + +IMAGE_TAG ?= latest + +NAMESPACE ?= saladcloud +DEPLOYMENT_NAME ?= mysaladcloud + +# These must be defined in the environmnet before executing 'make install' +SCE_API_KEY ?= api-key +SCE_ORGANIZATION_NAME ?= org-name +SCE_PROJECT_NAME ?= project-name + +# Development targets + .PHONY: build build: CGO_ENABLED=0 build: go build -o ./bin/virtual-kubelet ./cmd/virtual-kubelet/main.go +.PHONY: build-image +build-image: + docker build --tag ghcr.io/saladtechnologies/virtual-kubelet-saladcloud:$(IMAGE_TAG) --file docker/Dockerfile . + .PHONY: clean clean: rm -rf ./bin @@ -19,3 +49,40 @@ test: tidy: go mod tidy + +# Deploy and debug targets + +# Install and start the Docker image in k8s +.PHONY: install +install: + helm install \ + --create-namespace \ + --namespace $(NAMESPACE) \ + --set salad.apiKey=$(SCE_API_KEY) \ + --set salad.organizationName=$(SCE_ORGANIZATION_NAME) \ + --set salad.projectName=$(SCE_PROJECT_NAME) \ + --set provider.image.tag=$(IMAGE_TAG) \ + $(INSTALL_ARGS) \ + $(DEPLOYMENT_NAME) \ + ./charts/virtual-kubelet + +.PHONY: dry-install +dry-install: + $(MAKE) install INSTALL_ARGS="--dry-run" + +.PHONY: uninstall +uninstall: + helm uninstall \ + --namespace $(NAMESPACE) \ + $(DEPLOYMENT_NAME) + +# Run in foreground for debugging +.PHONY: run +run: + bin/virtual-kubelet \ + --nodename $(DEPLOYMENT_NAME) \ + --log-level DEBUG \ + --disable-taint \ + --sce-organization-name $(SCE_ORGANIZATION_NAME) \ + --sce-project-name $(SCE_PROJECT_NAME) \ + --sce-api-key $(SCE_API_KEY)