forked from cilium/cilium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.kind
455 lines (382 loc) · 21.4 KB
/
Makefile.kind
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
# Copyright Authors of Cilium
# SPDX-License-Identifier: Apache-2.0
##@ Development (Kind)
.PHONY: kind
kind: ## Create a kind cluster for Cilium development.
$(QUIET)SED=$(SED) ./contrib/scripts/kind.sh
.PHONY: kind-egressgw
kind-egressgw: ## Create a kind cluster for egress gateway Cilium development.
$(QUIET)SED=$(SED) WORKERS=3 ./contrib/scripts/kind.sh
kubectl patch node kind-worker3 --type=json -p='[{"op":"add","path":"/metadata/labels/cilium.io~1no-schedule","value":"true"}]'
.PHONY: kind-down
kind-down: ## Destroy a kind cluster for Cilium development.
$(QUIET)./contrib/scripts/kind-down.sh
.PHONY: kind-clustermesh
kind-clustermesh: ## Create two kind clusters for clustermesh development.
@echo " If you have problems with too many open file, check https://kind.sigs.k8s.io/docs/user/known-issues/#pod-errors-due-to-too-many-open-files"
$(QUIET) CLUSTER_NAME=clustermesh1 IPFAMILY=dual PODSUBNET=10.1.0.0/16,fd00:10:1::/48 SERVICESUBNET=172.20.1.0/24,fd00:10:f1::/112 ./contrib/scripts/kind.sh
$(QUIET) CLUSTER_NAME=clustermesh2 AGENTPORTPREFIX=236 OPERATORPORTPREFIX=237 IPFAMILY=dual PODSUBNET=10.2.0.0/16,fd00:10:2::/48 SERVICESUBNET=172.20.2.0/24,fd00:10:f2::/112 ./contrib/scripts/kind.sh
.PHONY: kind-clustermesh-down
kind-clustermesh-down: ## Destroy kind clusters for clustermesh development.
$(QUIET)./contrib/scripts/kind-down.sh clustermesh1 clustermesh2
.PHONY: kind-clustermesh-ready
kind-clustermesh-ready: ## Check if both kind clustermesh clusters exist
@$(ECHO_CHECK) clustermesh kind is ready...
@kind get clusters 2>&1 | grep "clustermesh1" \
&& exit 0 || exit 1
@kind get clusters 2>&1 | grep "clustermesh2" \
&& exit 0 || exit 1
.PHONY: kind-bgp-v4
kind-bgp-v4:
$(QUIET) $(MAKE) -C contrib/containerlab/bgp-cplane-dev-v4 deploy
.PHONY: kind-bgp-v4-down
kind-bgp-v4-down:
$(QUIET) $(MAKE) -C contrib/containerlab/bgp-cplane-dev-v4 destroy
.PHONY: kind-bgp-v4-apply-policy
kind-bgp-v4-apply-policy:
$(QUIET) $(MAKE) -C contrib/containerlab/bgp-cplane-dev-v4 apply-policy
.PHONY: kind-bgp-v6
kind-bgp-v6:
$(QUIET) $(MAKE) -C contrib/containerlab/bgp-cplane-dev-v6 deploy
.PHONY: kind-bgp-v6-down
kind-bgp-v6-down:
$(QUIET) $(MAKE) -C contrib/containerlab/bgp-cplane-dev-v6 destroy
.PHONY: kind-bgp-v6-apply-policy
kind-bgp-v6-apply-policy:
$(QUIET) $(MAKE) -C contrib/containerlab/bgp-cplane-dev-v6 apply-policy
.PHONY: kind-bgp-dual
kind-bgp-dual:
$(QUIET) $(MAKE) -C contrib/containerlab/bgp-cplane-dev-dual deploy
.PHONY: kind-bgp-dual-down
kind-bgp-dual-down:
$(QUIET) $(MAKE) -C contrib/containerlab/bgp-cplane-dev-dual destroy
.PHONY: kind-bgp-dual-apply-policy
kind-bgp-dual-apply-policy:
$(QUIET) $(MAKE) -C contrib/containerlab/bgp-cplane-dev-dual apply-policy
# Template for kind environment for a target. Parameters are:
# $(1) Makefile target name
define KIND_ENV
.PHONY: $(1)
$(1): export DOCKER_REGISTRY=localhost:5000
$(1): export LOCAL_AGENT_IMAGE=$$(DOCKER_REGISTRY)/$$(DOCKER_DEV_ACCOUNT)/cilium-dev:$$(LOCAL_IMAGE_TAG)
$(1): export LOCAL_OPERATOR_IMAGE=$$(DOCKER_REGISTRY)/$$(DOCKER_DEV_ACCOUNT)/operator-generic:$$(LOCAL_IMAGE_TAG)
$(1): export LOCAL_CLUSTERMESH_IMAGE=$$(DOCKER_REGISTRY)/$$(DOCKER_DEV_ACCOUNT)/clustermesh-apiserver:$$(LOCAL_IMAGE_TAG)
endef
$(eval $(call KIND_ENV,kind-clustermesh-images))
kind-clustermesh-images: kind-clustermesh-ready kind-build-clustermesh-apiserver kind-build-image-agent kind-build-image-operator ## Builds images and imports them into clustermesh clusters
$(QUIET)kind load docker-image $(LOCAL_CLUSTERMESH_IMAGE) --name clustermesh1
$(QUIET)kind load docker-image $(LOCAL_CLUSTERMESH_IMAGE) --name clustermesh2
$(QUIET)kind load docker-image $(LOCAL_AGENT_IMAGE) --name clustermesh1
$(QUIET)kind load docker-image $(LOCAL_AGENT_IMAGE) --name clustermesh2
$(QUIET)kind load docker-image $(LOCAL_OPERATOR_IMAGE) --name clustermesh1
$(QUIET)kind load docker-image $(LOCAL_OPERATOR_IMAGE) --name clustermesh2
.PHONY: kind-connect-clustermesh ## Connect the ClusterMesh clusters.
kind-connect-clustermesh: check_deps kind-clustermesh-ready
@echo " CONNECT the two clusters"
$(CILIUM_CLI) clustermesh connect --context kind-clustermesh1 --destination-context kind-clustermesh2
$(CILIUM_CLI) clustermesh status --context kind-clustermesh1 --wait
$(CILIUM_CLI) clustermesh status --context kind-clustermesh2 --wait
ENABLE_KVSTOREMESH ?= true
$(eval $(call KIND_ENV,kind-install-cilium-clustermesh))
kind-install-cilium-clustermesh: check_deps kind-clustermesh-ready ## Install a local Cilium version into the clustermesh clusters and enable clustermesh.
@echo " INSTALL cilium on clustermesh1 cluster"
-$(CILIUM_CLI) --context=kind-clustermesh1 uninstall >/dev/null
$(CILIUM_CLI) --context=kind-clustermesh1 install \
--chart-directory=$(ROOT_DIR)/install/kubernetes/cilium \
--values=$(ROOT_DIR)/contrib/testing/kind-clustermesh1.yaml \
--set=image.override=$(LOCAL_AGENT_IMAGE) \
--set=operator.image.override=$(LOCAL_OPERATOR_IMAGE) \
--set=clustermesh.apiserver.image.override=$(LOCAL_CLUSTERMESH_IMAGE) \
--set=clustermesh.apiserver.kvstoremesh.enabled=$(ENABLE_KVSTOREMESH)
@echo " INSTALL cilium on clustermesh2 cluster"
-$(CILIUM_CLI) --context=kind-clustermesh2 uninstall >/dev/null
$(KUBECTL) --context=kind-clustermesh1 get secret -n kube-system cilium-ca -o yaml | \
$(KUBECTL) --context=kind-clustermesh2 replace --force -f -
$(CILIUM_CLI) --context=kind-clustermesh2 install \
--chart-directory=$(ROOT_DIR)/install/kubernetes/cilium \
--values=$(ROOT_DIR)/contrib/testing/kind-clustermesh2.yaml \
--set=image.override=$(LOCAL_AGENT_IMAGE) \
--set=operator.image.override=$(LOCAL_OPERATOR_IMAGE) \
--set=clustermesh.apiserver.image.override=$(LOCAL_CLUSTERMESH_IMAGE) \
--set=clustermesh.apiserver.kvstoremesh.enabled=$(ENABLE_KVSTOREMESH)
$(MAKE) kind-connect-clustermesh
.PHONY: kind-install-cilium-clustermesh-fast
kind-install-cilium-clustermesh-fast: check_deps kind-clustermesh-ready ## "Fast" Install a local Cilium version using volume-mounted binaries into the ClusterMesh clusters and enable ClusterMesh.
@echo " INSTALL cilium on clustermesh1 cluster"
docker pull quay.io/cilium/cilium-ci:latest
kind load docker-image --name clustermesh1 quay.io/cilium/cilium-ci:latest
-$(CILIUM_CLI) --context=kind-clustermesh1 uninstall >/dev/null
$(CILIUM_CLI) --context=kind-clustermesh1 install \
--chart-directory=$(ROOT_DIR)/install/kubernetes/cilium \
--values=$(ROOT_DIR)/contrib/testing/kind-clustermesh1.yaml \
--values=$(ROOT_DIR)/contrib/testing/kind-fast.yaml \
--set=clustermesh.apiserver.kvstoremesh.enabled=$(ENABLE_KVSTOREMESH)
@echo " INSTALL cilium on clustermesh2 cluster"
kind load docker-image --name clustermesh2 quay.io/cilium/cilium-ci:latest
-$(CILIUM_CLI) --context=kind-clustermesh2 uninstall >/dev/null
$(KUBECTL) --context=kind-clustermesh1 get secret -n kube-system cilium-ca -o yaml | \
$(KUBECTL) --context=kind-clustermesh2 replace --force -f -
$(CILIUM_CLI) --context=kind-clustermesh2 install \
--chart-directory=$(ROOT_DIR)/install/kubernetes/cilium \
--values=$(ROOT_DIR)/contrib/testing/kind-clustermesh2.yaml \
--values=$(ROOT_DIR)/contrib/testing/kind-fast.yaml \
--set=clustermesh.apiserver.kvstoremesh.enabled=$(ENABLE_KVSTOREMESH)
$(MAKE) kind-image-fast
$(MAKE) kind-connect-clustermesh
KIND_CLUSTER_NAME ?= $(shell kind get clusters -q | head -n1)
.PHONY: kind-ready
kind-ready:
@$(ECHO_CHECK) kind-ready
@if [ -n "$(shell kind get clusters -q)" ]; then echo "kind is ready"; else echo "kind not ready"; exit 1; fi
$(eval $(call KIND_ENV,kind-build-image-agent))
kind-build-image-agent: ## Build cilium-dev docker image
$(QUIET)$(MAKE) dev-docker-image$(DEBUGGER_SUFFIX) DOCKER_IMAGE_TAG=$(LOCAL_IMAGE_TAG)
$(eval $(call KIND_ENV,kind-image-agent))
kind-image-agent: .SHELLFLAGS=-c
kind-image-agent: kind-ready kind-build-image-agent ## Build cilium-dev docker image and import it into kind.
$(QUIET)kind load docker-image $(LOCAL_AGENT_IMAGE) -n $(KIND_CLUSTER_NAME); \
[ $$? -eq 0 ] || $(QUIET)kind load docker-image $(LOCAL_AGENT_IMAGE) -n $(KIND_CLUSTER_NAME)
$(eval $(call KIND_ENV,kind-build-image-operator))
kind-build-image-operator: ## Build cilium-operator-dev docker image
$(QUIET)$(MAKE) dev-docker-operator-generic-image$(DEBUGGER_SUFFIX) DOCKER_IMAGE_TAG=$(LOCAL_IMAGE_TAG)
$(eval $(call KIND_ENV,kind-image-operator))
kind-image-operator: .SHELLFLAGS=-c
kind-image-operator: kind-ready kind-build-image-operator ## Build cilium-operator-dev docker image and import it into kind.
$(QUIET)kind load docker-image $(LOCAL_OPERATOR_IMAGE) -n $(KIND_CLUSTER_NAME); \
[ $$? -eq 0 ] || $(QUIET)kind load docker-image $(LOCAL_OPERATOR_IMAGE) -n $(KIND_CLUSTER_NAME)
$(eval $(call KIND_ENV,kind-build-clustermesh-apiserver))
kind-build-clustermesh-apiserver: ## Build cilium-clustermesh-apiserver docker image
$(QUIET)$(MAKE) docker-clustermesh-apiserver-image DOCKER_IMAGE_TAG=$(LOCAL_IMAGE_TAG)
.PHONY: kind-image
kind-image: ## Build cilium and operator images and import them into kind.
$(MAKE) kind-image-agent
$(MAKE) kind-image-operator
define KIND_VALUES_FAST_FILES
--helm-values=$(ROOT_DIR)/contrib/testing/kind-common.yaml \
--helm-values=$(ROOT_DIR)/contrib/testing/kind-fast.yaml
endef
ifneq ("$(wildcard $(ROOT_DIR)/contrib/testing/kind-custom.yaml)","")
KIND_VALUES_FAST_FILES := $(KIND_VALUES_FAST_FILES) --helm-values=$(ROOT_DIR)/contrib/testing/kind-custom.yaml
endif
ifdef ADDITIONAL_KIND_VALUES_FILE
KIND_VALUES_FAST_FILES := $(KIND_VALUES_FAST_FILES) --helm-values=$(ROOT_DIR)/$(ADDITIONAL_KIND_VALUES_FILE)
endif
.PHONY: kind-install-cilium-fast
kind-install-cilium-fast: .SHELLFLAGS=-c
kind-install-cilium-fast: check_deps kind-ready ## "Fast" Install a local Cilium version using volume-mounted binaries into all clusters.
@echo " INSTALL cilium"
docker pull quay.io/cilium/cilium-ci:latest
for cluster_name in $${KIND_CLUSTERS:-$(shell kind get clusters)}; do \
kind load docker-image --name $$cluster_name quay.io/cilium/cilium-ci:latest; \
[ $$? -eq 0 ] || kind load docker-image --name $$cluster_name quay.io/cilium/cilium-ci:latest; \
$(CILIUM_CLI) --context=kind-$$cluster_name uninstall >/dev/null 2>&1 || true; \
$(CILIUM_CLI) install --context=kind-$$cluster_name \
--chart-directory=$(ROOT_DIR)/install/kubernetes/cilium \
$(KIND_VALUES_FAST_FILES) \
--version= >/dev/null 2>&1 & \
done
.PHONY: build-cli
build-cli: ## Build cilium cli binary
$(QUIET)$(MAKE) -C cilium-dbg GOOS=linux
.PHONY: build-agent
build-agent: ## Build cilium daemon binary
$(QUIET)$(MAKE) -C daemon GOOS=linux
.PHONY: build-operator
build-operator: ## Build cilium operator binary
$(QUIET)$(MAKE) -C operator cilium-operator-generic GOOS=linux
.PHONY: build-clustermesh-apiserver
build-clustermesh-apiserver: ## Build cilium clustermesh-apiserver binary
$(QUIET)$(MAKE) -C clustermesh-apiserver GOOS=linux
.PHONY: build-hubble-cli
build-hubble-cli: ## Build hubble cli binary
$(QUIET)$(MAKE) -C hubble GOOS=linux
.PHONY: kind-image-fast-agent
kind-image-fast-agent: kind-ready build-cli build-agent build-hubble-cli ## Build cilium cli, daemon binaries, and hubble cli. Copy the bins and bpf files to kind nodes.
$(eval dst:=/cilium-binaries)
for cluster_name in $${KIND_CLUSTERS:-$(shell kind get clusters)}; do \
for node_name in $$(kind get nodes -n "$$cluster_name"); do \
docker exec $${node_name} mkdir -p "${dst}"; \
\
docker exec $${node_name} rm -rf "${dst}/var/lib/cilium"; \
docker exec $${node_name} mkdir -p "${dst}/var/lib/cilium"; \
docker cp "./bpf/" $${node_name}:"${dst}/var/lib/cilium/bpf"; \
docker exec $${node_name} find "${dst}/var/lib/cilium/bpf" -type f -exec chmod 0644 {} + ;\
\
docker exec $${node_name} rm -f "${dst}/cilium-dbg"; \
docker cp "./cilium-dbg/cilium-dbg" $${node_name}:"${dst}"; \
docker exec $${node_name} chmod +x "${dst}/cilium-dbg"; \
\
docker exec $${node_name} rm -f "${dst}/cilium-agent"; \
docker cp "./daemon/cilium-agent" $${node_name}:"${dst}"; \
docker exec $${node_name} chmod +x "${dst}/cilium-agent"; \
\
docker exec $${node_name} rm -f "${dst}/hubble"; \
docker cp "./hubble/hubble" $${node_name}:"${dst}"; \
docker exec $${node_name} chmod +x "${dst}/hubble"; \
done; \
kubectl --context=kind-$${cluster_name} delete pods -n kube-system -l k8s-app=cilium --force; \
done
.PHONY: kind-image-fast-operator
kind-image-fast-operator: kind-ready build-operator ## Build cilium operator binary and copy it to all kind nodes.
$(eval dst:=/cilium-binaries)
for cluster_name in $${KIND_CLUSTERS:-$(shell kind get clusters)}; do \
for node_name in $$(kind get nodes -n "$$cluster_name"); do \
docker exec $${node_name} mkdir -p "${dst}"; \
\
docker exec $${node_name} rm -f "${dst}/cilium-operator-generic"; \
docker cp "./operator/cilium-operator-generic" $${node_name}:"${dst}"; \
docker exec $${node_name} chmod +x "${dst}/cilium-operator-generic"; \
done; \
kubectl --context=kind-$${cluster_name} delete pods -n kube-system -l name=cilium-operator --force; \
done
.PHONY: kind-image-fast-clustermesh-apiserver
kind-image-fast-clustermesh-apiserver: kind-ready build-clustermesh-apiserver ## Build clustermesh-apiserver binary and copy it to all kind nodes.
$(eval dst:=/cilium-binaries)
for cluster_name in $${KIND_CLUSTERS:-$(shell kind get clusters)}; do \
for node_name in $$(kind get nodes -n "$$cluster_name"); do \
docker exec $${node_name} mkdir -p "${dst}"; \
\
docker exec $${node_name} rm -f "${dst}/clustermesh-apiserver"; \
docker cp "./clustermesh-apiserver/clustermesh-apiserver" $${node_name}:"${dst}"; \
docker exec $${node_name} chmod +x "${dst}/clustermesh-apiserver"; \
done; \
kubectl --context=kind-$${cluster_name} delete pods -n kube-system -l k8s-app=clustermesh-apiserver --force; \
done
.PHONY: kind-image-fast
kind-image-fast: kind-image-fast-agent kind-image-fast-operator kind-image-fast-clustermesh-apiserver ## Build all binaries and copy them to kind nodes.
define KIND_VALUES_FILES
--helm-values=$(ROOT_DIR)/contrib/testing/kind-common.yaml \
--helm-values=$(ROOT_DIR)/contrib/testing/kind-values.yaml
endef
ifdef ADDITIONAL_KIND_VALUES_FILE
KIND_VALUES_FILES := $(KIND_VALUES_FILES) --helm-values=$(ROOT_DIR)/$(ADDITIONAL_KIND_VALUES_FILE)
endif
ifneq ("$(wildcard $(ROOT_DIR)/contrib/testing/kind-custom.yaml)","")
KIND_VALUES_FILES := $(KIND_VALUES_FILES) --helm-values=$(ROOT_DIR)/contrib/testing/kind-custom.yaml
endif
.PHONY: kind-install-cilium
kind-install-cilium: check_deps kind-ready ## Install a local Cilium version into the cluster.
@echo " INSTALL cilium"
# cilium-cli doesn't support idempotent installs, so we uninstall and
# reinstall here. https://github.com/cilium/cilium-cli/issues/205
-@$(CILIUM_CLI) uninstall >/dev/null 2>&1 || true
# cilium-cli's --wait flag doesn't work, so we just force it to run
# in the background instead and wait for the resources to be available.
# https://github.com/cilium/cilium-cli/issues/1070
$(CILIUM_CLI) install \
--chart-directory=$(ROOT_DIR)/install/kubernetes/cilium \
$(KIND_VALUES_FILES) \
--version= \
>/dev/null 2>&1 &
GW_VERSION ?= $(shell grep "sigs.k8s.io/gateway-api" go.mod | awk '{print $$2}' | awk -F'-' '{print (NF>2)?$$NF:$$0}')
KIND_NET_CIDR ?= $(shell docker network inspect kind-cilium -f '{{json .IPAM.Config}}' | jq -r '.[] | select(.Subnet | test("^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+")) | .Subnet')
LB_CIDR ?= $(shell echo $(KIND_NET_CIDR) | sed "s@0.0/16@255.200\/28@" | sed -e 's/[\/&]/\\&/g')
.PHONY: kind-servicemesh-install-cilium
kind-servicemesh-install-cilium: check_deps kind-ready ## Install a local Cilium version into the cluster.
@echo " INSTALL cilium"
# cilium-cli doesn't support idempotent installs, so we uninstall and
# reinstall here. https://github.com/cilium/cilium-cli/issues/205
-@$(CILIUM_CLI) uninstall >/dev/null 2>&1 || true
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/$(GW_VERSION)/config/crd/standard/gateway.networking.k8s.io_gatewayclasses.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/$(GW_VERSION)/config/crd/standard/gateway.networking.k8s.io_gateways.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/$(GW_VERSION)/config/crd/standard/gateway.networking.k8s.io_httproutes.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/$(GW_VERSION)/config/crd/standard/gateway.networking.k8s.io_referencegrants.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/$(GW_VERSION)/config/crd/standard/gateway.networking.k8s.io_grpcroutes.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/$(GW_VERSION)/config/crd/experimental/gateway.networking.k8s.io_tlsroutes.yaml
$(CILIUM_CLI) install \
--chart-directory=$(ROOT_DIR)/install/kubernetes/cilium \
$(KIND_VALUES_FILES) \
--helm-values=$(ROOT_DIR)/contrib/testing/kind-servicemesh.yaml \
--version= \
>/dev/null 2>&1 &
$(CILIUM_CLI) status --wait --wait-duration 30s
@echo "KIND_NET_CIDR: $(KIND_NET_CIDR)"
@echo "LB_CIDR: $(LB_CIDR)"
@echo "Deploying LB-IPAM Pool..."
sed -e "s/LB_CIDR/$(LB_CIDR)/g" $(ROOT_DIR)/contrib/testing/servicemesh/ippool.yaml | kubectl apply -f -
@echo "Deploying L2-Announcement Policy..."
kubectl apply -f $(ROOT_DIR)/contrib/testing/servicemesh/l2policy.yaml
.PHONY: kind-egressgw-install-cilium
kind-egressgw-install-cilium: check_deps kind-ready ## Install a local Cilium version into the cluster.
@echo " INSTALL cilium"
# cilium-cli doesn't support idempotent installs, so we uninstall and
# reinstall here. https://github.com/cilium/cilium-cli/issues/205
-@$(CILIUM_CLI) uninstall >/dev/null 2>&1 || true
# cilium-cli's --wait flag doesn't work, so we just force it to run
# in the background instead and wait for the resources to be available.
# https://github.com/cilium/cilium-cli/issues/1070
$(CILIUM_CLI) install \
--chart-directory=$(ROOT_DIR)/install/kubernetes/cilium \
$(KIND_VALUES_FILES) \
--helm-values=$(ROOT_DIR)/contrib/testing/kind-egressgw-values.yaml \
--nodes-without-cilium \
--version= \
>/dev/null 2>&1 &
KVSTORE_POD_NAME ?= "kvstore"
KVSTORE_POD_PORT ?= "2378"
.PHONY: kind-kvstore-install-cilium
kind-kvstore-install-cilium: check_deps kind-ready kind-kvstore-start ## Install a local Cilium version into the cluster, configured in kvstore mode.
$(MAKE) kind-install-cilium KIND_VALUES_FILES="\
$(KIND_VALUES_FILES) \
--set etcd.enabled=true \
--set etcd.endpoints[0]=http://$(shell kubectl --namespace kube-system get pod $(KVSTORE_POD_NAME) -o jsonpath='{.status.hostIP}'):$(KVSTORE_POD_PORT) \
--set identityAllocationMode=kvstore \
"
.PHONY: kind-kvstore-start
kind-kvstore-start: ## Start an etcd pod serving as Cilium's kvstore
kubectl --namespace kube-system get pod $(KVSTORE_POD_NAME) >/dev/null 2>/dev/null || \
kubectl --namespace kube-system run $(KVSTORE_POD_NAME) --image $(ETCD_IMAGE) \
--overrides='{ "apiVersion": "v1", "spec": { "hostNetwork": true, "nodeSelector": {"node-role.kubernetes.io/control-plane": ""}, "tolerations": [{ "operator": "Exists" }] }}' \
-- etcd --listen-client-urls=http://0.0.0.0:$(KVSTORE_POD_PORT) --advertise-client-urls=http://0.0.0.0:$(KVSTORE_POD_PORT)
kubectl --namespace kube-system wait --for=condition=Ready pod/$(KVSTORE_POD_NAME)
.PHONY: kind-kvstore-stop
kind-kvstore-stop: ## Stop the etcd pod serving as Cilium's kvstore
kubectl --namespace kube-system delete pod $(KVSTORE_POD_NAME) --ignore-not-found
kubectl --namespace kube-system wait --for=delete pod/$(KVSTORE_POD_NAME)
.PHONY: kind-uninstall-cilium
kind-uninstall-cilium: check_deps ## Uninstall Cilium from the cluster.
@echo " UNINSTALL cilium"
-$(CILIUM_CLI) uninstall
.PHONY: kind-check-cilium
kind-check-cilium: check_deps
@echo " CHECK cilium is ready..."
$(CILIUM_CLI) status --wait --wait-duration 1s >/dev/null 2>/dev/null
# Template for kind debug targets. Parameters are:
# $(1) agent target
define DEBUG_KIND_TEMPLATE
.PHONY: kind-image$(1)-debug
kind-image$(1)-debug: export DEBUGGER_SUFFIX=-debug
kind-image$(1)-debug: export NOSTRIP=1
kind-image$(1)-debug: export NOOPT=1
kind-image$(1)-debug: ## Build cilium$(1) docker image with a dlv debugger wrapper and import it into kind.
$(MAKE) kind-image$(1)
endef
# kind-image-agent-debug
$(eval $(call DEBUG_KIND_TEMPLATE,-agent))
# kind-image-operator-debug
$(eval $(call DEBUG_KIND_TEMPLATE,-operator))
$(eval $(call KIND_ENV,kind-debug-agent))
kind-debug-agent: ## Create a local kind development environment with cilium-agent attached to a debugger.
$(QUIET)$(MAKE) kind-ready 2>/dev/null \
|| $(MAKE) kind
$(MAKE) kind-image-agent-debug
# Not debugging cilium-operator here; any image is good enough.
kind load docker-image $(LOCAL_OPERATOR_IMAGE) \
|| $(MAKE) kind-image-operator
$(MAKE) kind-check-cilium 2>/dev/null \
|| $(MAKE) kind-install-cilium
@echo "Attach delve to localhost on these ports to continue:"
@echo " - 23401: cilium-agent (kind-control-plane)"
@echo " - 23411: cilium-agent (kind-worker)"
$(eval $(call KIND_ENV,kind-debug))
kind-debug: ## Create a local kind development environment with cilium-agent & cilium-operator attached to a debugger.
$(QUIET)$(MAKE) kind-ready 2>/dev/null \
|| $(MAKE) kind
$(MAKE) kind-image-agent-debug
$(MAKE) kind-image-operator-debug
$(MAKE) kind-check-cilium 2>/dev/null \
|| $(MAKE) kind-install-cilium
@echo "Attach delve to localhost on these ports to continue:"
@echo " - 23401: cilium-agent (kind-control-plane)"
@echo " - 23411: cilium-agent (kind-worker)"
@echo " - 23511: cilium-operator (kind-worker)"