2020-05-24 00:05:32 +02:00
|
|
|
GOPATH = $(shell go env GOPATH)
|
2019-09-11 23:50:37 +02:00
|
|
|
|
2019-03-13 23:27:20 +01:00
|
|
|
JSONNET_BIN := $(GOPATH)/bin/jsonnet
|
|
|
|
JB_BINARY := $(GOPATH)/bin/jb
|
2018-12-12 18:18:00 +01:00
|
|
|
|
2020-03-18 22:01:01 +01:00
|
|
|
JSONNET_FMT := $(GOPATH)/bin/jsonnetfmt -n 2 --max-blank-lines 2 --string-style s --comment-style s
|
|
|
|
|
2023-07-30 19:10:22 +02:00
|
|
|
GO_MAJOR_VERSION = $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1)
|
|
|
|
GO_MINOR_VERSION = $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)
|
|
|
|
MINIMUM_SUPPORTED_GO_MAJOR_VERSION = 1
|
|
|
|
MINIMUM_SUPPORTED_GO_MINOR_VERSION = 18
|
|
|
|
GO_VERSION_VALIDATION_ERR_MSG = Your golang version, $(GO_MAJOR_VERSION).$(GO_MINOR_VERSION), is not supported, \
|
|
|
|
please update to at least $(MINIMUM_SUPPORTED_GO_MAJOR_VERSION).$(MINIMUM_SUPPORTED_GO_MINOR_VERSION).
|
|
|
|
|
2020-03-18 22:01:01 +01:00
|
|
|
.PHONY: generate vendor fmt manifests help
|
|
|
|
|
|
|
|
all: manifests ## Builds the manifests
|
2018-12-12 18:18:00 +01:00
|
|
|
|
2020-03-18 22:01:01 +01:00
|
|
|
help: # Show help
|
|
|
|
@echo "Makefile targets:"
|
|
|
|
@echo ""
|
|
|
|
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
2018-12-12 18:18:00 +01:00
|
|
|
|
2020-03-18 22:01:01 +01:00
|
|
|
manifests: $(JSONNET_BIN) ## Builds the manifests
|
2018-12-12 18:18:00 +01:00
|
|
|
rm -rf manifests
|
2019-03-13 23:27:20 +01:00
|
|
|
./scripts/build.sh main.jsonnet $(JSONNET_BIN)
|
2018-12-12 18:18:00 +01:00
|
|
|
|
2020-06-23 00:29:51 +02:00
|
|
|
docker: ## Builds the manifests in a Docker container to avoid installing pre-requisites (Golang, Jsonnet, etc)
|
|
|
|
docker run -it --rm -v $(PWD):/work -w /work --rm golang bash -c "make vendor && make"
|
2020-06-22 19:07:18 +02:00
|
|
|
|
2020-06-23 00:29:51 +02:00
|
|
|
update_libs: $(JB_BINARY) ## Updates vendor libs. Require a regeneration of the manifests
|
2020-03-18 22:01:01 +01:00
|
|
|
$(JB_BINARY) update
|
2018-12-12 18:18:00 +01:00
|
|
|
|
2023-07-30 19:10:22 +02:00
|
|
|
vendor: validate-go-version $(JB_BINARY) jsonnetfile.json jsonnetfile.lock.json ## Download vendor libs
|
2018-12-12 18:18:00 +01:00
|
|
|
rm -rf vendor
|
|
|
|
$(JB_BINARY) install
|
|
|
|
|
2020-06-23 00:29:51 +02:00
|
|
|
fmt: ## Formats all jsonnet and libsonnet files (except on vendor dir)
|
2020-03-18 22:01:01 +01:00
|
|
|
@echo "Formatting jsonnet files"
|
2020-06-19 14:58:49 +02:00
|
|
|
@find . -type f \( -iname "*.libsonnet" -or -iname "*.jsonnet" \) -print -or -name "vendor" -prune | xargs -n 1 -- $(JSONNET_FMT) -i
|
2018-12-12 18:18:00 +01:00
|
|
|
|
2020-06-23 00:29:51 +02:00
|
|
|
deploy: ## Deploy current manifests to configured cluster
|
2020-05-26 01:23:56 +02:00
|
|
|
echo "Deploying stack setup manifests..."
|
|
|
|
kubectl apply -f ./manifests/setup/
|
|
|
|
echo "Will wait 10 seconds to deploy the additional manifests.."
|
|
|
|
sleep 10
|
2018-12-12 18:18:00 +01:00
|
|
|
kubectl apply -f ./manifests/
|
|
|
|
|
2020-06-23 00:29:51 +02:00
|
|
|
teardown: ## Delete all monitoring stack resources from configured cluster
|
2018-12-12 18:18:00 +01:00
|
|
|
kubectl delete -f ./manifests/
|
2020-05-26 01:23:56 +02:00
|
|
|
kubectl delete -f ./manifests/setup/
|
2018-12-12 18:18:00 +01:00
|
|
|
|
2020-06-23 00:29:51 +02:00
|
|
|
tar: manifests ## Generates a .tar.gz from manifests dir
|
2020-03-18 22:01:01 +01:00
|
|
|
rm -rf manifests.tar.gz
|
|
|
|
tar -cfz manifests.tar.gz manifests
|
2018-12-12 18:18:00 +01:00
|
|
|
|
2020-06-23 00:29:51 +02:00
|
|
|
$(JB_BINARY): ## Installs jsonnet-bundler utility
|
2019-03-13 22:04:19 +01:00
|
|
|
@echo "Installing jsonnet-bundler"
|
2022-07-13 23:14:29 +02:00
|
|
|
@go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@latest
|
2019-03-13 22:04:19 +01:00
|
|
|
|
2020-06-23 00:29:51 +02:00
|
|
|
$(JSONNET_BIN): ## Installs jsonnet and jsonnetfmt utility
|
2019-03-13 22:04:19 +01:00
|
|
|
@echo "Installing jsonnet"
|
2022-07-13 23:14:29 +02:00
|
|
|
@go install github.com/google/go-jsonnet/cmd/jsonnet@latest
|
|
|
|
@go install github.com/google/go-jsonnet/cmd/jsonnetfmt@latest
|
|
|
|
@go install github.com/brancz/gojsontoyaml@latest
|
2020-03-18 22:01:01 +01:00
|
|
|
|
2020-06-23 00:29:51 +02:00
|
|
|
update_tools: ## Updates jsonnet, jsonnetfmt and jb utilities
|
2020-03-18 22:01:01 +01:00
|
|
|
@echo "Updating jsonnet"
|
2022-07-13 23:14:29 +02:00
|
|
|
@go install github.com/google/go-jsonnet/cmd/jsonnet@latest
|
|
|
|
@go install github.com/google/go-jsonnet/cmd/jsonnetfmt@latest
|
|
|
|
@go install github.com/brancz/gojsontoyaml@latest
|
|
|
|
@go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@latest
|
2019-08-22 00:13:13 +02:00
|
|
|
|
2020-06-23 00:29:51 +02:00
|
|
|
change_suffix: ## Changes suffix for the ingress. Pass suffix=[suffixURL] as argument
|
2020-06-15 22:06:36 +02:00
|
|
|
@echo "Ingress IPs changed to [service].${suffix}"
|
|
|
|
@echo "Apply to your cluster with:"
|
2020-06-15 22:52:35 +02:00
|
|
|
@for f in alertmanager prometheus grafana; do \
|
|
|
|
cat manifests/ingress-$$f.yaml | sed -e "s/\(.*$$f\.\).*/\1${suffix}/" > manifests/ingress-$$f.yaml-tmp; \
|
|
|
|
mv -f manifests/ingress-$$f.yaml-tmp manifests/ingress-$$f.yaml; \
|
|
|
|
echo ${K3S} kubectl apply -f manifests/ingress-$$f.yaml; \
|
2022-07-13 23:14:29 +02:00
|
|
|
done
|
2023-07-30 19:10:22 +02:00
|
|
|
|
|
|
|
validate-go-version: ## Validates the installed version of go to allow the `go install` syntax needed for `make vendor`
|
|
|
|
@if [ $(GO_MAJOR_VERSION) -lt $(MINIMUM_SUPPORTED_GO_MAJOR_VERSION) -o $(GO_MINOR_VERSION) -lt $(MINIMUM_SUPPORTED_GO_MINOR_VERSION) ]; then \
|
|
|
|
echo '$(GO_VERSION_VALIDATION_ERR_MSG)'; \
|
|
|
|
exit 1; \
|
|
|
|
fi
|