forked from TencentCloud/cluster-api-provider-tencent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
158 lines (117 loc) · 5.46 KB
/
Copy pathMakefile
File metadata and controls
158 lines (117 loc) · 5.46 KB
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
155
156
157
158
# Image URL to use all building/pushing image targets
#REPO ?= 'ccr.ccs.tencentyun.com/ccs-dev'
REPO ?= ccr.ccs.tencentyun.com/chenky
TAG ?= 0.0.4
GENERIC_IMG=$(REPO)/clusterapi-generic-controller:$(TAG)
CLUSTER_IMG=$(REPO)/tke-cluster-controller:$(TAG)
MACHINE_IMG=$(REPO)/tke-machine-controller:$(TAG)
CLUSTER-CONTROLLER=output/bin/tke-cluster-controller
MACHINE-CONTROLLER=output/bin/tke-machine-controller
GENERIC-CONTROLLER=output/bin/clusterapi-generic-controller
GCFLAGS ?= -x -gcflags="-N -l"
all: bin
# Run tests
test: generate fmt vet manifests
go test -v -tags=integration ./pkg/... ./cmd/... -coverprofile cover.out
tke-cluster-controller: ${CLUSTER-CONTROLLER}
tke-machine-controller: ${MACHINE-CONTROLLER}
clusterapi-generic-controller: ${GENERIC-CONTROLLER}
${CLUSTER-CONTROLLER}:
CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' ${GCFLAGS} -o $@ cmd/tke-cluster-controller/main.go
${MACHINE-CONTROLLER}:
CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' ${GCFLAGS} -o $@ cmd/tke-machine-controller/main.go
${GENERIC-CONTROLLER}:
CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' ${GCFLAGS} -o $@ cmd/clusterapi-generic-controller/main.go
bin: ${CLUSTER-CONTROLLER} ${MACHINE-CONTROLLER} ${GENERIC-CONTROLLER}
clean:
rm -f output/bin/* output/yaml/*
# Build manager binary
manager: generate fmt vet
go build -o bin/manager sigs.k8s.io/cluster-api-provider-gcp/cmd/manager
# Build manager binary
clusterctl: generate fmt vet
go build -o bin/clusterctl sigs.k8s.io/cluster-api-provider-gcp/cmd/clusterctl
# Run against the configured Kubernetes cluster in ~/.kube/config
run: generate fmt vet
go run ./cmd/manager/main.go
# Install CRDs into a cluster
install: manifests
kubectl apply -f config/crds
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
deploy: manifests
kubectl apply -f config/crds
kustomize build config/default | kubectl apply -f -
# Generate manifests e.g. CRD, RBAC etc.
manifests:
go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go all
# Run go fmt against code
fmt:
go fmt ./pkg/... ./cmd/...
# Run go vet against code
vet:
go vet ./pkg/... ./cmd/...
# Generate code
generate:
go generate ./pkg/... ./cmd/...
YAML_DIR=output/yaml
GENERIC_CTL_YAML=output/yaml/clusterapi-generic-controller.yaml
CLUSTER_CTL_YAML=output/yaml/tke-cluster-controller.yaml
MACHINE_CTL_YAML=output/yaml/tke-machine-controller.yaml
ALL_IN_ONE_YAML=output/yaml/clusterapi-controllers-all-in-one.yaml
${YAML_DIR}:
mkdir -p $@
# Build the docker image
docker-build-generic-controller: ${YAML_DIR}
docker build -f cmd/clusterapi-generic-controller/Dockerfile . -t ${GENERIC_IMG}
docker-build-tke-cluster-controller: ${YAML_DIR}
docker build -f cmd/tke-cluster-controller/Dockerfile . -t ${CLUSTER_IMG}
docker-build-tke-machine-controller: ${YAML_DIR}
docker build -f cmd/tke-machine-controller/Dockerfile . -t ${MACHINE_IMG}
# Build the docker image from local biniaries in output/bin
img-generic-controller: ${GENERIC-CONTROLLER}
docker build -f cmd/clusterapi-generic-controller/Dockerfile.local . -t ${GENERIC_IMG}
img-cluster-controller: ${CLUSTER-CONTROLLER}
docker build -f cmd/tke-cluster-controller/Dockerfile.local . -t ${CLUSTER_IMG}
img-machine-controller: ${MACHINE-CONTROLLER}
docker build -f cmd/tke-machine-controller/Dockerfile.local . -t ${MACHINE_IMG}
${GENERIC_CTL_YAML}: ${YAML_DIR}
sed -e 's@image: .*@image: '"${GENERIC_IMG}"'@' ./config/controller/clusterapi-generic-controller.yaml > $@
${CLUSTER_CTL_YAML}: ${YAML_DIR}
sed -e 's@image: .*@image: '"${CLUSTER_IMG}"'@' ./config/controller/tke-cluster-controller.yaml > $@
${MACHINE_CTL_YAML}: ${YAML_DIR}
sed -e 's@image: .*@image: '"${MACHINE_IMG}"'@' ./config/controller/tke-machine-controller.yaml > $@
yaml:
cp config/controller/tencent-cloud-api-secret.yaml ${YAML_DIR}/
make ${GENERIC_CTL_YAML}
make ${CLUSTER_CTL_YAML}
make ${MACHINE_CTL_YAML}
cat config/rbac/rbac_role.yaml >> ${ALL_IN_ONE_YAML}
echo "---" >> ${ALL_IN_ONE_YAML}
cat config/rbac/rbac_role_binding.yaml >> ${ALL_IN_ONE_YAML}
echo "---" >> ${ALL_IN_ONE_YAML}
cat ${GENERIC_CTL_YAML} >> ${ALL_IN_ONE_YAML}
echo "---" >> ${ALL_IN_ONE_YAML}
cat ${CLUSTER_CTL_YAML} >> ${ALL_IN_ONE_YAML}
echo "---" >> ${ALL_IN_ONE_YAML}
cat ${MACHINE_CTL_YAML} >> ${ALL_IN_ONE_YAML}
img-by-docker: docker-build-generic-controller docker-build-tke-cluster-controller docker-build-tke-machine-controller yaml
img: img-generic-controller img-cluster-controller img-machine-controller
push:
docker push ${GENERIC_IMG}
docker push ${CLUSTER_IMG}
docker push ${MACHINE_IMG}
help:
@echo '## build all binaries of controllers'
@echo 'make bin'
@echo 'make bin/clusterapi-generic-controller'
@echo 'make bin/tke-cluster-controller'
@echo 'make bin/tke-machine-controller'
@echo '## build all docker images from local binaries'
@echo 'REPO=ccr.ccs.tencentyun.com/ccs-dev TAG=0.2 make img'
@echo 'make img-cluster-controller'
@echo 'make docker-build-generic-controller'
@echo 'make docker-build-tke-cluster-controller'
@echo 'make docker-build-tke-machine-controller'
@echo '## push images'
@echo 'REPO=ccr.ccs.tencentyun.com/ccs-dev TAG=0.2 make push'
.PHONY : help clean controllers all bin img push img-by-docker img-generic-controller img-cluster-controller img-machine-controller tke-cluster-controller tke-machine-controller clusterapi-generic-controller docker-build-generic-controller docker-build-tke-cluster-controller docker-build-tke-machine-controller