cilium

Форк
0
/
Makefile 
577 строк · 26.6 Кб
1
# Copyright Authors of Cilium
2
# SPDX-License-Identifier: Apache-2.0
3

4
##@ Default
5
all: precheck build postcheck ## Default make target that perform precheck -> build -> postcheck
6
	@echo "Build finished."
7

8
##@ Build, Install and Test
9
debug: export NOOPT=1 ## Builds Cilium by disabling inlining, compiler optimizations and without stripping debug symbols, useful for debugging.
10
debug: export NOSTRIP=1
11
debug: all
12

13
include Makefile.defs
14

15
SUBDIRS_CILIUM_CONTAINER := cilium-dbg daemon cilium-health bugtool tools/mount tools/sysctlfix plugins/cilium-cni
16
SUBDIR_OPERATOR_CONTAINER := operator
17
SUBDIR_RELAY_CONTAINER := hubble-relay
18

19
ifdef LIBNETWORK_PLUGIN
20
SUBDIRS_CILIUM_CONTAINER += plugins/cilium-docker
21
endif
22

23
# Add the ability to override variables
24
-include Makefile.override
25

26
# List of subdirectories used for global "make build", "make clean", etc
27
SUBDIRS := $(SUBDIRS_CILIUM_CONTAINER) $(SUBDIR_OPERATOR_CONTAINER) plugins tools $(SUBDIR_RELAY_CONTAINER) bpf
28

29
# Filter out any directories where the parent directory is also present, to avoid
30
# building or cleaning a subdirectory twice.
31
# For example: The directory "tools" is transformed into a match pattern "tools/%",
32
# which is then used to filter out items such as "tools/mount" and "tools/sysctlfx"
33
SUBDIRS := $(filter-out $(foreach dir,$(SUBDIRS),$(dir)/%),$(SUBDIRS))
34

35
# Space-separated list of Go packages to test, equivalent to 'go test' package patterns.
36
# Because is treated as a Go package pattern, the special '...' sequence is supported,
37
# meaning 'all subpackages of the given package'.
38
TESTPKGS ?= ./...
39

40
GOTEST_BASE := -timeout 600s
41
GOTEST_COVER_OPTS += -coverprofile=coverage.out
42
BENCH_EVAL := "."
43
BENCH ?= $(BENCH_EVAL)
44
BENCHFLAGS_EVAL := -bench=$(BENCH) -run=^$ -benchtime=10s
45
BENCHFLAGS ?= $(BENCHFLAGS_EVAL)
46
SKIP_KVSTORES ?= "false"
47
SKIP_K8S_CODE_GEN_CHECK ?= "true"
48
SKIP_CUSTOMVET_CHECK ?= "false"
49

50
JOB_BASE_NAME ?= cilium_test
51

52
TEST_LDFLAGS=-ldflags "-X github.com/cilium/cilium/pkg/kvstore.consulDummyAddress=https://consul:8443 \
53
	-X github.com/cilium/cilium/pkg/kvstore.etcdDummyAddress=http://etcd:4002 \
54
	-X github.com/cilium/cilium/pkg/datapath.datapathSHA256=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
55

56
TEST_UNITTEST_LDFLAGS=-ldflags "-X github.com/cilium/cilium/pkg/datapath.datapathSHA256=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
57

58
BPF_SOURCE_NAMES_TO_IDS ?= bpf/source_names_to_ids.h
59
GO_SOURCE_NAMES_TO_IDS ?= pkg/monitor/datapath_drop.go
60

61
build: check-sources $(SUBDIRS) ## Builds all the components for Cilium by executing make in the respective sub directories.
62

63
build-container: check-sources ## Builds components required for cilium-agent container.
64
	for i in $(SUBDIRS_CILIUM_CONTAINER); do $(MAKE) $(SUBMAKEOPTS) -C $$i all; done
65

66
build-container-operator: ## Builds components required for cilium-operator container.
67
	$(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_OPERATOR_CONTAINER) all
68

69
build-container-operator-generic: ## Builds components required for a cilium-operator generic variant container.
70
	$(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_OPERATOR_CONTAINER) cilium-operator-generic
71

72
build-container-operator-aws: ## Builds components required for a cilium-operator aws variant container.
73
	$(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_OPERATOR_CONTAINER) cilium-operator-aws
74

75
build-container-operator-azure: ## Builds components required for a cilium-operator azure variant container.
76
	$(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_OPERATOR_CONTAINER) cilium-operator-azure
77

78
build-container-operator-alibabacloud: ## Builds components required for a cilium-operator alibabacloud variant container.
79
	$(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_OPERATOR_CONTAINER) cilium-operator-alibabacloud
80

81
build-container-hubble-relay:
82
	$(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_RELAY_CONTAINER) all
