forked from gardener/gardener
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
226 lines (188 loc) · 13 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
REGISTRY := eu.gcr.io/gardener-project/gardener
APISERVER_IMAGE_REPOSITORY := $(REGISTRY)/apiserver
CONTROLLER_MANAGER_IMAGE_REPOSITORY := $(REGISTRY)/controller-manager
SCHEDULER_IMAGE_REPOSITORY := $(REGISTRY)/scheduler
ADMISSION_IMAGE_REPOSITORY := $(REGISTRY)/admission-controller
SEED_ADMISSION_IMAGE_REPOSITORY := $(REGISTRY)/seed-admission-controller
GARDENLET_IMAGE_REPOSITORY := $(REGISTRY)/gardenlet
LANDSCAPER_GARDENLET_IMAGE_REPOSITORY := $(REGISTRY)/landscaper-gardenlet
PUSH_LATEST_TAG := false
VERSION := $(shell cat VERSION)
EFFECTIVE_VERSION := $(VERSION)-$(shell git rev-parse HEAD)
REPO_ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
LOCAL_GARDEN_LABEL := local-garden
REMOTE_GARDEN_LABEL := remote-garden
CR_VERSION := $(shell go list -m -f '{{ .Version }}' sigs.k8s.io/controller-runtime)
ACTIVATE_SEEDAUTHORIZER := false
ifneq ($(strip $(shell git status --porcelain 2>/dev/null)),)
EFFECTIVE_VERSION := $(EFFECTIVE_VERSION)-dirty
endif
#########################################
# Rules for local development scenarios #
#########################################
.PHONY: dev-setup
dev-setup:
@./hack/local-development/dev-setup
.PHONY: dev-setup-register-gardener
dev-setup-register-gardener:
@./hack/local-development/dev-setup-register-gardener
.PHONY: local-garden-up
local-garden-up:
@./hack/local-development/local-garden/start.sh $(LOCAL_GARDEN_LABEL) $(ACTIVATE_SEEDAUTHORIZER)
.PHONY: local-garden-down
local-garden-down:
@./hack/local-development/local-garden/stop.sh $(LOCAL_GARDEN_LABEL)
.PHONY: remote-garden-up
remote-garden-up:
@./hack/local-development/remote-garden/start.sh $(REMOTE_GARDEN_LABEL)
.PHONY: remote-garden-down
remote-garden-down:
@./hack/local-development/remote-garden/stop.sh $(REMOTE_GARDEN_LABEL)
.PHONY: start-apiserver
start-apiserver:
@./hack/local-development/start-apiserver
.PHONY: start-controller-manager
start-controller-manager:
@./hack/local-development/start-controller-manager
.PHONY: start-scheduler
start-scheduler:
@./hack/local-development/start-scheduler
.PHONY: start-admission-controller
start-admission-controller:
@./hack/local-development/start-admission-controller
.PHONY: start-seed-admission-controller
start-seed-admission-controller:
@./hack/local-development/start-seed-admission-controller
.PHONY: start-gardenlet
start-gardenlet:
@./hack/local-development/start-gardenlet
.PHONY: start-landscaper-gardenlet
start-landscaper-gardenlet:
@./hack/local-development/start-landscaper-gardenlet $(OPERATION)
#################################################################
# Rules related to binary build, Docker image build and release #
#################################################################
.PHONY: install
install:
@EFFECTIVE_VERSION=$(EFFECTIVE_VERSION) ./hack/install.sh ./...
.PHONY: docker-images
docker-images:
@echo "Building docker images with version and tag $(EFFECTIVE_VERSION)"
@docker build --build-arg EFFECTIVE_VERSION=$(EFFECTIVE_VERSION) -t $(APISERVER_IMAGE_REPOSITORY):$(EFFECTIVE_VERSION) -t $(APISERVER_IMAGE_REPOSITORY):latest -f Dockerfile --target apiserver .
@docker build --build-arg EFFECTIVE_VERSION=$(EFFECTIVE_VERSION) -t $(CONTROLLER_MANAGER_IMAGE_REPOSITORY):$(EFFECTIVE_VERSION) -t $(CONTROLLER_MANAGER_IMAGE_REPOSITORY):latest -f Dockerfile --target controller-manager .
@docker build --build-arg EFFECTIVE_VERSION=$(EFFECTIVE_VERSION) -t $(SCHEDULER_IMAGE_REPOSITORY):$(EFFECTIVE_VERSION) -t $(SCHEDULER_IMAGE_REPOSITORY):latest -f Dockerfile --target scheduler .
@docker build --build-arg EFFECTIVE_VERSION=$(EFFECTIVE_VERSION) -t $(ADMISSION_IMAGE_REPOSITORY):$(EFFECTIVE_VERSION) -t $(ADMISSION_IMAGE_REPOSITORY):latest -f Dockerfile --target admission-controller .
@docker build --build-arg EFFECTIVE_VERSION=$(EFFECTIVE_VERSION) -t $(SEED_ADMISSION_IMAGE_REPOSITORY):$(EFFECTIVE_VERSION) -t $(SEED_ADMISSION_IMAGE_REPOSITORY):latest -f Dockerfile --target seed-admission-controller .
@docker build --build-arg EFFECTIVE_VERSION=$(EFFECTIVE_VERSION) -t $(GARDENLET_IMAGE_REPOSITORY):$(EFFECTIVE_VERSION) -t $(GARDENLET_IMAGE_REPOSITORY):latest -f Dockerfile --target gardenlet .
@docker build --build-arg EFFECTIVE_VERSION=$(EFFECTIVE_VERSION) -t $(LANDSCAPER_GARDENLET_IMAGE_REPOSITORY):$(EFFECTIVE_VERSION) -t $(LANDSCAPER_GARDENLET_IMAGE_REPOSITORY):latest -f Dockerfile --target landscaper-gardenlet .
.PHONY: docker-images-ppc
docker-images-ppc:
@echo "Building docker images for IBM's POWER(ppc64le) with version and tag $(EFFECTIVE_VERSION)"
@docker build --build-arg GCR_PULL_URL="" --build-arg EFFECTIVE_VERSION=$(EFFECTIVE_VERSION) -t $(APISERVER_IMAGE_REPOSITORY):$(EFFECTIVE_VERSION) -t $(APISERVER_IMAGE_REPOSITORY):latest -f Dockerfile --target apiserver .
@docker build --build-arg GCR_PULL_URL="" --build-arg EFFECTIVE_VERSION=$(EFFECTIVE_VERSION) -t $(CONTROLLER_MANAGER_IMAGE_REPOSITORY):$(EFFECTIVE_VERSION) -t $(CONTROLLER_MANAGER_IMAGE_REPOSITORY):latest -f Dockerfile --target controller-manager .
@docker build --build-arg GCR_PULL_URL="" --build-arg EFFECTIVE_VERSION=$(EFFECTIVE_VERSION) -t $(SCHEDULER_IMAGE_REPOSITORY):$(EFFECTIVE_VERSION) -t $(SCHEDULER_IMAGE_REPOSITORY):latest -f Dockerfile --target scheduler .
@docker build --build-arg GCR_PULL_URL="" --build-arg EFFECTIVE_VERSION=$(EFFECTIVE_VERSION) -t $(ADMISSION_IMAGE_REPOSITORY):$(EFFECTIVE_VERSION) -t $(ADMISSION_IMAGE_REPOSITORY):latest -f Dockerfile --target admission-controller .
@docker build --build-arg GCR_PULL_URL="" --build-arg EFFECTIVE_VERSION=$(EFFECTIVE_VERSION) -t $(SEED_ADMISSION_IMAGE_REPOSITORY):$(EFFECTIVE_VERSION) -t $(SEED_ADMISSION_IMAGE_REPOSITORY):latest -f Dockerfile --target seed-admission-controller .
@docker build --build-arg GCR_PULL_URL="" --build-arg EFFECTIVE_VERSION=$(EFFECTIVE_VERSION) -t $(GARDENLET_IMAGE_REPOSITORY):$(EFFECTIVE_VERSION) -t $(GARDENLET_IMAGE_REPOSITORY):latest -f Dockerfile --target gardenlet .
@docker build --build-arg GCR_PULL_URL="" --build-arg EFFECTIVE_VERSION=$(EFFECTIVE_VERSION) -t $(LANDSCAPER_GARDENLET_IMAGE_REPOSITORY):$(EFFECTIVE_VERSION) -t $(LANDSCAPER_GARDENLET_IMAGE_REPOSITORY):latest -f Dockerfile --target landscaper-gardenlet .
.PHONY: docker-login
docker-login:
@gcloud auth activate-service-account --key-file .kube-secrets/gcr/gcr-readwrite.json
.PHONY: docker-push
docker-push:
@if ! docker images $(APISERVER_IMAGE_REPOSITORY) | awk '{ print $$2 }' | grep -q -F $(EFFECTIVE_VERSION); then echo "$(APISERVER_IMAGE_REPOSITORY) version $(EFFECTIVE_VERSION) is not yet built. Please run 'make docker-images'"; false; fi
@if ! docker images $(CONTROLLER_MANAGER_IMAGE_REPOSITORY) | awk '{ print $$2 }' | grep -q -F $(EFFECTIVE_VERSION); then echo "$(CONTROLLER_MANAGER_IMAGE_REPOSITORY) version $(EFFECTIVE_VERSION) is not yet built. Please run 'make docker-images'"; false; fi
@if ! docker images $(SCHEDULER_IMAGE_REPOSITORY) | awk '{ print $$2 }' | grep -q -F $(EFFECTIVE_VERSION); then echo "$(SCHEDULER_IMAGE_REPOSITORY) version $(EFFECTIVE_VERSION) is not yet built. Please run 'make docker-images'"; false; fi
@if ! docker images $(ADMISSION_IMAGE_REPOSITORY) | awk '{ print $$2 }' | grep -q -F $(EFFECTIVE_VERSION); then echo "$(ADMISSION_IMAGE_REPOSITORY) version $(EFFECTIVE_VERSION) is not yet built. Please run 'make docker-images'"; false; fi
@if ! docker images $(SEED_ADMISSION_IMAGE_REPOSITORY) | awk '{ print $$2 }' | grep -q -F $(EFFECTIVE_VERSION); then echo "$(SEED_ADMISSION_IMAGE_REPOSITORY) version $(EFFECTIVE_VERSION) is not yet built. Please run 'make docker-images'"; false; fi
@if ! docker images $(GARDENLET_IMAGE_REPOSITORY) | awk '{ print $$2 }' | grep -q -F $(EFFECTIVE_VERSION); then echo "$(GARDENLET_IMAGE_REPOSITORY) version $(EFFECTIVE_VERSION) is not yet built. Please run 'make docker-images'"; false; fi
@if ! docker images $(LANDSCAPER_GARDENLET_IMAGE_REPOSITORY) | awk '{ print $$2 }' | grep -q -F $(EFFECTIVE_VERSION); then echo "$(LANDSCAPER_GARDENLET_IMAGE_REPOSITORY) version $(EFFECTIVE_VERSION) is not yet built. Please run 'make docker-images'"; false; fi
@gcloud docker -- push $(APISERVER_IMAGE_REPOSITORY):$(EFFECTIVE_VERSION)
@if [[ "$(PUSH_LATEST_TAG)" == "true" ]]; then gcloud docker -- push $(APISERVER_IMAGE_REPOSITORY):latest; fi
@gcloud docker -- push $(CONTROLLER_MANAGER_IMAGE_REPOSITORY):$(EFFECTIVE_VERSION)
@if [[ "$(PUSH_LATEST_TAG)" == "true" ]]; then gcloud docker -- push $(CONTROLLER_MANAGER_IMAGE_REPOSITORY):latest; fi
@gcloud docker -- push $(SCHEDULER_IMAGE_REPOSITORY):$(EFFECTIVE_VERSION)
@if [[ "$(PUSH_LATEST_TAG)" == "true" ]]; then gcloud docker -- push $(SCHEDULER_IMAGE_REPOSITORY):latest; fi
@gcloud docker -- push $(ADMISSION_IMAGE_REPOSITORY):$(EFFECTIVE_VERSION)
@if [[ "$(PUSH_LATEST_TAG)" == "true" ]]; then gcloud docker -- push $(ADMISSION_IMAGE_REPOSITORY):latest; fi
@gcloud docker -- push $(SEED_ADMISSION_IMAGE_REPOSITORY):$(EFFECTIVE_VERSION)
@if [[ "$(PUSH_LATEST_TAG)" == "true" ]]; then gcloud docker -- push $(SEED_ADMISSION_IMAGE_REPOSITORY):latest; fi
@gcloud docker -- push $(GARDENLET_IMAGE_REPOSITORY):$(EFFECTIVE_VERSION)
@if [[ "$(PUSH_LATEST_TAG)" == "true" ]]; then gcloud docker -- push $(GARDENLET_IMAGE_REPOSITORY):latest; fi
@gcloud docker -- push $(LANDSCAPER_GARDENLET_IMAGE_REPOSITORY):$(EFFECTIVE_VERSION)
@if [[ "$(PUSH_LATEST_TAG)" == "true" ]]; then gcloud docker -- push $(LANDSCAPER_GARDENLET_IMAGE_REPOSITORY):latest; fi
#####################################################################
# Rules for verification, formatting, linting, testing and cleaning #
#####################################################################
.PHONY: install-requirements
install-requirements:
@go install -mod=vendor github.com/onsi/ginkgo/ginkgo
@go install -mod=vendor github.com/ahmetb/gen-crd-api-reference-docs
@go install -mod=vendor github.com/golang/mock/mockgen
@go install -mod=vendor sigs.k8s.io/controller-tools/cmd/controller-gen
@./hack/install-promtool.sh
@./hack/install-requirements.sh
.PHONY: revendor
revendor:
@GO111MODULE=on go mod vendor
@GO111MODULE=on go mod tidy
@curl -sSLo hack/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/$(CR_VERSION)/hack/setup-envtest.sh
.PHONY: clean
clean:
@hack/clean.sh ./cmd/... ./extensions/... ./pkg/... ./plugin/... ./test/... ./landscaper/...
.PHONY: check-generate
check-generate:
@hack/check-generate.sh $(REPO_ROOT)
.PHONY: check
check:
@hack/check.sh --golangci-lint-config=./.golangci.yaml ./cmd/... ./extensions/... ./pkg/... ./plugin/... ./test/...
@hack/check-charts.sh ./charts
# We need to explicitly pass GO111MODULE=off to k8s.io/code-generator as it is significantly slower otherwise,
# see https://github.com/kubernetes/code-generator/issues/100.
.PHONY: generate
generate:
@GO111MODULE=off hack/update-protobuf.sh
@GO111MODULE=off hack/update-codegen.sh --parallel
@hack/generate-parallel.sh cmd extensions pkg plugin landscaper test
.PHONY: generate-sequential
generate-sequential:
@GO111MODULE=off hack/update-protobuf.sh
@GO111MODULE=off hack/update-codegen.sh
@hack/generate.sh ./cmd/... ./extensions/... ./pkg/... ./plugin/... ./landscaper/... ./test/...
.PHONY: generate-extensions-crds
generate-extensions-crds:
@controller-gen crd paths=./pkg/apis/extensions/... output:crd:dir=./dev/extensions-crds output:stdout
.PHONY: format
format:
@./hack/format.sh ./cmd ./extensions ./pkg ./plugin ./test ./landscaper
.PHONY: test
test:
@./hack/test.sh ./cmd/... ./extensions/... ./pkg/... ./plugin/... ./landscaper/...
$(MAKE) test-prometheus
.PHONY: test-cov
test-cov:
@./hack/test-cover.sh ./cmd/... ./extensions/... ./pkg/... ./plugin/... ./landscaper/...
$(MAKE) test-prometheus
.PHONY: test-cov-clean
test-cov-clean:
@./hack/test-cover-clean.sh
.PHONY: test-prometheus
test-prometheus:
@./hack/test-prometheus.sh
.PHONY: verify
verify: check format test
.PHONY: verify-extended
verify-extended: install-requirements check-generate check format test-cov test-cov-clean