2019-09-11 23:50:37 +02:00
|
|
|
GOPATH ?= `$(pwd)`
|
|
|
|
|
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
|
|
|
|
|
|
|
|
.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-03-18 22:01:01 +01:00
|
|
|
update_libs: $(JB_BINARY) ## Updates vendor libs. Require a regeneration of the manifests
|
|
|
|
$(JB_BINARY) update
|
2018-12-12 18:18:00 +01:00
|
|
|
|
2020-03-18 22:01:01 +01:00
|
|
|
vendor: $(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-03-18 22:01:01 +01:00
|
|
|
fmt: ## Formats all jsonnet and libsonnet files (except on vendor dir)
|
|
|
|
@echo "Formatting jsonnet files"
|
|
|
|
@find . -name 'vendor' -prune -o -name '*.libsonnet' -o -name '*.jsonnet' -print | xargs -n 1 -- $(JSONNET_FMT) -i
|
2018-12-12 18:18:00 +01:00
|
|
|
|
2020-03-18 22:01:01 +01:00
|
|
|
deploy: manifests ## Rebuilds manifests and deploy to configured cluster
|
2018-12-12 18:18:00 +01:00
|
|
|
kubectl apply -f ./manifests/
|
|
|
|
echo "Will wait 40 seconds to reapply manifests"
|
|
|
|
sleep 40
|
|
|
|
kubectl apply -f ./manifests/
|
|
|
|
|
2020-03-18 22:01:01 +01:00
|
|
|
teardown: ## Delete all monitoring stack resources from configured cluster
|
2018-12-12 18:18:00 +01:00
|
|
|
kubectl delete -f ./manifests/
|
|
|
|
|
2020-03-18 22:01:01 +01:00
|
|
|
tar: manifests ## Generates a .tar.gz from manifests dir
|
|
|
|
rm -rf manifests.tar.gz
|
|
|
|
tar -cfz manifests.tar.gz manifests
|
2018-12-12 18:18:00 +01:00
|
|
|
|
2020-03-18 22:01:01 +01:00
|
|
|
$(JB_BINARY): ## Installs jsonnet-bundler utility
|
2019-03-13 22:04:19 +01:00
|
|
|
@echo "Installing jsonnet-bundler"
|
|
|
|
@go get -u github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb
|
|
|
|
|
2020-03-18 22:01:01 +01:00
|
|
|
$(JSONNET_BIN): ## Installs jsonnet and jsonnetfmt utility
|
2019-03-13 22:04:19 +01:00
|
|
|
@echo "Installing jsonnet"
|
2020-03-18 22:01:01 +01:00
|
|
|
@go get -u github.com/google/go-jsonnet/cmd/jsonnet
|
|
|
|
@go get -u github.com/google/go-jsonnet/cmd/jsonnetfmt
|
|
|
|
@go get -u github.com/brancz/gojsontoyaml
|
|
|
|
|
|
|
|
update_tools: ## Updates jsonnet, jsonnetfmt and jb utilities
|
|
|
|
@echo "Updating jsonnet"
|
|
|
|
@go get -u github.com/google/go-jsonnet/cmd/jsonnet
|
|
|
|
@go get -u github.com/google/go-jsonnet/cmd/jsonnetfmt
|
|
|
|
@go get -u github.com/brancz/gojsontoyaml
|
|
|
|
@go get -u github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb
|
2019-08-22 00:13:13 +02:00
|
|
|
|
2020-03-18 22:01:01 +01:00
|
|
|
change_suffix: ## Changes suffix for the ingress
|
2020-03-18 15:13:47 +01:00
|
|
|
@perl -p -i -e 's/^(\s*)\-\ host:.*/\1- host: alertmanager.${IP}.nip.io/g' manifests/ingress-alertmanager.yaml manifests/ingress-prometheus.yaml manifests/ingress-grafana.yaml
|
2019-08-22 00:13:13 +02:00
|
|
|
@echo "Ingress IPs changed to [service].${IP}.nip.io"
|
2020-03-18 15:13:47 +01:00
|
|
|
${K3S} kubectl apply -f manifests/ingress-alertmanager.yaml
|
2019-08-22 00:13:13 +02:00
|
|
|
${K3S} kubectl apply -f manifests/ingress-grafana.yaml
|
|
|
|
${K3S} kubectl apply -f manifests/ingress-prometheus-k8s.yaml
|