83

84
$(SUBDIRS): force ## Execute default make target(make all) for the provided subdirectory.
85
	@ $(MAKE) $(SUBMAKEOPTS) -C $@ all
86

87
tests-privileged: ## Run Go tests including ones that require elevated privileges.
88
	@$(ECHO_CHECK) running privileged tests...
89
	PRIVILEGED_TESTS=true PATH=$(PATH):$(ROOT_DIR)/bpf $(GO_TEST) $(TEST_LDFLAGS) \
90
		$(TESTPKGS) $(GOTEST_BASE) $(GOTEST_COVER_OPTS) | $(GOTEST_FORMATTER)
91
	$(MAKE) generate-cov
92

93
start-kvstores: ## Start running kvstores (etcd and consul containers) for integration tests.
94
ifeq ($(SKIP_KVSTORES),"false")
95
	@echo Starting key-value store containers...
96
	-$(QUIET)$(CONTAINER_ENGINE) rm -f "cilium-etcd-test-container" 2> /dev/null
97
	$(QUIET)$(CONTAINER_ENGINE) run -d \
98
		-e ETCD_UNSUPPORTED_ARCH=$(GOARCH) \
99
		--name "cilium-etcd-test-container" \
100
		-p 4002:4001 \
101
		$(ETCD_IMAGE) \
102
		etcd -name etcd0 \
103
		-advertise-client-urls http://0.0.0.0:4001 \
104
		-listen-client-urls http://0.0.0.0:4001 \
105
		-listen-peer-urls http://0.0.0.0:2380 \
106
		-initial-cluster-token etcd-cluster-1 \
107
		-initial-cluster-state new
108
	-$(QUIET)$(CONTAINER_ENGINE) rm -f "cilium-consul-test-container" 2> /dev/null
109
	$(QUIET)rm -rf /tmp/cilium-consul-certs
110
	$(QUIET)mkdir /tmp/cilium-consul-certs
