forked from pdettori/multicluster-controlplane
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
141 lines (107 loc) · 5.7 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
137
138
139
140
141
# Copyright Contributors to the Open Cluster Management project
BINARYDIR := bin
KUBECTL?=kubectl
KUSTOMIZE?=kustomize
ETCD_NS?=multicluster-controlplane-etcd
HUB_NAME?=multicluster-controlplane
IMAGE_REGISTRY?=quay.io/open-cluster-management
IMAGE_TAG?=latest
export IMAGE_NAME?=$(IMAGE_REGISTRY)/multicluster-controlplane:$(IMAGE_TAG)
CONTROLPLANE_KUBECONFIG?=hack/deploy/cert-$(HUB_NAME)/kubeconfig
check-copyright:
@hack/check/check-copyright.sh
check: check-copyright
verify-gocilint:
go install github.com/golangci/golangci-lint/cmd/[email protected]
go vet ./...
golangci-lint run --timeout=3m ./...
verify: verify-gocilint
all: clean vendor build run
.PHONY: all
run:
hack/start-multicluster-controlplane.sh
.PHONY: run
build-bin-release:
$(rm -rf bin)
$(mkdir -p bin)
GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -gcflags=-trimpath=x/y -o bin/multicluster-controlplane ./cmd/main.go && tar -czf bin/multicluster_controlplane_darwin_amd64.tar.gz LICENSE -C bin/ multicluster-controlplane
GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w" -gcflags=-trimpath=x/y -o bin/multicluster-controlplane ./cmd/main.go && tar -czf bin/multicluster_controlplane_darwin_arm64.tar.gz LICENSE -C bin/ multicluster-controlplane
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -gcflags=-trimpath=x/y -o bin/multicluster-controlplane ./cmd/main.go && tar -czf bin/multicluster_controlplane_linux_amd64.tar.gz LICENSE -C bin/ multicluster-controlplane
GOOS=linux GOARCH=arm64 go build -ldflags="-s -w" -gcflags=-trimpath=x/y -o bin/multicluster-controlplane ./cmd/main.go && tar -czf bin/multicluster_controlplane_linux_arm64.tar.gz LICENSE -C bin/ multicluster-controlplane
GOOS=linux GOARCH=ppc64le go build -ldflags="-s -w" -gcflags=-trimpath=x/y -o bin/multicluster-controlplane ./cmd/main.go && tar -czf bin/multicluster_controlplane_linux_ppc64le.tar.gz LICENSE -C bin/ multicluster-controlplane
GOOS=linux GOARCH=s390x go build -ldflags="-s -w" -gcflags=-trimpath=x/y -o bin/multicluster-controlplane ./cmd/main.go && tar -czf bin/multicluster_controlplane_linux_s390x.tar.gz LICENSE -C bin/ multicluster-controlplane
GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -gcflags=-trimpath=x/y -o bin/multicluster-controlplane.exe ./cmd/main.go && zip -q bin/multicluster_controlplane_windows_amd64.zip LICENSE -j bin/multicluster-controlplane.exe
build:
$(shell if [ ! -e $(BINARYDIR) ];then mkdir -p $(BINARYDIR); fi)
go build -o bin/multicluster-controlplane cmd/server/main.go
.PHONY: build
image:
docker build -f Dockerfile -t $(IMAGE_NAME) .
.PHONY: image
push:
docker push $(IMAGE_NAME)
.PHONY: push
clean:
rm -rf bin .ocmconfig vendor
.PHONY: clean
vendor:
go mod tidy
go mod vendor
.PHONY: vendor
update:
bash -x hack/crd-update/copy-crds.sh
.PHONY: update
deploy-etcd:
$(KUBECTL) get ns $(ETCD_NS); if [ $$? -ne 0 ] ; then $(KUBECTL) create ns $(ETCD_NS); fi
hack/deploy-etcd.sh
deploy:
hack/deploy-multicluster-controlplane.sh
destroy:
$(KUSTOMIZE) build hack/deploy/controlplane | $(KUBECTL) delete --namespace $(HUB_NAME) --ignore-not-found -f -
$(KUBECTL) delete ns $(HUB_NAME) --ignore-not-found
rm -r hack/deploy/cert-$(HUB_NAME)
deploy-work-manager-addon:
$(KUBECTL) apply -k hack/deploy/addon/work-manager/hub --kubeconfig=$(CONTROLPLANE_KUBECONFIG)
cp hack/deploy/addon/work-manager/manager/kustomization.yaml hack/deploy/addon/work-manager/manager/kustomization.yaml.tmp
cd hack/deploy/addon/work-manager/manager && $(KUSTOMIZE) edit set namespace $(HUB_NAME)
$(KUSTOMIZE) build hack/deploy/addon/work-manager/manager | $(KUBECTL) apply -f -
mv hack/deploy/addon/work-manager/manager/kustomization.yaml.tmp hack/deploy/addon/work-manager/manager/kustomization.yaml
deploy-managed-serviceaccount-addon:
$(KUBECTL) apply -k hack/deploy/addon/managed-serviceaccount/hub --kubeconfig=$(CONTROLPLANE_KUBECONFIG)
cp hack/deploy/addon/managed-serviceaccount/manager/kustomization.yaml hack/deploy/addon/managed-serviceaccount/manager/kustomization.yaml.tmp
cd hack/deploy/addon/managed-serviceaccount/manager && $(KUSTOMIZE) edit set namespace $(HUB_NAME)
$(KUSTOMIZE) build hack/deploy/addon/managed-serviceaccount/manager | $(KUBECTL) apply -f -
mv hack/deploy/addon/managed-serviceaccount/manager/kustomization.yaml.tmp hack/deploy/addon/managed-serviceaccount/manager/kustomization.yaml
deploy-policy-addon:
$(KUBECTL) apply -k hack/deploy/addon/policy/hub --kubeconfig=$(CONTROLPLANE_KUBECONFIG)
cp hack/deploy/addon/policy/manager/kustomization.yaml hack/deploy/addon/policy/manager/kustomization.yaml.tmp
cd hack/deploy/addon/policy/manager && $(KUSTOMIZE) edit set namespace $(HUB_NAME)
$(KUSTOMIZE) build hack/deploy/addon/policy/manager | $(KUBECTL) apply -f -
mv hack/deploy/addon/policy/manager/kustomization.yaml.tmp hack/deploy/addon/policy/manager/kustomization.yaml
deploy-all: deploy deploy-work-manager-addon deploy-managed-serviceaccount-addon deploy-policy-addon
# test
export CONTROLPLANE_NUMBER ?= 2
export VERBOSE ?= 5
cleanup-e2e:
./test/e2e/hack/cleanup.sh
.PHONY: cleanup-e2e
build-e2e-test:
go test -c ./test/e2e -o _output/e2e.test
.PHONY: build-e2e-test
test-e2e: cleanup-e2e build-e2e-test
./test/e2e/hack/e2e.sh
.PHONY: test-e2e
cleanup-integration:
./test/integration/hack/cleanup.sh
.PHONY: cleanup-integration
test-integration: cleanup-integration build
./test/integration/hack/integration.sh
.PHONY: test-integration
build-performance-test:
go build -o bin/perftool test/performance/perftool.go
.PHONY: build-performance-test
export PERF_TEST_OUTPUT_SUFFIX ?= $(shell date '+%Y%m%dT%H%M%S')
test-performance: build-performance-test
mkdir -p _output/performance
./test/performance/hack/performance.sh >_output/performance/perf.$(PERF_TEST_OUTPUT_SUFFIX).output 2>&1 &
.PHONY: test-performance