forked from matrixorigin/matrixone-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
154 lines (118 loc) · 4.16 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
142
143
144
145
146
147
148
149
150
151
152
153
154
SHELL=/usr/bin/env bash -o pipefail
# Image URL to use all building/pushing image targets
IMG ?= "matrixorigin/matrixone-operator:latest"
MIMG ?= "matrixorigin/matrixone:kc"
BIMG ?= "matrixorigin/mysql-tester:latest"
PROXY ?= https://goproxy.cn,direct
BRANCH ?= main
TOOLS_BIN_DIR ?= $(shell pwd)/tmp/bin
GOLANGCILINTER_BINARY=$(TOOLS_BIN_DIR)/golangci-lint
LICENSE_EYE_BINARY=$(TOOLS_BIN_DIR)/license-eye
TOOLING=$(GOLANGCILINTER_BINARY) $(LICENSE_EYE_BINARY)
export PATH := $(TOOLS_BIN_DIR):$(PATH)
# 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
all: manager
# Build matrixone docker image
mo-build:
cd third_part/mo-docker && docker build . -t $(MIMG) --build-arg PROXY=$(PROXY) --build-arg BRANCH=$(BRANCH)
# push matrixone docker image
mo-push:
docker push $(MIMG)
# Make sure the generated files are up to date before open PR
reviewable: ci-reviewable go-lint check-license
ci-reviewable: generate manifests test
go mod tidy
# Check whether the pull request is reviewable in CI, go-lint is delibrately excluded since we already have golangci-lint action
verify: ci-reviewable
echo "checking that branch is clean"
test -z "$$(git status --porcelain)" || (echo "unclean working tree, did you forget to run make reviewable?" && exit 1)
echo "branch is clean"
# license check
check-license: $(LICENSE_EYE_BINARY)
$(LICENSE_EYE_BINARY) -v info -c .licenserc.yml header check
# Run tests
test: generate fmt vet manifests
go test ./... -coverprofile cover.out
# build mysql-tester image
# repo: https://github.com/matrixorigin/mysql-tester
bvt-build:
docker build -f tools/bvt-test/Dockerfile . -t $(BIMG) --build-arg PROXY=$(PROXY)
# Build manager binary
manager: generate fmt vet
CGO_ENABLED=0 go build -o manager cmd/operator/main.go
# Run against the configured Kubernetes cluster in ~/.kube/config
run: generate fmt vet manifests
go run cmd/operator/main.go
# Install CRDs into a cluster
install: manifests
kubectl apply -f deploy/crds
# Uninstall CRDs from a cluster
uninstall: manifests
kubectl delete -f deploy/crds
kruise:
helm repo add openkruise https://openkruise.github.io/charts/
helm repo update
helm install kruise openkruise/kruise --version 1.2.0
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
deploy: install manifests
kubectl apply -f deploy/service_account.yaml
kubectl apply -f deploy/role.yaml
kubectl apply -f deploy/role_binding.yaml
kustomize build deploy/ | kubectl apply -f -
# Destroyo Controller the configured Kubernetes cluster in ~/.kube/config
undeploy: uninstall manifests
kustomize build deploy/ | kubectl delete -f -
kubectl delete -f deploy/service_account.yaml
kubectl delete -f deploy/role.yaml
kubectl delete -f deploy/role_binding.yaml
## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
.PHONY: manifests
manifests:
cd api && make manifests
## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
.PHONY: generate
generate:
cd api && make generate
# Run go fmt against code
fmt:
go fmt ./...
# Run go vet against code
vet:
go vet ./...
# helm lint
lint:
helm lint charts/matrixone-operator
# golangci-lint
go-lint: $(GOLANGCILINTER_BINARY)
$(GOLANGCILINTER_BINARY) run
# Build the docker image
op-build: generate manifests pkg
docker build -f images/operator/Dockerfile . -t ${IMG} --build-arg PROXY=$(PROXY)
# Push the docker image
op-push:
docker push ${IMG}
# local e2e test on kind
e2e:
./hack/kind-e2e.sh
# start a kind clsuter
kind:
kind create cluster --config test/kind-config.yml
kubectl apply -f test/kind-rbac.yml
# kind load images
load:
kind load docker-image --name mo matrixorigin/matrixone-operator:latest
# helm package
helm-pkg: charts
helm package charts/matrixone-operator
mv matrixone-operator-0.1.0.tgz packages
# install tools
$(TOOLS_BIN_DIR):
mkdir -p $(TOOLS_BIN_DIR)
$(TOOLING): $(TOOLS_BIN_DIR)
@echo Installing tools from tools/tools.go
@cat tools/tools.go | grep _ | awk -F'"' '{print $$2}' | GOBIN=$(TOOLS_BIN_DIR) xargs -tI % go install -mod=readonly -modfile=tools/go.mod %