111
	$(QUIET)cp $(CURDIR)/test/consul/* /tmp/cilium-consul-certs
112
	$(QUIET)chmod -R a+rX /tmp/cilium-consul-certs
113
	$(QUIET)$(CONTAINER_ENGINE) run -d \
114
		--name "cilium-consul-test-container" \
115
		-p 8501:8443 \
116
		-e 'CONSUL_LOCAL_CONFIG={"skip_leave_on_interrupt": true, "disable_update_check": true}' \
117
		-v /tmp/cilium-consul-certs:/cilium-consul/ \
118
		$(CONSUL_IMAGE) \
119
		agent -client=0.0.0.0 -server -bootstrap-expect 1 -config-file=/cilium-consul/consul-config.json
120
endif
121

122
stop-kvstores: ## Forcefully removes running kvstore components (etcd and consul containers) for integration tests.
123
ifeq ($(SKIP_KVSTORES),"false")
124
	$(QUIET)$(CONTAINER_ENGINE) rm -f "cilium-etcd-test-container"
125
	$(QUIET)$(CONTAINER_ENGINE) rm -f "cilium-consul-test-container"
126
	$(QUIET)rm -rf /tmp/cilium-consul-certs
127
endif
128

129
generate-cov: ## Generate HTML coverage report at coverage-all.html.
130
	# Remove generated code from coverage
131
	$(QUIET) grep -Ev '(^github.com/cilium/cilium/api/v1)|(generated.deepcopy.go)|(^github.com/cilium/cilium/pkg/k8s/client/)' \
132
		coverage.out > coverage.out.tmp
133
	$(QUIET)$(GO) tool cover -html=coverage.out.tmp -o=coverage-all.html
134
	$(QUIET) rm coverage.out.tmp
135
	@rmdir ./daemon/1 ./daemon/1_backup 2> /dev/null || true
136

137
integration-tests: start-kvstores ## Run Go tests including ones that are marked as integration tests.
138
	$(QUIET) $(MAKE) $(SUBMAKEOPTS) -C test/bpf/
139
	@$(ECHO_CHECK) running integration tests...
140
	INTEGRATION_TESTS=true $(GO_TEST) $(TEST_UNITTEST_LDFLAGS) $(TESTPKGS) $(GOTEST_BASE) $(GOTEST_COVER_OPTS) | $(GOTEST_FORMATTER)
141
	$(MAKE) generate-cov
142
	$(MAKE) stop-kvstores
143

144
bench: start-kvstores ## Run benchmarks for Cilium integration-tests in the repository.
145
	$(GO_TEST) $(TEST_UNITTEST_LDFLAGS) $(GOTEST_BASE) $(BENCHFLAGS) $(TESTPKGS)
146
	$(MAKE) stop-kvstores
147

148
bench-privileged: ## Run benchmarks for privileged tests.
149
	PRIVILEGED_TESTS=true $(GO_TEST) $(TEST_UNITTEST_LDFLAGS) $(GOTEST_BASE) $(BENCHFLAGS) $(TESTPKGS)
150

151
clean-tags: ## Remove all the tags files from the repository.
152
	@$(ECHO_CLEAN) tags
153
	@-rm -f cscope.out cscope.in.out cscope.po.out cscope.files tags
154

155
.PHONY: cscope.files
156
cscope.files: ## Generate cscope.files with the list of all files to generate ctags for.
157
	@# Argument to -f must be double-quoted since shell removes backslashes that appear
158
	@# before newlines. Otherwise, backslashes will appear in the output file.
159
	@go list -f "{{ \$$p := .ImportPath }} \
160
		{{- range .GoFiles }}{{ printf \"%s/%s\n\" \$$p . }}{{ end }} \
161
		{{- range .TestGoFiles }}{{ printf \"%s/%s\n\" \$$p . }}{{ end }}" ./... \
162
		| sed 's#github.com/cilium/cilium/##g' | sort | uniq > cscope.files
163

164
	@echo "$(BPF_SRCFILES)" | sed 's/ /\n/g' | sort >> cscope.files
165

166
tags: cscope.files ## Generate tags for Go and BPF source files.
167
	@ctags -L cscope.files
168
	cscope -R -b -q
169

170
clean-container: ## Perform `make clean` for each component required in cilium-agent container.
171
	-$(QUIET) for i in $(SUBDIRS_CILIUM_CONTAINER); do $(MAKE) $(SUBMAKEOPTS) -C $$i clean; done
172

173
clean: ## Perform overall cleanup for Cilium.
174
	-$(QUIET) for i in $(SUBDIRS); do $(MAKE) $(SUBMAKEOPTS) -C $$i clean; done
175

176
veryclean: ## Perform complete cleanup for container engine images(including build cache).
177
	-$(QUIET) $(CONTAINER_ENGINE) image prune -af
178
	-$(QUIET) $(CONTAINER_ENGINE) builder prune -af
179

180
install-bpf: ## Copies over the BPF source files from bpf/ to /var/lib/cilium/bpf/
181
	$(QUIET)$(INSTALL) -m 0750 -d $(DESTDIR)$(LOCALSTATEDIR)/lib/cilium
182
	-rm -rf $(DESTDIR)$(LOCALSTATEDIR)/lib/cilium/bpf/*
183
	$(foreach bpfsrc,$(BPF_SRCFILES), $(INSTALL) -D -m 0644 $(bpfsrc) $(DESTDIR)$(LOCALSTATEDIR)/lib/cilium/$(bpfsrc);)
184

185
install: install-bpf ## Performs install for all the Cilium sub components (daemon, operator, relay etc.)
186
	$(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR)
187
	for i in $(SUBDIRS); do $(MAKE) $(SUBMAKEOPTS) -C $$i install; done
188

189
install-container: install-bpf ## Performs install for all components required for cilium-agent container.
190
	$(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR)
191
	for i in $(SUBDIRS_CILIUM_CONTAINER); do $(MAKE) $(SUBMAKEOPTS) -C $$i install; done
192

193
install-container-binary: install-bpf ## Install binaries for all components required for cilium-agent container.
194
	$(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR)
195
	for i in $(SUBDIRS_CILIUM_CONTAINER); do $(MAKE) $(SUBMAKEOPTS) -C $$i install-binary; done
196

197
install-bash-completion: ## Install bash completion for all components required for cilium-agent container.
198
	$(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR)
199
	for i in $(SUBDIRS_CILIUM_CONTAINER); do $(MAKE) $(SUBMAKEOPTS) -C $$i install-bash-completion; done
200

201
install-container-binary-operator: ## Install binaries for all components required for cilium-operator container.
202
	$(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR)
203
	$(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_OPERATOR_CONTAINER) install
204

205
install-container-binary-operator-generic: ## Install binaries for all components required for cilium-operator generic variant container.
206
	$(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR)
207
	$(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_OPERATOR_CONTAINER) install-generic
208

209
install-container-binary-operator-aws: ## Install binaries for all components required for cilium-operator aws variant container.
210
	$(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR)
211
	$(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_OPERATOR_CONTAINER) install-aws
212

213
install-container-binary-operator-azure: ## Install binaries for all components required for cilium-operator azure variant container.
214
	$(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR)
215
	$(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_OPERATOR_CONTAINER) install-azure
216

217
install-container-binary-operator-alibabacloud: ## Install binaries for all components required for cilium-operator alibabacloud variant container.
218
	$(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR)
219
	$(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_OPERATOR_CONTAINER) install-alibabacloud
220

221
install-container-binary-hubble-relay:
222
	$(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR)
223
	$(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_RELAY_CONTAINER) install-binary
224

225
# Workaround for not having git in the build environment
226
# Touch the file only if needed
227
GIT_VERSION: force
228
	@if [ "$(GIT_VERSION)" != "`cat 2>/dev/null GIT_VERSION`" ] ; then echo "$(GIT_VERSION)" >GIT_VERSION; fi
229

230
include Makefile.kind
231

232
-include Makefile.docker
233

234
##@ API targets
235
CRD_OPTIONS ?= "crd:crdVersions=v1"
236
CRD_PATHS := "$(PWD)/pkg/k8s/apis/cilium.io/v2;\
237
              $(PWD)/pkg/k8s/apis/cilium.io/v2alpha1;"
238
CRDS_CILIUM_PATHS := $(PWD)/pkg/k8s/apis/cilium.io/client/crds/v2\
239
                     $(PWD)/pkg/k8s/apis/cilium.io/client/crds/v2alpha1
240
CRDS_CILIUM_V2 := ciliumnetworkpolicies \
241
                  ciliumclusterwidenetworkpolicies \
242
                  ciliumendpoints \
243
                  ciliumidentities \
244
                  ciliumnodes \
245
                  ciliumexternalworkloads \
246
                  ciliumlocalredirectpolicies \
247
                  ciliumegressgatewaypolicies \
248
                  ciliumenvoyconfigs \
249
                  ciliumclusterwideenvoyconfigs
250
CRDS_CILIUM_V2ALPHA1 := ciliumendpointslices \
251
                        ciliumbgppeeringpolicies \
252
                        ciliumbgpclusterconfigs \
253
                        ciliumbgppeerconfigs \
254
                        ciliumbgpadvertisements \
255
                        ciliumbgpnodeconfigs \
256
                        ciliumbgpnodeconfigoverrides \
257
                        ciliumloadbalancerippools \
258
                        ciliumnodeconfigs \
259
                        ciliumcidrgroups \
260
                        ciliuml2announcementpolicies \
261
                        ciliumpodippools
262

263
manifests: ## Generate K8s manifests e.g. CRD, RBAC etc.
264
	$(eval TMPDIR := $(shell mktemp -d -t cilium.tmpXXXXXXXX))
265
	$(QUIET)$(GO) run sigs.k8s.io/controller-tools/cmd/controller-gen $(CRD_OPTIONS) paths=$(CRD_PATHS) output:crd:artifacts:config="$(TMPDIR)"
266
	$(QUIET)$(GO) run ./tools/crdcheck "$(TMPDIR)"
267

268
	# Clean up old CRD state and start with a blank state.
269
	for path in $(CRDS_CILIUM_PATHS); do rm -rf $${path} && mkdir $${path}; done
270

271
	for file in $(CRDS_CILIUM_V2); do mv ${TMPDIR}/cilium.io_$${file}.yaml ./pkg/k8s/apis/cilium.io/client/crds/v2/$${file}.yaml; done
272
	for file in $(CRDS_CILIUM_V2ALPHA1); do mv ${TMPDIR}/cilium.io_$${file}.yaml ./pkg/k8s/apis/cilium.io/client/crds/v2alpha1/$${file}.yaml; done
273
	rm -rf $(TMPDIR)
274

275
generate-api: api/v1/openapi.yaml ## Generate cilium-agent client, model and server code from openapi spec.
276
	@$(ECHO_GEN)api/v1/openapi.yaml
277
	-$(QUIET)$(SWAGGER) generate server -s server -a restapi \
278
		-t api/v1 \
279
		-f api/v1/openapi.yaml \
280
		--default-scheme=unix \
281
		-C api/v1/cilium-server.yml \
282
		-r hack/spdx-copyright-header.txt
283
	-$(QUIET)$(SWAGGER) generate client -a restapi \
284
		-t api/v1 \
285
		-f api/v1/openapi.yaml \
286
		-r hack/spdx-copyright-header.txt
287
	@# sort goimports automatically
288
	-$(QUIET)$(GO) run golang.org/x/tools/cmd/goimports -w ./api/v1/client ./api/v1/models ./api/v1/server
289

290
generate-health-api: api/v1/health/openapi.yaml ## Generate cilium-health client, model and server code from openapi spec.
291
	@$(ECHO_GEN)api/v1/health/openapi.yaml
292
	-$(QUIET)$(SWAGGER) generate server -s server -a restapi \
293
		-t api/v1 \
294
		-t api/v1/health/ \
295
		-f api/v1/health/openapi.yaml \
296
		--default-scheme=unix \
297
		-C api/v1/cilium-server.yml \
298
		-r hack/spdx-copyright-header.txt
299
	-$(QUIET)$(SWAGGER) generate client -a restapi \
300
		-t api/v1 \
301
		-t api/v1/health/ \
302
		-f api/v1/health/openapi.yaml \
303
		-r hack/spdx-copyright-header.txt
304
	@# sort goimports automatically
305
	-$(QUIET)$(GO) run golang.org/x/tools/cmd/goimports -w ./api/v1/health
306

307
generate-operator-api: api/v1/operator/openapi.yaml ## Generate cilium-operator client, model and server code from openapi spec.
308
	@$(ECHO_GEN)api/v1/operator/openapi.yaml
309
	-$(QUIET)$(SWAGGER) generate server -s server -a restapi \
310
		-t api/v1 \
311
		-t api/v1/operator/ \
312
		-f api/v1/operator/openapi.yaml \
313
		--default-scheme=http \
314
		-C api/v1/cilium-server.yml \
315
		-r hack/spdx-copyright-header.txt
316
	-$(QUIET)$(SWAGGER) generate client -a restapi \
317
		-t api/v1 \
318
		-t api/v1/operator/ \
319
		-f api/v1/operator/openapi.yaml \
320
		-r hack/spdx-copyright-header.txt
321
	@# sort goimports automatically
322
	-$(QUIET)$(GO) run golang.org/x/tools/cmd/goimports -w ./api/v1/operator
323

324
generate-hubble-api: api/v1/flow/flow.proto api/v1/peer/peer.proto api/v1/observer/observer.proto api/v1/relay/relay.proto ## Generate hubble proto Go sources.
325
	$(QUIET) $(MAKE) $(SUBMAKEOPTS) -C api/v1
326

327
define generate_k8s_api
328
	$(QUIET) cd "./vendor/k8s.io/code-generator" && \
329
	bash ./generate-internal-groups.sh $(1) \
330
	    $(2) \
331
	    "" \
332
	    $(3) \
333
	    $(4) \
334
	    --go-header-file "$(PWD)/hack/custom-boilerplate.go.txt" \
335
	    --output-base $(5)
336
endef
337

338
define generate_deepequal
339
	$(GO) run github.com/cilium/deepequal-gen \
340
	--input-dirs $(subst $(space),$(comma),$(1)) \
341
	--go-header-file "$(PWD)/hack/custom-boilerplate.go.txt" \
342
	--output-file-base zz_generated.deepequal \
343
	--output-base $(2)
344
endef
345

346
define generate_deepcopy
347
	$(GO) run k8s.io/code-generator/cmd/deepcopy-gen \
348
	--input-dirs $(subst $(space),$(comma),$(1)) \
349
	--go-header-file "$(PWD)/hack/custom-boilerplate.go.txt" \
350
	--output-file-base zz_generated.deepcopy \
351
	--output-base $(2)
352
endef
353

354
define generate_k8s_protobuf
355
	$(GO) install k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo && \
356
	$(GO) install golang.org/x/tools/cmd/goimports && \
357
	$(GO) run k8s.io/code-generator/cmd/go-to-protobuf \
358
		--apimachinery-packages='-k8s.io/apimachinery/pkg/util/intstr,$\
359
                                -k8s.io/apimachinery/pkg/api/resource,$\
360
                                -k8s.io/apimachinery/pkg/runtime/schema,$\
361
                                -k8s.io/apimachinery/pkg/runtime,$\
362
                                -k8s.io/apimachinery/pkg/apis/meta/v1,$\
363
                                -k8s.io/apimachinery/pkg/apis/meta/v1beta1'\
364
		--drop-embedded-fields="github.com/cilium/cilium/pkg/k8s/slim/k8s/apis/meta/v1.TypeMeta" \
365
		--proto-import="$(PWD)" \
366
		--proto-import="$(PWD)/vendor" \
367
		--proto-import="$(PWD)/tools/protobuf" \
368
		--packages=$(subst $(newline),$(comma),$(1)) \
369
		--go-header-file "$(PWD)/hack/custom-boilerplate.go.txt" \
370
		--output-base=$(2)
371
endef
372

373
define K8S_PROTO_PACKAGES
374
github.com/cilium/cilium/pkg/k8s/slim/k8s/api/core/v1
375
github.com/cilium/cilium/pkg/k8s/slim/k8s/api/discovery/v1
376
github.com/cilium/cilium/pkg/k8s/slim/k8s/api/discovery/v1beta1
377
github.com/cilium/cilium/pkg/k8s/slim/k8s/api/networking/v1
378
github.com/cilium/cilium/pkg/k8s/slim/k8s/apis/apiextensions/v1
379
github.com/cilium/cilium/pkg/k8s/slim/k8s/apis/meta/v1
380
github.com/cilium/cilium/pkg/k8s/slim/k8s/apis/meta/v1beta1
381
github.com/cilium/cilium/pkg/k8s/slim/k8s/apis/util/intstr
382
endef
383

384
GEN_CRD_GROUPS := "cilium.io:v2\
385
                   cilium.io:v2alpha1"
386
generate-k8s-api: ## Generate Cilium k8s API client, deepcopy and deepequal Go sources.
387
	$(ASSERT_CILIUM_MODULE)
388

389
	$(eval TMPDIR := $(shell mktemp -d -t cilium.tmpXXXXXXXX))
390

391
	$(QUIET) $(call generate_k8s_protobuf,${K8S_PROTO_PACKAGES},"$(TMPDIR)")
392

393
	$(eval DEEPEQUAL_PACKAGES := $(shell grep "\+deepequal-gen" -l -r --include \*.go --exclude-dir 'vendor' . | xargs dirname {} | sort | uniq | grep -x -v '.' | sed 's|\.\/|github.com/cilium/cilium\/|g'))
394
	$(QUIET) $(call generate_deepequal,${DEEPEQUAL_PACKAGES},"$(TMPDIR)")
395

396
	$(eval DEEPCOPY_PACKAGES := $(shell grep "\+k8s:deepcopy-gen" -l -r --include \*.go --exclude-dir 'vendor' . | xargs dirname {} | sort | uniq | grep -x -v '.' | sed 's|\.\/|github.com/cilium/cilium\/|g'))
397
	$(QUIET) $(call generate_deepcopy,${DEEPCOPY_PACKAGES},"$(TMPDIR)")
398

399
	$(QUIET) $(call generate_k8s_api,client,github.com/cilium/cilium/pkg/k8s/slim/k8s/client,github.com/cilium/cilium/pkg/k8s/slim/k8s/api,"discovery:v1beta1 discovery:v1 networking:v1 core:v1","$(TMPDIR)")
400
	$(QUIET) $(call generate_k8s_api,client,github.com/cilium/cilium/pkg/k8s/slim/k8s/apiextensions-client,github.com/cilium/cilium/pkg/k8s/slim/k8s/apis,"apiextensions:v1","$(TMPDIR)")
401
	$(QUIET) $(call generate_k8s_api,client$(comma)lister$(comma)informer,github.com/cilium/cilium/pkg/k8s/client,github.com/cilium/cilium/pkg/k8s/apis,$(GEN_CRD_GROUPS),"$(TMPDIR)")
402

403
	$(QUIET) cp -r "$(TMPDIR)/github.com/cilium/cilium/." ./
404
	$(QUIET) rm -rf "$(TMPDIR)"
405

406
check-k8s-clusterrole: ## Ensures there is no diff between preflight's clusterrole and runtime's clusterrole.
407
	./contrib/scripts/check-preflight-clusterrole.sh
408

409
##@ Development
410
vps: ## List all the running vagrant VMs.
411
	VBoxManage list runningvms
412

413
reload: ## Reload cilium-agent and cilium-docker systemd service after installing built binaries.
414
	sudo systemctl stop cilium cilium-docker
415
	sudo $(MAKE) install
416
	sudo systemctl start cilium cilium-docker
417
	sleep 6
418
	cilium status
419

420
release: ## Perform a Git release for Cilium.
421
	$(eval TAG_VERSION := $(shell git tag | grep v$(VERSION) > /dev/null; echo $$?))
422
	$(eval BRANCH := $(shell git rev-parse --abbrev-ref HEAD))
423
	$(info Checking if tag $(VERSION) is created '$(TAG_VERSION)' $(BRANCH))
424

425
	@if [ "$(TAG_VERSION)" -eq "0" ];then { echo Git tag v$(VERSION) is already created; exit 1; } fi
426
	git commit -m "Version $(VERSION)"
427
	git tag v$(VERSION)
428
	git archive --format tar $(BRANCH) | gzip > ../cilium_$(VERSION).orig.tar.gz
429

430
gofmt: ## Run gofmt on Go source files in the repository.
431
	$(QUIET)$(GO) fmt ./...
432

433
govet: ## Run govet on Go source files in the repository.
434
	@$(ECHO_CHECK) vetting all packages...
435
	$(QUIET) $(GO_VET) ./...
436

437
golangci-lint: ## Run golangci-lint
438
ifneq (,$(findstring $(GOLANGCILINT_WANT_VERSION:v%=%),$(GOLANGCILINT_VERSION)))
439
	@$(ECHO_CHECK) golangci-lint $(GOLANGCI_LINT_ARGS)
440
	$(QUIET) golangci-lint run $(GOLANGCI_LINT_ARGS)
441
else
442
	$(QUIET) $(CONTAINER_ENGINE) run --rm -v `pwd`:/app -w /app docker.io/golangci/golangci-lint:$(GOLANGCILINT_WANT_VERSION)@$(GOLANGCILINT_IMAGE_SHA) golangci-lint run $(GOLANGCI_LINT_ARGS)
443
endif
444

445
golangci-lint-fix: ## Run golangci-lint to automatically fix warnings
446
	$(QUIET)$(MAKE) golangci-lint GOLANGCI_LINT_ARGS="--fix"
447

448
lint: golangci-lint
449

450
lint-fix: golangci-lint-fix
451

452
logging-subsys-field: ## Validate logrus subsystem field for logs in Go source code.
453
	@$(ECHO_CHECK) contrib/scripts/check-logging-subsys-field.sh
454
	$(QUIET) contrib/scripts/check-logging-subsys-field.sh
455

456
check-microk8s: ## Validate if microk8s is ready to install cilium.
457
	@$(ECHO_CHECK) microk8s is ready...
458
	$(QUIET)microk8s.status >/dev/null \
459
		|| (echo "Error: Microk8s is not running" && exit 1)
460

461
LOCAL_IMAGE_TAG=local
462
microk8s: export DOCKER_REGISTRY=localhost:32000
463
microk8s: export LOCAL_AGENT_IMAGE=$(DOCKER_REGISTRY)/$(DOCKER_DEV_ACCOUNT)/cilium-dev:$(LOCAL_IMAGE_TAG)
464
microk8s: export LOCAL_OPERATOR_IMAGE=$(DOCKER_REGISTRY)/$(DOCKER_DEV_ACCOUNT)/operator:$(LOCAL_IMAGE_TAG)
465
microk8s: check-microk8s ## Build cilium-dev docker image and import to microk8s
466
	$(QUIET)$(MAKE) dev-docker-image DOCKER_IMAGE_TAG=$(LOCAL_IMAGE_TAG)
467
	@echo "  DEPLOY image to microk8s ($(LOCAL_AGENT_IMAGE))"
468
	$(QUIET)./contrib/scripts/microk8s-import.sh $(LOCAL_AGENT_IMAGE)
469
	$(QUIET)$(MAKE) dev-docker-operator-image DOCKER_IMAGE_TAG=$(LOCAL_IMAGE_TAG)
470
	@echo "  DEPLOY image to microk8s ($(LOCAL_OPERATOR_IMAGE))"
471
	$(QUIET)./contrib/scripts/microk8s-import.sh $(LOCAL_OPERATOR_IMAGE)
472

473
precheck: logging-subsys-field ## Peform build precheck for the source code.
474
ifeq ($(SKIP_K8S_CODE_GEN_CHECK),"false")
475
	@$(ECHO_CHECK) contrib/scripts/check-k8s-code-gen.sh
476
	$(QUIET) contrib/scripts/check-k8s-code-gen.sh
477
endif
478
	@$(ECHO_CHECK) contrib/scripts/check-fmt.sh
479
	$(QUIET) contrib/scripts/check-fmt.sh
480
	@$(ECHO_CHECK) contrib/scripts/check-log-newlines.sh
481
	$(QUIET) contrib/scripts/check-log-newlines.sh
482
	@$(ECHO_CHECK) contrib/scripts/check-test-tags.sh
483
	$(QUIET) contrib/scripts/check-test-tags.sh
484
	@$(ECHO_CHECK) contrib/scripts/check-assert-deep-equals.sh
485
	$(QUIET) contrib/scripts/check-assert-deep-equals.sh
486
	@$(ECHO_CHECK) contrib/scripts/lock-check.sh
487
	$(QUIET) contrib/scripts/lock-check.sh
488
	@$(ECHO_CHECK) contrib/scripts/check-viper.sh
489
	$(QUIET) contrib/scripts/check-viper.sh
490
ifeq ($(SKIP_CUSTOMVET_CHECK),"false")
491
	@$(ECHO_CHECK) contrib/scripts/custom-vet-check.sh
492
	$(QUIET) contrib/scripts/custom-vet-check.sh
493
endif
494
	@$(ECHO_CHECK) contrib/scripts/rand-check.sh
495
	$(QUIET) contrib/scripts/rand-check.sh
496
	@$(ECHO_CHECK) contrib/scripts/check-time.sh
497
	$(QUIET) contrib/scripts/check-time.sh
498

499
check-sources:
500
	@$(ECHO_CHECK) pkg/datapath/loader/check-sources.sh
501
	$(QUIET) BPF_SOURCE_NAMES_TO_IDS=$(BPF_SOURCE_NAMES_TO_IDS) GO_SOURCE_NAMES_TO_IDS=$(GO_SOURCE_NAMES_TO_IDS) pkg/datapath/loader/check-sources.sh
502

503
pprof-heap: ## Get Go pprof heap profile.
504
	$(QUIET)$(GO) tool pprof http://localhost:6060/debug/pprof/heap
505

506
pprof-profile: ## Get Go pprof profile.
507
	$(QUIET)$(GO) tool pprof http://localhost:6060/debug/pprof/profile
508

509
pprof-block: ## Get Go pprof block profile.
510
	$(QUIET)$(GO) tool pprof http://localhost:6060/debug/pprof/block
511

512
pprof-trace-5s: ## Get Go pprof trace for a duration of 5 seconds.
513
	curl http://localhost:6060/debug/pprof/trace?seconds=5
514

515
pprof-mutex: ## Get Go pprof mutex profile.
516
	$(QUIET)$(GO) tool pprof http://localhost:6060/debug/pprof/mutex
517

518
update-authors: ## Update AUTHORS file for Cilium repository.
519
	@echo "Updating AUTHORS file..."
520
	@echo "The following people, in alphabetical order, have either authored or signed" > AUTHORS
521
	@echo "off on commits in the Cilium repository:" >> AUTHORS
522
	@echo "" >> AUTHORS
523
	@contrib/scripts/extract_authors.sh >> AUTHORS
524
	@cat .authors.aux >> AUTHORS
525

526
generate-crd-docs: ## Generate CRD List for documentation
527
	$(QUIET)$(GO) run ./tools/crdlistgen
528

529
test-docs: ## Build HTML documentation.
530
	$(MAKE) -C Documentation html
531

532
render-docs: ## Run server with live preview to render documentation.
533
	$(MAKE) -C Documentation live-preview
534

535
manpages: ## Generate manpage for Cilium CLI.
536
	-rm -r man
537
	mkdir -p man
538
	cilium cmdman -d man
539

540
install-manpages: ## Install manpages the Cilium CLI.
541
	cp man/* /usr/local/share/man/man1/
542
	mandb
543

544
postcheck: build ## Run Cilium build postcheck (update-cmdref, build documentation etc.).
545
	$(QUIET) SKIP_BUILD=true $(MAKE) $(SUBMAKEOPTS) -C Documentation check
546

547
licenses-all: ## Generate file with all the License from dependencies.
548
	@$(GO) run ./tools/licensegen > LICENSE.all || ( rm -f LICENSE.all ; false )
549

550
dev-doctor: ## Run Cilium dev-doctor to validate local development environment.
551
	$(QUIET)$(GO) version 2>/dev/null || ( echo "go not found, see https://golang.org/doc/install" ; false )
552
	$(QUIET)$(GO) run ./tools/dev-doctor
553

554
help: ## Display help for the Makefile, from https://www.thapaliya.com/en/writings/well-documented-makefiles/.
555
	$(call print_help_from_makefile)
556
	@# There is also a list of target we have to manually put the information about.
557
	@# These are templated targets.
558
	$(call print_help_line,"docker-cilium-image","Build cilium-agent docker image")
559
	$(call print_help_line,"dev-docker-image","Build cilium-agent development docker image")
560
	$(call print_help_line,"docker-plugin-image","Build cilium-docker plugin image")
561
	$(call print_help_line,"docker-hubble-relay-image","Build hubble-relay docker image")
562
	$(call print_help_line,"docker-clustermesh-apiserver-image","Build docker image for Cilium clustermesh APIServer")
563
	$(call print_help_line,"docker-operator-image","Build cilium-operator docker image")
564
	$(call print_help_line,"docker-operator-*-image","Build platform specific cilium-operator images(alibabacloud, aws, azure, generic)")
565
	$(call print_help_line,"docker-*-image-unstripped","Build unstripped version of above docker images(cilium, hubble-relay, operator etc.)")
566

567
.PHONY: help clean clean-container dev-doctor force generate-api generate-health-api generate-operator-api generate-hubble-api install licenses-all veryclean check-sources
568
force :;
569

570
# this top level run_bpf_tests target will run the bpf unit tests inside the Cilium Builder container.
571
# it exists here so the entire source code repo can be mounted into the container.
572
CILIUM_BUILDER_IMAGE=$(shell cat images/cilium/Dockerfile | grep "ARG CILIUM_BUILDER_IMAGE=" | cut -d"=" -f2)
573
run_bpf_tests:
574
	docker run -v $$(pwd):/src --privileged -w /src -e RUN_WITH_SUDO=false $(CILIUM_BUILDER_IMAGE) "make" "-C" "test/" "run_bpf_tests"
575

576
run-builder:
577
	docker run -it --rm -v $$(pwd):/go/src/github.com/cilium/cilium $(CILIUM_BUILDER_IMAGE) bash
578

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.