rpi.carlosedp.cluster-monit.../Makefile
Crt Mori 129fdd7182
Dependency on the jsonnet vendor and gojsontoyaml
I have tried to run a simple `make deploy`. First problem was my GOPATH was blank (even though the golang was installed). After that was fixed, I needed to actually run `make vendor` before I could even consider running `make deploy`. I also needed to add my GOPATH/bin directory to path as it did not find gojsontoyaml otherwise
`export PATH=$PATH:$GOPATH/bin`

Error I was solving:
```
$ make deploy
Installing jsonnet
rm -rf manifests
./scripts/build.sh main.jsonnet /home/xzy/cluster-monitoring/bin/jsonnet
using jsonnet from arg
+ set -o pipefail
+ rm -rf manifests
+ mkdir manifests
+ /home/xyz/cluster-monitoring/bin/jsonnet -J vendor -m manifests main.jsonnet
+ xargs '-I{}' sh -c 'cat {} | gojsontoyaml > {}.yaml; rm -f {}' -- '{}'
RUNTIME ERROR: couldn't open import "kube-prometheus/kube-prometheus.libsonnet": no match locally or in the Jsonnet library paths
	main.jsonnet:12:13-63	thunk <kp> from <$>
	main.jsonnet:30:81-83	
	<std>:1268:24-25	thunk from <function <anonymous>>
	<std>:1268:5-33	function <anonymous>
	main.jsonnet:30:64-99	$
		
		
	During evaluation	

make: *** [Makefile:12: manifests] Error 1
```
2019-09-11 23:50:37 +02:00

58 lines
1.5 KiB
Makefile

JSONNET_FMT := jsonnet fmt -n 2 --max-blank-lines 2 --string-style s --comment-style s
GOPATH ?= `$(pwd)`
JSONNET_BIN := $(GOPATH)/bin/jsonnet
JB_BINARY := $(GOPATH)/bin/jb
.PHONY: generate vendor fmt manifests
all: manifests
manifests: jsonnet
rm -rf manifests
./scripts/build.sh main.jsonnet $(JSONNET_BIN)
update: jsonnet_bundler
jb update
vendor: jsonnet_bundler jsonnetfile.json jsonnetfile.lock.json
rm -rf vendor
$(JB_BINARY) install
fmt:
find . -name 'vendor' -prune -o -name '*.libsonnet' -o -name '*.jsonnet' -print | xargs -n 1 -- $(JSONNET_FMT) -i
deploy: manifests
kubectl apply -f ./manifests/
echo "Will wait 40 seconds to reapply manifests"
sleep 40
kubectl apply -f ./manifests/
teardown:
kubectl delete -f ./manifests/
tar: manifests
rm -rf manifests.tar
tar -cf manifests.tar manifests
jsonnet_bundler:
ifeq (, $(shell which jb))
@echo "Installing jsonnet-bundler"
@go get -u github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb
endif
jsonnet:
ifeq (, $(shell which jsonnet))
@echo "Installing jsonnet"
@go get github.com/google/go-jsonnet/cmd/jsonnet
@go get github.com/brancz/gojsontoyaml
endif
change_suffix:
@perl -p -i -e 's/^(\s*)\-\ host:.*/\1- host: alertmanager.${IP}.nip.io/g' manifests/ingress-alertmanager-main.yaml manifests/ingress-prometheus-k8s.yaml manifests/ingress-grafana.yaml
@echo "Ingress IPs changed to [service].${IP}.nip.io"
${K3S} kubectl apply -f manifests/ingress-alertmanager-main.yaml
${K3S} kubectl apply -f manifests/ingress-grafana.yaml
${K3S} kubectl apply -f manifests/ingress-prometheus-k8s.yaml