-
Notifications
You must be signed in to change notification settings - Fork 31
/
Makefile
104 lines (75 loc) · 3.38 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
NAMESPACE ?= kubesphere-logging-system
REGISTRY?=kubesphere
REPO_OPERATOR?=$(REGISTRY)/kube-events-operator
REPO_EXPORTER?=$(REGISTRY)/kube-events-exporter
REPO_RULER?=$(REGISTRY)/kube-events-ruler
TAG?=$(shell cat VERSION | tr -d " \t\n\r")
GO_PKG?=github.com/kubesphere/kube-events
CRD_OPTIONS ?= "crd:trivialVersions=true"
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif
CONTROLLER_GEN := $(GOBIN)/controller-gen
KE_DOCGEN_BINARY:=$(GOBIN)/kube-events-docgen
TYPES_V1ALPHA1_TARGET := pkg/apis/v1alpha1/exporter_types.go pkg/apis/v1alpha1/ruler_types.go pkg/apis/v1alpha1/rule_types.go
DEEPCOPY_TARGET := pkg/apis/v1alpha1/zz_generated.deepcopy.go
.PHONY: helm
deploy:
kubectl apply -f config/bundle.yaml
generate: $(DEEPCOPY_TARGET) manifests
cd config && $(GOBIN)/kustomize edit set image operator=$(REPO_OPERATOR):$(TAG)
$(GOBIN)/kustomize build config > config/bundle.yaml
cd config/crs && $(GOBIN)/kustomize edit set image exporter=$(REPO_EXPORTER):$(TAG) ruler=$(REPO_RULER):$(TAG)
$(GOBIN)/kustomize build config/crs > config/crs/bundle.yaml
# Generate manifests e.g. CRD, RBAC etc.
manifests: $(CONTROLLER_GEN) $(TYPES_V1ALPHA1_TARGET)
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=operator paths="./pkg/..." output:crd:artifacts:config=config/crd/bases
helm: $(CONTROLLER_GEN)
$(GOBIN)/kustomize build config/helm | sed -e '/creationTimestamp/d' > helm/crds/bundle.yaml
tar zcvf kube-events.tgz helm
doc/api.md: $(KE_DOCGEN_BINARY) $(TYPES_V1ALPHA1_TARGET)
$(KE_DOCGEN_BINARY) $(TYPES_V1ALPHA1_TARGET) > doc/api.md
fmt:
go fmt ./...
vet:
go vet ./...
test: fmt vet
go test ./...
# Generate deepcopy etc.
$(DEEPCOPY_TARGET): $(CONTROLLER_GEN) $(TYPES_V1ALPHA1_TARGET)
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./pkg/..."
$(CONTROLLER_GEN):
set -e ;\
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
cd $$CONTROLLER_GEN_TMP_DIR ;\
go mod init tmp ;\
go install sigs.k8s.io/controller-tools/cmd/[email protected] ;\
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
$(KE_DOCGEN_BINARY): cmd/docgen/kube-events-docgen.go
go install cmd/docgen/kube-events-docgen.go
image-push: image
docker push $(REPO_OPERATOR):$(TAG)
docker push $(REPO_EXPORTER):$(TAG)
docker push $(REPO_RULER):$(TAG)
.PHONY: image
image: operator-image exporter-image ruler-image
operator-image: cmd/operator/Dockerfile
docker build -t $(REPO_OPERATOR):$(TAG) -f cmd/operator/Dockerfile .
exporter-image: cmd/exporter/Dockerfile
docker build -t $(REPO_EXPORTER):$(TAG) -f cmd/exporter/Dockerfile .
ruler-image: cmd/ruler/Dockerfile
docker build -t $(REPO_RULER):$(TAG) -f cmd/ruler/Dockerfile .
cross-build: cross-build-operator cross-build-exporter cross-build-ruler
cross-build-operator: cmd/operator/Dockerfile
docker buildx build --push --platform linux/amd64,linux/arm64 -t $(REPO_OPERATOR):$(TAG) -f cmd/operator/Dockerfile .
cross-build-exporter: cmd/exporter/Dockerfile
docker buildx build --push --platform linux/amd64,linux/arm64 -t $(REPO_EXPORTER):$(TAG) -f cmd/exporter/Dockerfile .
cross-build-ruler: cmd/ruler/Dockerfile
docker buildx build --push --platform linux/amd64,linux/arm64 -t $(REPO_RULER):$(TAG) -f cmd/ruler/Dockerfile .
ca-secret:
./hack/certs.sh --service kube-events-admission --namespace $(NAMESPACE)
update-cert: ca-secret
./hack/update-cert.sh