forked from prometheus-operator/prometheus-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
136 lines (101 loc) · 6 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
SHELL=/bin/bash -o pipefail
REPO?=quay.io/coreos/prometheus-operator
TAG?=$(shell git rev-parse --short HEAD)
NAMESPACE?=po-e2e-$(shell LC_ALL=C tr -dc a-z0-9 < /dev/urandom | head -c 13 ; echo '')
KUBECONFIG?=$(HOME)/.kube/config
PROMU := $(GOPATH)/bin/promu
PREFIX ?= $(shell pwd)
ifeq ($(GOBIN),)
GOBIN :=${GOPATH}/bin
endif
pkgs = $(shell go list ./... | grep -v /vendor/ | grep -v /test/)
all: check-license format build test
build: promu
@$(PROMU) build --prefix $(PREFIX)
short-build:
go install github.com/coreos/prometheus-operator/cmd/operator
po-crdgen:
go install github.com/coreos/prometheus-operator/cmd/po-crdgen
crossbuild: promu
@$(PROMU) crossbuild
cd contrib/prometheus-config-reloader && make build
test:
@go test $(TEST_RUN_ARGS) -short $(pkgs)
format:
go fmt $(pkgs)
check-license:
./scripts/check_license.sh
container:
docker build -t $(REPO):$(TAG) .
cd contrib/prometheus-config-reloader && docker build -t quay.io/coreos/prometheus-config-reloader:$(TAG) .
e2e-test:
go test -timeout 55m -v ./test/e2e/ $(TEST_RUN_ARGS) --kubeconfig=$(KUBECONFIG) --operator-image=$(REPO):$(TAG) --namespace=$(NAMESPACE)
e2e-status:
kubectl get prometheus,alertmanager,servicemonitor,statefulsets,deploy,svc,endpoints,pods,cm,secrets,replicationcontrollers --all-namespaces
e2e: container
$(MAKE) e2e-test
e2e-helm:
./helm/hack/e2e-test.sh
# package the chart and verify if they have the version bumped
helm/hack/helm-package.sh "alertmanager grafana prometheus prometheus-operator exporter-kube-dns exporter-kube-scheduler exporter-kubelets exporter-node exporter-kube-controller-manager exporter-kube-etcd exporter-kube-state exporter-kubernetes exporter-coredns"
helm/hack/sync-repo.sh false
clean-e2e:
kubectl -n $(NAMESPACE) delete prometheus,alertmanager,servicemonitor,statefulsets,deploy,svc,endpoints,pods,cm,secrets,replicationcontrollers --all
kubectl delete namespace $(NAMESPACE)
promu:
@go get -u github.com/prometheus/promu
embedmd:
@go get github.com/campoy/embedmd
po-docgen:
@go install github.com/coreos/prometheus-operator/cmd/po-docgen
docs: embedmd po-docgen
$(GOPATH)/bin/embedmd -w `find Documentation contrib/kube-prometheus/ -name "*.md" | grep -v vendor`
$(GOPATH)/bin/po-docgen api pkg/client/monitoring/v1/types.go > Documentation/api.md
$(GOPATH)/bin/po-docgen compatibility > Documentation/compatibility.md
generate: jsonnet-docker
docker run --rm -u=$(shell id -u $(USER)):$(shell id -g $(USER)) -v `pwd`:/go/src/github.com/coreos/prometheus-operator po-jsonnet make generate-deepcopy generate-openapi generate-crd jsonnet generate-bundle generate-kube-prometheus docs
$(GOBIN)/openapi-gen:
go get -u -v -d k8s.io/code-generator/cmd/openapi-gen
cd $(GOPATH)/src/k8s.io/code-generator; git checkout release-1.10
go install k8s.io/code-generator/cmd/openapi-gen
$(GOBIN)/deepcopy-gen:
go get -u -v -d k8s.io/code-generator/cmd/deepcopy-gen
cd $(GOPATH)/src/k8s.io/code-generator; git checkout release-1.10
go install k8s.io/code-generator/cmd/deepcopy-gen
openapi-gen: $(GOBIN)/openapi-gen
deepcopy-gen: $(GOBIN)/deepcopy-gen
generate-deepcopy: deepcopy-gen
$(GOBIN)/deepcopy-gen -i github.com/coreos/prometheus-operator/pkg/client/monitoring/v1 --go-header-file="$(GOPATH)/src/github.com/coreos/prometheus-operator/.header" -v=4 --logtostderr --bounding-dirs "github.com/coreos/prometheus-operator/pkg/client" --output-file-base zz_generated.deepcopy
$(GOBIN)/deepcopy-gen -i github.com/coreos/prometheus-operator/pkg/client/monitoring/v1alpha1 --go-header-file="$(GOPATH)/src/github.com/coreos/prometheus-operator/.header" -v=4 --logtostderr --bounding-dirs "github.com/coreos/prometheus-operator/pkg/client" --output-file-base zz_generated.deepcopy
generate-openapi: openapi-gen
$(GOBIN)/openapi-gen -i github.com/coreos/prometheus-operator/pkg/client/monitoring/v1,k8s.io/apimachinery/pkg/apis/meta/v1,k8s.io/api/core/v1 -p github.com/coreos/prometheus-operator/pkg/client/monitoring/v1 --go-header-file="$(GOPATH)/src/github.com/coreos/prometheus-operator/.header"
generate-bundle:
hack/generate-bundle.sh
generate-kube-prometheus:
cd contrib/kube-prometheus; $(MAKE) generate-raw
jsonnet: jb
# Update the Prometheus Operator version in kube-prometheus
sed -i \
"s/prometheusOperator: 'v.*',/prometheusOperator: 'v$(shell cat VERSION)',/" \
jsonnet/prometheus-operator/prometheus-operator.libsonnet;
cd hack/generate; jb install;
hack/generate/build-jsonnet.sh
jb:
go get github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb
jsonnet-docker:
docker build -f scripts/jsonnet/Dockerfile -t po-jsonnet .
helm-sync-s3:
helm/hack/helm-package.sh "alertmanager grafana prometheus prometheus-operator exporter-kube-dns exporter-kube-scheduler exporter-kubelets exporter-node exporter-kube-controller-manager exporter-kube-etcd exporter-kube-state exporter-kubernetes exporter-coredns"
helm/hack/sync-repo.sh true
helm/hack/helm-package.sh kube-prometheus
helm/hack/sync-repo.sh true
generate-crd: generate-openapi po-crdgen
po-crdgen prometheus > example/prometheus-operator-crd/prometheus.crd.yaml
po-crdgen alertmanager > example/prometheus-operator-crd/alertmanager.crd.yaml
po-crdgen servicemonitor > example/prometheus-operator-crd/servicemonitor.crd.yaml
po-crdgen prometheusrule > example/prometheus-operator-crd/prometheusrule.crd.yaml
cat example/prometheus-operator-crd/alertmanager.crd.yaml | gojsontoyaml -yamltojson > jsonnet/prometheus-operator/alertmanager-crd.libsonnet
cat example/prometheus-operator-crd/prometheus.crd.yaml | gojsontoyaml -yamltojson > jsonnet/prometheus-operator/prometheus-crd.libsonnet
cat example/prometheus-operator-crd/servicemonitor.crd.yaml | gojsontoyaml -yamltojson > jsonnet/prometheus-operator/servicemonitor-crd.libsonnet
cat example/prometheus-operator-crd/prometheusrule.crd.yaml | gojsontoyaml -yamltojson > jsonnet/prometheus-operator/prometheusrule-crd.libsonnet
.PHONY: all build crossbuild test format check-license container e2e-test e2e-status e2e clean-e2e embedmd apidocgen docs generate-crd jb