forked from open-telemetry/opentelemetry-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
967 lines (817 loc) · 42 KB
/
Makefile
File metadata and controls
967 lines (817 loc) · 42 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
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
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
# Current Operator version
VERSION ?= $(shell git describe --tags | sed 's/^v//')
VERSION_DATE ?= $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
VERSION_PKG ?= github.com/open-telemetry/opentelemetry-operator/internal/version
OTELCOL_VERSION ?= "$(shell awk -F= '/^opentelemetry-collector=/ {print $$2}' versions.txt)"
OPERATOR_VERSION ?= "$(shell awk -F= '/^operator=/ {print $$2}' versions.txt)"
TARGETALLOCATOR_VERSION ?= $(shell awk -F= '/^targetallocator=/ {print $$2}' versions.txt)
OPERATOR_OPAMP_BRIDGE_VERSION ?= "$(shell awk -F= '/^operator-opamp-bridge/ {print $$2}' versions.txt)"
DEFAULT_INSTRUMENTATION_JAVA_VERSION ?= "$(shell awk -F= '/^autoinstrumentation-java=/ {print $$2}' versions.txt)"
DEFAULT_INSTRUMENTATION_NODEJS_VERSION ?= "$(shell awk -F= '/^autoinstrumentation-nodejs=/ {print $$2}' versions.txt)"
DEFAULT_INSTRUMENTATION_PYTHON_VERSION ?= "$(shell awk -F= '/^autoinstrumentation-python=/ {print $$2}' versions.txt)"
DEFAULT_INSTRUMENTATION_DOTNET_VERSION ?= "$(shell awk -F= '/^autoinstrumentation-dotnet=/ {print $$2}' versions.txt)"
DEFAULT_INSTRUMENTATION_GO_VERSION ?= "$(shell awk -F= '/^autoinstrumentation-go=/ {print $$2}' versions.txt)"
DEFAULT_INSTRUMENTATION_APACHE_HTTPD_VERSION ?= "$(shell awk -F= '/^autoinstrumentation-apache-httpd=/ {print $$2}' versions.txt)"
DEFAULT_INSTRUMENTATION_NGINX_VERSION ?= "$(shell awk -F= '/^autoinstrumentation-nginx=/ {print $$2}' versions.txt)"
# Actual versions used for publishing instrumentation images
INSTRUMENTATION_JAVA_VERSION ?= "$(shell cat autoinstrumentation/java/version.txt)"
INSTRUMENTATION_NODEJS_VERSION ?= "$(shell grep -o '"@opentelemetry/auto-instrumentations-node": "[^"]*' autoinstrumentation/nodejs/package.json | cut -d'"' -f4)"
INSTRUMENTATION_PYTHON_VERSION ?= "$(shell grep -o '^opentelemetry-instrumentation==[^ ]*' autoinstrumentation/python/requirements.txt | cut -d'=' -f3)"
INSTRUMENTATION_DOTNET_VERSION ?= "$(shell cat autoinstrumentation/dotnet/version.txt)"
INSTRUMENTATION_APACHE_HTTPD_VERSION ?= "$(shell cat autoinstrumentation/apache-httpd/version.txt)"
COMMON_LDFLAGS ?= -s -w
OPERATOR_LDFLAGS ?= -X ${VERSION_PKG}.version=${VERSION}\
-X ${VERSION_PKG}.buildDate=${VERSION_DATE}\
-X ${VERSION_PKG}.otelCol=${OTELCOL_VERSION}\
-X ${VERSION_PKG}.targetAllocator=${TARGETALLOCATOR_VERSION}\
-X ${VERSION_PKG}.operatorOpAMPBridge=${OPERATOR_OPAMP_BRIDGE_VERSION}\
-X ${VERSION_PKG}.autoInstrumentationJava=${DEFAULT_INSTRUMENTATION_JAVA_VERSION}\
-X ${VERSION_PKG}.autoInstrumentationNodeJS=${DEFAULT_INSTRUMENTATION_NODEJS_VERSION}\
-X ${VERSION_PKG}.autoInstrumentationPython=${DEFAULT_INSTRUMENTATION_PYTHON_VERSION}\
-X ${VERSION_PKG}.autoInstrumentationDotNet=${DEFAULT_INSTRUMENTATION_DOTNET_VERSION}\
-X ${VERSION_PKG}.autoInstrumentationGo=${DEFAULT_INSTRUMENTATION_GO_VERSION}\
-X ${VERSION_PKG}.autoInstrumentationApacheHttpd=${DEFAULT_INSTRUMENTATION_APACHE_HTTPD_VERSION}\
-X ${VERSION_PKG}.autoInstrumentationNginx=${DEFAULT_INSTRUMENTATION_NGINX_VERSION}
ARCH ?= $(shell go env GOARCH)
ifeq ($(shell uname), Darwin)
SED_INPLACE := sed -i ''
else
SED_INPLACE := sed -i
endif
# Image URL to use all building/pushing image targets
DOCKER_USER ?= open-telemetry
IMG_PREFIX ?= ghcr.io/${DOCKER_USER}/opentelemetry-operator
IMG_REPO ?= opentelemetry-operator
IMG ?= ${IMG_PREFIX}/${IMG_REPO}:${VERSION}
BUNDLE_IMG ?= ${IMG_PREFIX}/${IMG_REPO}-bundle:${VERSION}
TARGETALLOCATOR_IMG_REPO ?= target-allocator
TARGETALLOCATOR_IMG ?= ${IMG_PREFIX}/${TARGETALLOCATOR_IMG_REPO}:$(addprefix v,${VERSION})
OPERATOROPAMPBRIDGE_IMG_REPO ?= operator-opamp-bridge
OPERATOROPAMPBRIDGE_IMG ?= ${IMG_PREFIX}/${OPERATOROPAMPBRIDGE_IMG_REPO}:$(addprefix v,${VERSION})
BRIDGETESTSERVER_IMG_REPO ?= e2e-test-app-bridge-server
BRIDGETESTSERVER_IMG ?= ${IMG_PREFIX}/${BRIDGETESTSERVER_IMG_REPO}:ve2e
INSTRUMENTATION_JAVA_IMG_REPO ?= autoinstrumentation-java
INSTRUMENTATION_JAVA_IMG ?= ${IMG_PREFIX}/${INSTRUMENTATION_JAVA_IMG_REPO}:${INSTRUMENTATION_JAVA_VERSION}
INSTRUMENTATION_NODEJS_IMG_REPO ?= autoinstrumentation-nodejs
INSTRUMENTATION_NODEJS_IMG ?= ${IMG_PREFIX}/${INSTRUMENTATION_NODEJS_IMG_REPO}:${INSTRUMENTATION_NODEJS_VERSION}
INSTRUMENTATION_PYTHON_IMG_REPO ?= autoinstrumentation-python
INSTRUMENTATION_PYTHON_IMG ?= ${IMG_PREFIX}/${INSTRUMENTATION_PYTHON_IMG_REPO}:${INSTRUMENTATION_PYTHON_VERSION}
INSTRUMENTATION_DOTNET_IMG_REPO ?= autoinstrumentation-dotnet
INSTRUMENTATION_DOTNET_IMG ?= ${IMG_PREFIX}/${INSTRUMENTATION_DOTNET_IMG_REPO}:${INSTRUMENTATION_DOTNET_VERSION}
INSTRUMENTATION_APACHE_HTTPD_IMG_REPO ?= autoinstrumentation-apache-httpd
INSTRUMENTATION_APACHE_HTTPD_IMG ?= ${IMG_PREFIX}/${INSTRUMENTATION_APACHE_HTTPD_IMG_REPO}:${INSTRUMENTATION_APACHE_HTTPD_VERSION}
MUSTGATHER_IMG ?= ${IMG_PREFIX}/must-gather
# 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
# by default, do not run the manager with webhooks enabled. This only affects local runs, not the build or in-cluster deployments.
ENABLE_WEBHOOKS ?= false
# Additional flags for go test command
GOTEST_EXTRA_OPTS ?=
# If we are running in CI, run go test in verbose mode
ifeq (,$(CI))
GOTEST_OPTS=-race $(if $(GOTEST_EXTRA_OPTS),$(GOTEST_EXTRA_OPTS))
else
GOTEST_OPTS=-race -v $(if $(GOTEST_EXTRA_OPTS),$(GOTEST_EXTRA_OPTS))
endif
START_KIND_CLUSTER ?= true
KUBE_VERSION ?= 1.35
KIND_CONFIG ?= kind-$(KUBE_VERSION).yaml
KIND_CLUSTER_NAME ?= "otel-operator"
CHAINSAW_SELECTOR := $(shell [ "$(shell printf '%s\n' "$(KUBE_VERSION)" "1.29" | sort -V | head -n1)" = "1.29" ] && echo "--selector sidecar=native" || echo "--selector sidecar=legacy")
OPERATOR_SDK_VERSION ?= 1.29.0
CERTMANAGER_VERSION ?= 1.10.0
ifndef ignore-not-found
ignore-not-found = false
endif
## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)
# CHANNELS define the bundle channels used in the bundle.
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")
# To re-generate a bundle for other specific channels without changing the standard setup, you can:
# - use the CHANNELS as arg of the bundle target (e.g make bundle CHANNELS=candidate,fast,stable)
# - use environment variables to overwrite this value (e.g export CHANNELS="candidate,fast,stable")
ifneq ($(origin CHANNELS), undefined)
BUNDLE_CHANNELS := --channels=$(CHANNELS)
endif
# DEFAULT_CHANNEL defines the default channel used in the bundle.
# Add a new line here if you would like to change its default config. (E.g DEFAULT_CHANNEL = "stable")
# To re-generate a bundle for any other default channel without changing the default setup, you can:
# - use the DEFAULT_CHANNEL as arg of the bundle target (e.g make bundle DEFAULT_CHANNEL=stable)
# - use environment variables to overwrite this value (e.g export DEFAULT_CHANNEL="stable")
ifneq ($(origin DEFAULT_CHANNEL), undefined)
BUNDLE_DEFAULT_CHANNEL := --default-channel=$(DEFAULT_CHANNEL)
endif
BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
# BUNDLE_GEN_FLAGS are the flags passed to the operator-sdk generate bundle command
BUNDLE_GEN_FLAGS ?= -q --overwrite --version $(OPERATOR_VERSION) $(BUNDLE_METADATA_OPTS)
# USE_IMAGE_DIGESTS defines if images are resolved via tags or digests
# You can enable this value if you would like to use SHA Based Digests
# To enable set flag to true
USE_IMAGE_DIGESTS ?= false
ifeq ($(USE_IMAGE_DIGESTS), true)
BUNDLE_GEN_FLAGS += --use-image-digests
endif
MANIFEST_DIR ?= config/crd/bases
# kubectl apply does not work on large CRDs.
CRD_OPTIONS ?= "crd:generateEmbeddedObjectMeta=true,maxDescLen=0"
# Choose which version to generate
BUNDLE_VARIANT ?= community
BUNDLE_DIR = ./bundle/$(BUNDLE_VARIANT)
MANIFESTS_DIR = config/manifests/$(BUNDLE_VARIANT)
BUNDLE_BUILD_GEN_FLAGS ?= $(BUNDLE_GEN_FLAGS) --output-dir . --kustomize-dir ../../$(MANIFESTS_DIR)
MIN_KUBERNETES_VERSION ?= 1.25.0
MIN_OPENSHIFT_VERSION ?= 4.14
## On MacOS, use gsed instead of sed, to make sed behavior
## consistent with Linux.
SED ?= $(shell which gsed 2>/dev/null || which sed)
.DEFAULT_GOAL := help
# Show this help message
.PHONY: help
help:
@echo -e "\033[1;3;34mOpenTelemetry Operator.\033[0m\n"
@echo 'Usage: make [target]'
@echo ''
@echo 'Targets:'
@awk '\
BEGIN { desc="" } \
/^##@/ { \
printf "\n\033[1m%s\033[0m\n", substr($$0, 5); \
next \
} \
/^# / { \
desc = substr($$0, 3); \
next \
} \
/^[a-zA-Z_0-9\/-]+:/ { \
target = $$1; \
sub(/:.*/, "", target); \
if (!seen[target]++) { \
printf " \033[36m%-40s\033[0m %s\n", target, (desc ? desc : "(no description)"); \
} \
desc = ""; \
} \
' $(MAKEFILE_LIST)
##@ PR
# Verify generated code, manifests, bundles, and API docs are up to date
.PHONY: ensure-update-is-noop
ensure-update-is-noop: VERSION=$(OPERATOR_VERSION)
ensure-update-is-noop: DOCKER_USER=open-telemetry
ensure-update-is-noop: set-image-controller update
@git diff -s --exit-code apis/**/zz_generated.*.go || (echo "Build failed: a model has been changed but the generated resources aren't up to date. Run 'make generate' and update your PR." && exit 1)
@git diff -s --exit-code bundle config || (echo "Build failed: the bundle, config files has been changed but the generated bundle, config files aren't up to date. Run 'make bundle' and update your PR." && git diff && exit 1)
@git diff -s --exit-code docs/api || (echo "Build failed: a model has been changed but the generated docs/api/*.md files aren't up to date. Run 'make api-docs' and update your PR." && git diff && exit 1)
# Build manager binary
.PHONY: all
all: manager targetallocator operator-opamp-bridge
##@ Core Build
# Run full CI pipeline (generate, vet, test, and validation). No lint here, as CI runs it separately
.PHONY: ci
ci: generate fmt vet test ensure-update-is-noop
# Update manifests
.PHONY: update
update: generate manifests bundle api-docs reset
# Build manager binary
.PHONY: manager
manager: generate
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(ARCH) go build -o bin/manager_${ARCH} -trimpath -ldflags "${COMMON_LDFLAGS} ${OPERATOR_LDFLAGS}" main.go
# Build must-gather diagnostic utility
.PHONY: must-gather
must-gather:
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(ARCH) go build -o bin/must-gather_${ARCH} -trimpath -ldflags "${COMMON_LDFLAGS}" ./cmd/gather/main.go
# Build target allocator binary
.PHONY: targetallocator
targetallocator:
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(ARCH) go build -o cmd/otel-allocator/bin/targetallocator_${ARCH} -trimpath -ldflags "${COMMON_LDFLAGS}" ./cmd/otel-allocator
# Build opamp bridge binary
.PHONY: operator-opamp-bridge
operator-opamp-bridge: generate
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(ARCH) go build -o cmd/operator-opamp-bridge/bin/opampbridge_${ARCH} -trimpath -ldflags "${COMMON_LDFLAGS}" ./cmd/operator-opamp-bridge
# Run against the configured Kubernetes cluster in ~/.kube/config
.PHONY: run
run: generate fmt vet manifests
ENABLE_WEBHOOKS=$(ENABLE_WEBHOOKS) go run -ldflags "${OPERATOR_LDFLAGS}" ./main.go --zap-devel
# Install CRDs into a cluster
.PHONY: install
install: manifests kustomize
$(KUSTOMIZE) build config/crd | kubectl apply -f -
# Uninstall CRDs from a cluster
.PHONY: uninstall
uninstall: manifests kustomize
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
##@ Operator Configuration
# Set the controller image parameters
.PHONY: set-image-controller
set-image-controller: manifests kustomize
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
# Add a custom argument to the operator deployment
.PHONY: add-operator-arg
add-operator-arg: PATCH = [{"op":"add","path":"/spec/template/spec/containers/0/args/-","value":"$(OPERATOR_ARG)"}]
add-operator-arg: manifests kustomize
cd config/manager && $(KUSTOMIZE) edit add patch --kind Deployment --patch '$(PATCH)'
# Set the target allocator image used by the operator
.PHONY: add-image-targetallocator
add-image-targetallocator:
@$(MAKE) add-operator-arg OPERATOR_ARG=--target-allocator-image=$(TARGETALLOCATOR_IMG)
# Set the collector image used by the operator
.PHONY: add-image-collector
add-image-collector:
@$(MAKE) add-operator-arg OPERATOR_ARG=--collector-image=$(COLLECTOR_IMG)
# Set auto-instrumentation images for all supported languages
.PHONY: add-image-instrumentation
add-instrumentation-images:
@$(MAKE) add-operator-arg OPERATOR_ARG=--auto-instrumentation-java-image=$(INSTRUMENTATION_JAVA_IMG)
@$(MAKE) add-operator-arg OPERATOR_ARG=--auto-instrumentation-nodejs-image=$(INSTRUMENTATION_NODEJS_IMG)
@$(MAKE) add-operator-arg OPERATOR_ARG=--auto-instrumentation-python-image=$(INSTRUMENTATION_PYTHON_IMG)
@$(MAKE) add-operator-arg OPERATOR_ARG=--auto-instrumentation-dotnet-image=$(INSTRUMENTATION_DOTNET_IMG)
@$(MAKE) add-operator-arg OPERATOR_ARG=--auto-instrumentation-apache-httpd-image=$(INSTRUMENTATION_APACHE_HTTPD_IMG)
# Enable Go auto-instrumentation support in the operator
.PHONY: add-instrumentation-params
add-instrumentation-params:
@$(MAKE) add-operator-arg OPERATOR_ARG=--enable-go-instrumentation=true
# Enable multi-instrumentation support
.PHONY: add-multi-instrumentation-params
add-multi-instrumentation-params:
@$(MAKE) add-operator-arg OPERATOR_ARG=--enable-multi-instrumentation
# Set the OpAMP bridge image used by the operator
.PHONY: add-image-opampbridge
add-image-opampbridge:
@$(MAKE) add-operator-arg OPERATOR_ARG=--operator-opamp-bridge-image=$(OPERATOROPAMPBRIDGE_IMG)
# Add extra RBAC permissions to operator for e2e tests
.PHONY: add-rbac-permissions-to-operator
add-rbac-permissions-to-operator: manifests kustomize
# Kustomize only allows patches in the folder where the kustomization is located
# This folder is ignored by .gitignore
mkdir -p config/rbac/extra-permissions-operator
cp -r tests/e2e-automatic-rbac/extra-permissions-operator/* config/rbac/extra-permissions-operator
cd config/rbac && $(KUSTOMIZE) edit add patch --kind ClusterRole --name manager-role --path extra-permissions-operator/clusterresourcequotas.yaml
cd config/rbac && $(KUSTOMIZE) edit add patch --kind ClusterRole --name manager-role --path extra-permissions-operator/cronjobs.yaml
cd config/rbac && $(KUSTOMIZE) edit add patch --kind ClusterRole --name manager-role --path extra-permissions-operator/daemonsets.yaml
cd config/rbac && $(KUSTOMIZE) edit add patch --kind ClusterRole --name manager-role --path extra-permissions-operator/events.yaml
cd config/rbac && $(KUSTOMIZE) edit add patch --kind ClusterRole --name manager-role --path extra-permissions-operator/extensions.yaml
cd config/rbac && $(KUSTOMIZE) edit add patch --kind ClusterRole --name manager-role --path extra-permissions-operator/namespaces.yaml
cd config/rbac && $(KUSTOMIZE) edit add patch --kind ClusterRole --name manager-role --path extra-permissions-operator/namespaces-status.yaml
cd config/rbac && $(KUSTOMIZE) edit add patch --kind ClusterRole --name manager-role --path extra-permissions-operator/nodes.yaml
cd config/rbac && $(KUSTOMIZE) edit add patch --kind ClusterRole --name manager-role --path extra-permissions-operator/nodes-proxy.yaml
cd config/rbac && $(KUSTOMIZE) edit add patch --kind ClusterRole --name manager-role --path extra-permissions-operator/nodes-spec.yaml
cd config/rbac && $(KUSTOMIZE) edit add patch --kind ClusterRole --name manager-role --path extra-permissions-operator/pod-status.yaml
cd config/rbac && $(KUSTOMIZE) edit add patch --kind ClusterRole --name manager-role --path extra-permissions-operator/rbac.yaml
cd config/rbac && $(KUSTOMIZE) edit add patch --kind ClusterRole --name manager-role --path extra-permissions-operator/replicaset.yaml
cd config/rbac && $(KUSTOMIZE) edit add patch --kind ClusterRole --name manager-role --path extra-permissions-operator/replicationcontrollers.yaml
cd config/rbac && $(KUSTOMIZE) edit add patch --kind ClusterRole --name manager-role --path extra-permissions-operator/resourcequotas.yaml
##@ Deploy
# Deploy controller in the current Kubernetes context, configured in ~/.kube/config
.PHONY: deploy
deploy: set-image-controller
$(KUSTOMIZE) build config/default | kubectl apply -f -
go run hack/check-operator-ready.go 300
# Undeploy controller in the current Kubernetes context, configured in ~/.kube/config
.PHONY: undeploy
undeploy: set-image-controller
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
# Generates the released manifests
.PHONY: release-artifacts
release-artifacts: set-image-controller
mkdir -p dist
$(KUSTOMIZE) build config/default -o dist/opentelemetry-operator.yaml
$(KUSTOMIZE) build config/overlays/openshift -o dist/opentelemetry-operator-openshift.yaml
# Generate manifests e.g. CRD, RBAC etc.
.PHONY: manifests
manifests: controller-gen
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=${MANIFEST_DIR}
# Run tests
# setup-envtest uses KUBEBUILDER_ASSETS which points to a directory with binaries (api-server, etcd and kubectl)
.PHONY: test
test: envtest gotestsum
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(KUBE_VERSION) -p path)" $(GOTESTSUM) -- ${GOTEST_OPTS} ./...
# Run precommit checks (format, vet, lint, test, validation)
.PHONY: precommit
precommit: fmt vet lint test ensure-update-is-noop
##@ Lint and Format
# Run formatters
.PHONY: fmt
fmt: golangci-lint
go fmt ./...
$(GOLANGCI_LINT) run --fix
# Run go vet against code
.PHONY: vet
vet:
go vet ./...
# Run go lint against code
.PHONY: lint
lint: golangci-lint
$(GOLANGCI_LINT) run
# Generate code
.PHONY: generate
generate: controller-gen
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
##@ E2E
# end-to-tests
.PHONY: e2e
e2e: chainsaw
$(CHAINSAW) test --test-dir ./tests/e2e --report-name e2e
# End-to-end tests for sidecar functionality
.PHONY: e2e-sidecar
e2e-sidecar: chainsaw
$(CHAINSAW) test --test-dir ./tests/e2e-sidecar --report-name e2e-sidecar $(CHAINSAW_SELECTOR)
# end-to-end-test for testing automatic RBAC creation
.PHONY: e2e-automatic-rbac
e2e-automatic-rbac: chainsaw
$(CHAINSAW) test --test-dir ./tests/e2e-automatic-rbac --report-name e2e-automatic-rbac
# end-to-end-test for testing autoscale
.PHONY: e2e-autoscale
e2e-autoscale: chainsaw
$(CHAINSAW) test --test-dir ./tests/e2e-autoscale --report-name e2e-autoscale
# instrumentation end-to-tests, alias to make matrix tests more convenient
# the tests are the same, but the setup is different
.PHONY: e2e-instrumentation-default
e2e-instrumentation-default: e2e-instrumentation
# instrumentation end-to-tests
.PHONY: e2e-instrumentation
e2e-instrumentation: chainsaw
$(CHAINSAW) test --test-dir ./tests/e2e-instrumentation --report-name e2e-instrumentation
# Log operator pod information for debugging
.PHONY: e2e-log-operator
e2e-log-operator:
kubectl get pod -n opentelemetry-operator-system | grep "opentelemetry-operator" | awk '{print $$1}' | xargs -I {} kubectl logs -n opentelemetry-operator-system {} manager
kubectl get deploy -A
# multi-instrumentation end-to-tests, alias to make matrix tests more convenient
# the tests are the same, but the setup is different
.PHONY: e2e-multi-instrumentation-default
e2e-multi-instrumentation-default: e2e-multi-instrumentation
# end-to-tests for multi-instrumentation
.PHONY: e2e-multi-instrumentation
e2e-multi-instrumentation: chainsaw
$(CHAINSAW) test --test-dir ./tests/e2e-multi-instrumentation --report-name e2e-multi-instrumentation
# OpAMPBridge CR end-to-tests
.PHONY: e2e-opampbridge
e2e-opampbridge: chainsaw
$(CHAINSAW) test --test-dir ./tests/e2e-opampbridge --report-name e2e-opampbridge
# end-to-end-test for testing pdb support
.PHONY: e2e-pdb
e2e-pdb: chainsaw
$(CHAINSAW) test --test-dir ./tests/e2e-pdb --report-name e2e-pdb
# end-to-end-test for PrometheusCR E2E tests
.PHONY: e2e-prometheuscr
e2e-prometheuscr: chainsaw
$(CHAINSAW) test --test-dir ./tests/e2e-prometheuscr --report-name e2e-prometheuscr $(CHAINSAW_SELECTOR)
# Target allocator end-to-tests
.PHONY: e2e-targetallocator
e2e-targetallocator: chainsaw
$(CHAINSAW) test --test-dir ./tests/e2e-targetallocator --report-name e2e-targetallocator
# Target allocator CR end-to-tests
.PHONY: e2e-targetallocator-cr
e2e-targetallocator-cr: chainsaw
$(CHAINSAW) test --test-dir ./tests/e2e-targetallocator-cr --report-name e2e-targetallocator-cr
# Add cert-manager permissions for mTLS testing
.PHONY: add-certmanager-permissions
add-certmanager-permissions:
# Kustomize only allows patches in the folder where the kustomization is located
# This folder is ignored by .gitignore
cp -r tests/e2e-ta-collector-mtls/certmanager-permissions config/rbac/certmanager-permissions
cd config/rbac && $(KUSTOMIZE) edit add patch --kind ClusterRole --name manager-role --path certmanager-permissions/certmanager.yaml
# Target allocator collector mTLS end-to-tests
.PHONY: e2e-ta-collector-mtls
e2e-ta-collector-mtls: chainsaw
$(CHAINSAW) test --test-dir ./tests/e2e-ta-collector-mtls --report-name e2e-ta-collector-mtls
# end-to-end-test for Annotations/Labels Filters
.PHONY: e2e-metadata-filters
e2e-metadata-filters: chainsaw
$(CHAINSAW) test --test-dir ./tests/e2e-metadata-filters --report-name e2e-metadata-filters
# end-to-end-test for testing upgrading
.PHONY: e2e-upgrade
e2e-upgrade: undeploy chainsaw
kubectl apply -f ./tests/e2e-upgrade/upgrade-test/opentelemetry-operator-v0.86.0.yaml
go run hack/check-operator-ready.go
$(CHAINSAW) test --test-dir ./tests/e2e-upgrade --report-name e2e-upgrade
# end-to-end tests to test crd validations
.PHONY: e2e-crd-validations
e2e-crd-validations: chainsaw
$(CHAINSAW) test --test-dir ./tests/e2e-crd-validations
# Prepare environment for e2e tests
.PHONY: prepare-e2e
prepare-e2e: chainsaw set-image-controller add-image-targetallocator add-image-opampbridge start-kind cert-manager install-metrics-server install-targetallocator-prometheus-crds load-image-all deploy
@mkdir -p ./.testresults/e2e
# Run operator-sdk scorecard tests for bundles
.PHONY: scorecard-tests
scorecard-tests: operator-sdk
$(OPERATOR_SDK) scorecard -w=5m bundle/community || (echo "scorecard test for community bundle failed" && exit 1)
$(OPERATOR_SDK) scorecard -w=5m bundle/openshift || (echo "scorecard test for openshift bundle failed" && exit 1)
##@ Container
# Build the container image, used only for local dev purposes.
# buildx is used to ensure same results for arm based systems (m1/2 chips)
.PHONY: container
container: GOOS = linux
container: manager
docker build --load -t ${IMG} .
# Push the container image, used only for local dev purposes
.PHONY: container-push
container-push:
docker push ${IMG}
# Push target allocator container image
.PHONY: container-target-allocator-push
container-target-allocator-push:
docker push ${TARGETALLOCATOR_IMG}
# Push operator OpAMP bridge container image
.PHONY: container-operator-opamp-bridge-push
container-operator-opamp-bridge-push:
docker push ${OPERATOROPAMPBRIDGE_IMG}
# Build target allocator container image
.PHONY: container-target-allocator
container-target-allocator: GOOS = linux
container-target-allocator: targetallocator
docker build --load -t ${TARGETALLOCATOR_IMG} cmd/otel-allocator
# Build operator OpAMP bridge container image
.PHONY: container-operator-opamp-bridge
container-operator-opamp-bridge: GOOS = linux
container-operator-opamp-bridge: operator-opamp-bridge
docker build --load -t ${OPERATOROPAMPBRIDGE_IMG} cmd/operator-opamp-bridge
# Build bridge test server container image for e2e tests
.PHONY: container-bridge-test-server
container-bridge-test-server: GOOS = linux
container-bridge-test-server:
docker build --load -t ${BRIDGETESTSERVER_IMG} tests/test-e2e-apps/bridge-server
# Build must-gather container image
.PHONY: container-must-gather
container-must-gather: GOOS = linux
container-must-gather: must-gather
docker build -f cmd/gather/Dockerfile --load -t ${MUSTGATHER_IMG} .
# Push must-gather container image
.PHONY: container-must-gather-push
container-must-gather-push:
docker push ${MUSTGATHER_IMG}
# Build Java auto-instrumentation container image
.PHONY: container-instrumentation-java
container-instrumentation-java:
docker build --load -t ${INSTRUMENTATION_JAVA_IMG} autoinstrumentation/java \
--build-arg version=${INSTRUMENTATION_JAVA_VERSION}
# Build Node.js auto-instrumentation container image
.PHONY: container-instrumentation-nodejs
container-instrumentation-nodejs:
docker build --load -t ${INSTRUMENTATION_NODEJS_IMG} autoinstrumentation/nodejs \
--build-arg version=${INSTRUMENTATION_NODEJS_VERSION}
# Build Python auto-instrumentation container image
.PHONY: container-instrumentation-python
container-instrumentation-python:
docker build --load -t ${INSTRUMENTATION_PYTHON_IMG} autoinstrumentation/python \
--build-arg version=${INSTRUMENTATION_PYTHON_VERSION}
# Build .NET auto-instrumentation container image
.PHONY: container-instrumentation-dotnet
container-instrumentation-dotnet:
docker build --load -t ${INSTRUMENTATION_DOTNET_IMG} autoinstrumentation/dotnet \
--build-arg version=${INSTRUMENTATION_DOTNET_VERSION}
# Build Apache HTTPD auto-instrumentation container image
.PHONY: container-instrumentation-apache-httpd
container-instrumentation-apache-httpd:
docker build --load -t ${INSTRUMENTATION_APACHE_HTTPD_IMG} autoinstrumentation/apache-httpd \
--build-arg version=${INSTRUMENTATION_APACHE_HTTPD_VERSION}
# Build all auto-instrumentation container images
.PHONY: container-instrumentation-all
container-instrumentation-all: container-instrumentation-java container-instrumentation-nodejs container-instrumentation-python container-instrumentation-dotnet container-instrumentation-apache-httpd
##@ Kind Cluster
# Start kind cluster for local development
.PHONY: start-kind
start-kind: kind
ifeq (true,$(START_KIND_CLUSTER))
$(KIND) create cluster --name $(KIND_CLUSTER_NAME) --config $(KIND_CONFIG) || true
endif
# Stop kind cluster
.PHONY: stop-kind
stop-kind: kind
ifeq (true,$(START_KIND_CLUSTER))
$(KIND) delete cluster --name $(KIND_CLUSTER_NAME)
endif
# Install metrics server in the cluster
.PHONY: install-metrics-server
install-metrics-server:
./hack/install-metrics-server.sh
# This only installs the CRDs Target Allocator supports
.PHONY: install-targetallocator-prometheus-crds
install-targetallocator-prometheus-crds:
./hack/install-targetallocator-prometheus-crds.sh
# Load all container images into kind cluster
.PHONY: load-image-all
load-image-all:
ifeq ($(IMAGE_ARCHIVE),)
@make container load-image-operator load-image-target-allocator load-image-operator-opamp-bridge load-image-bridge-test-server
else
$(KIND) load --name $(KIND_CLUSTER_NAME) image-archive $(IMAGE_ARCHIVE)
endif
# Load operator image into kind cluster
.PHONY: load-image-operator
load-image-operator: container kind
ifeq (true,$(START_KIND_CLUSTER))
$(KIND) load --name $(KIND_CLUSTER_NAME) docker-image $(IMG)
else
$(MAKE) container-push
endif
# Load target allocator image into kind cluster
.PHONY: load-image-target-allocator
load-image-target-allocator: container-target-allocator kind
ifeq (true,$(START_KIND_CLUSTER))
$(KIND) load --name $(KIND_CLUSTER_NAME) docker-image $(TARGETALLOCATOR_IMG)
else
$(MAKE) container-target-allocator-push
endif
# Load bridge test server image into kind cluster
.PHONY: load-image-bridge-test-server
load-image-bridge-test-server: container-bridge-test-server kind
$(KIND) load --name $(KIND_CLUSTER_NAME) docker-image ${BRIDGETESTSERVER_IMG}
# Load operator OpAMP bridge image into kind cluster
.PHONY: load-image-operator-opamp-bridge
load-image-operator-opamp-bridge: container-operator-opamp-bridge kind
$(KIND) load --name $(KIND_CLUSTER_NAME) docker-image ${OPERATOROPAMPBRIDGE_IMG}
# Load all instrumentation images into kind cluster
.PHONY: load-images-instrumentation
load-images-instrumentation: container-instrumentation-all kind
$(KIND) load --name $(KIND_CLUSTER_NAME) docker-image ${INSTRUMENTATION_JAVA_IMG}
$(KIND) load --name $(KIND_CLUSTER_NAME) docker-image ${INSTRUMENTATION_NODEJS_IMG}
$(KIND) load --name $(KIND_CLUSTER_NAME) docker-image ${INSTRUMENTATION_PYTHON_IMG}
$(KIND) load --name $(KIND_CLUSTER_NAME) docker-image ${INSTRUMENTATION_DOTNET_IMG}
$(KIND) load --name $(KIND_CLUSTER_NAME) docker-image ${INSTRUMENTATION_APACHE_HTTPD_IMG}
# Install cert-manager in the cluster
.PHONY: cert-manager
cert-manager: cmctl
# Consider using cmctl to install the cert-manager once install command is not experimental
kubectl apply --validate=false -f https://github.com/jetstack/cert-manager/releases/download/v${CERTMANAGER_VERSION}/cert-manager.yaml
$(CMCTL) check api --wait=5m
##@ Tools
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
CMCTL = $(shell pwd)/bin/cmctl
# Download cmctl locally if necessary
.PHONY: cmctl
cmctl:
@{ \
set -e ;\
if (`pwd`/bin/cmctl version | grep ${CERTMANAGER_VERSION}) > /dev/null 2>&1 ; then \
exit 0; \
fi ;\
TMP_DIR=$$(mktemp -d) ;\
curl -L -o $$TMP_DIR/cmctl.tar.gz https://github.com/jetstack/cert-manager/releases/download/v$(CERTMANAGER_VERSION)/cmctl-`go env GOOS`-`go env GOARCH`.tar.gz ;\
tar xzf $$TMP_DIR/cmctl.tar.gz -C $$TMP_DIR ;\
[ -d bin ] || mkdir bin ;\
mv $$TMP_DIR/cmctl $(CMCTL) ;\
rm -rf $$TMP_DIR ;\
}
KUSTOMIZE ?= $(LOCALBIN)/kustomize
KIND ?= $(LOCALBIN)/kind
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest
CHLOGGEN ?= $(LOCALBIN)/chloggen
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
CHAINSAW ?= $(LOCALBIN)/chainsaw
GOTESTSUM ?= $(LOCALBIN)/gotestsum
# renovate: datasource=go depName=sigs.k8s.io/kustomize/kustomize/v5
KUSTOMIZE_VERSION ?= v5.8.1
# renovate: datasource=go depName=sigs.k8s.io/controller-tools/cmd/controller-gen
CONTROLLER_TOOLS_VERSION ?= v0.20.1
# renovate: datasource=github-releases depName=golangci/golangci-lint
GOLANGCI_LINT_VERSION ?= v2.10.1
# renovate: datasource=go depName=sigs.k8s.io/kind
KIND_VERSION ?= v0.31.0
# renovate: datasource=go depName=github.com/kyverno/chainsaw
CHAINSAW_VERSION ?= v0.2.14
# renovate: datasource=go depName=gotest.tools/gotestsum
GOTESTSUM_VERSION ?= v1.13.0
# Install all development tools
.PHONY: install-tools
install-tools: kustomize golangci-lint kind controller-gen envtest crdoc operator-sdk chainsaw gotestsum cmctl
# Download kustomize locally if necessary
.PHONY: kustomize
kustomize: ## Download kustomize locally if necessary.
$(call go-install-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v5,$(KUSTOMIZE_VERSION))
# Download golangci-lint locally if necessary
.PHONY: golangci-lint
golangci-lint: ## Download golangci-lint locally if necessary.
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
# Download kind locally if necessary
.PHONY: kind
kind: ## Download kind locally if necessary.
$(call go-install-tool,$(KIND),sigs.k8s.io/kind,$(KIND_VERSION))
# Download controller-gen locally if necessary
.PHONY: controller-gen
controller-gen: ## Download controller-gen locally if necessary.
$(call go-install-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen,$(CONTROLLER_TOOLS_VERSION))
# Download envtest-setup locally if necessary
.PHONY: envtest
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
$(call go-install-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest,latest)
CRDOC = $(shell pwd)/bin/crdoc
# Download crdoc locally if necessary
.PHONY: crdoc
crdoc: ## Download crdoc locally if necessary.
$(call go-install-tool,$(CRDOC),fybrik.io/crdoc,v0.5.2)
# Find or download chainsaw
.PHONY: chainsaw
chainsaw: ## Find or download chainsaw
$(call go-install-tool,$(CHAINSAW),github.com/kyverno/chainsaw,$(CHAINSAW_VERSION))
# Find or download gotestsum
.PHONY: gotestsum
gotestsum: ## Find or download gotestsum
$(call go-install-tool,$(GOTESTSUM),gotest.tools/gotestsum,$(GOTESTSUM_VERSION))
# go-install-tool will 'go install' any package $2 and install it to $1.
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
define go-install-tool
@set -e ; \
BIN="$(1)"; PKG="$(2)"; VER="$(3)"; \
DIR="$$(dirname "$$BIN")"; mkdir -p "$$DIR"; \
if [ -x "$$BIN" ] && [ "$$VER" != "latest" ]; then \
CUR=$$(go version -m "$$BIN" 2>/dev/null | awk '$$1=="mod"{print $$3; exit}'); \
if [ "$$CUR" = "$$VER" ]; then \
exit 0; \
fi; \
echo "Current version of $$PKG is $$CUR, expected $$VER. Reinstalling..."; \
fi; \
echo "Installing $$PKG@$$VER -> $$BIN"; \
GOBIN="$$DIR" go install "$$PKG@$$VER"
endef
OPERATOR_SDK = $(shell pwd)/bin/operator-sdk
# Download operator-sdk locally if necessary
.PHONY: operator-sdk
operator-sdk: $(LOCALBIN)
@{ \
set -e ;\
if (`pwd`/bin/operator-sdk version | grep ${OPERATOR_SDK_VERSION}) > /dev/null 2>&1 ; then \
exit 0; \
fi ;\
[ -d bin ] || mkdir bin ;\
curl -L -o $(OPERATOR_SDK) https://github.com/operator-framework/operator-sdk/releases/download/v${OPERATOR_SDK_VERSION}/operator-sdk_`go env GOOS`_`go env GOARCH`;\
chmod +x $(OPERATOR_SDK) ;\
}
##@ Bundle
# Generate bundle manifests and metadata, then validate generated files.
.PHONY: generate-bundle
generate-bundle: kustomize operator-sdk manifests set-image-controller api-docs
@$(SED_INPLACE) 's/minKubeVersion: .*/minKubeVersion: $(MIN_KUBERNETES_VERSION)/' config/manifests/$(BUNDLE_VARIANT)/bases/opentelemetry-operator.clusterserviceversion.yaml
$(OPERATOR_SDK) generate kustomize manifests -q --input-dir $(MANIFESTS_DIR) --output-dir $(MANIFESTS_DIR)
cd $(BUNDLE_DIR) && cp ../../PROJECT . && $(KUSTOMIZE) build ../../$(MANIFESTS_DIR) | $(OPERATOR_SDK) generate bundle $(BUNDLE_BUILD_GEN_FLAGS) && rm PROJECT
# Workaround for https://github.com/operator-framework/operator-sdk/issues/4992
echo "" >> bundle/$(BUNDLE_VARIANT)/bundle.Dockerfile
echo "LABEL com.redhat.openshift.versions=v$(MIN_OPENSHIFT_VERSION)" >> bundle/$(BUNDLE_VARIANT)/bundle.Dockerfile
echo "" >> bundle/$(BUNDLE_VARIANT)/metadata/annotations.yaml
echo " com.redhat.openshift.versions: v$(MIN_OPENSHIFT_VERSION)" >> bundle/$(BUNDLE_VARIANT)/metadata/annotations.yaml
$(OPERATOR_SDK) bundle validate $(BUNDLE_DIR)
./hack/ignore-createdAt-bundle.sh
# Generate bundle for both community and openshift variants
.PHONY: bundle
bundle:
BUNDLE_VARIANT=community VERSION=$(VERSION) $(MAKE) generate-bundle
BUNDLE_VARIANT=openshift VERSION=$(VERSION) $(MAKE) generate-bundle
# Reset bundle configuration to defaults
.PHONY: reset
reset: kustomize operator-sdk manifests
$(MAKE) VERSION=${OPERATOR_VERSION} set-image-controller
$(OPERATOR_SDK) generate kustomize manifests -q --input-dir config/manifests/community --output-dir config/manifests/community
$(OPERATOR_SDK) generate kustomize manifests -q --input-dir config/manifests/openshift --output-dir config/manifests/openshift
$(KUSTOMIZE) build config/manifests/community | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS) --kustomize-dir config/manifests/community --output-dir bundle/community
$(KUSTOMIZE) build config/manifests/openshift |$(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS) --kustomize-dir config/manifests/openshift --output-dir bundle/openshift
# Workaround for https://github.com/operator-framework/operator-sdk/issues/4992
echo "" >> bundle/community/metadata/annotations.yaml
echo " com.redhat.openshift.versions: v$(MIN_OPENSHIFT_VERSION)" >> bundle/community/metadata/annotations.yaml
echo "" >> bundle/openshift/metadata/annotations.yaml
echo " com.redhat.openshift.versions: v$(MIN_OPENSHIFT_VERSION)" >> bundle/openshift/metadata/annotations.yaml
$(OPERATOR_SDK) bundle validate ./bundle/community
$(OPERATOR_SDK) bundle validate ./bundle/openshift
rm bundle.Dockerfile
git checkout config/manager/kustomization.yaml
./hack/ignore-createdAt-bundle.sh
# Build the bundle image, used only for local dev purposes
.PHONY: bundle-build
bundle-build:
docker build --load -f ./bundle/$(BUNDLE_VARIANT)/bundle.Dockerfile -t $(BUNDLE_IMG) ./bundle/$(BUNDLE_VARIANT)
# Push bundle image to registry
.PHONY: bundle-push
bundle-push:
docker push $(BUNDLE_IMG)
##@ Documentation
# Generate API documentation from CRDs
.PHONY: api-docs
api-docs: crdoc kustomize
@{ \
set -e ;\
TMP_MANIFEST_DIR=$$(mktemp -d) ; \
cp -r config/crd/* $$TMP_MANIFEST_DIR; \
$(MAKE) CRD_OPTIONS=$(CRD_OPTIONS),maxDescLen=1200 MANIFEST_DIR=$$TMP_MANIFEST_DIR/bases manifests ;\
TMP_DIR=$$(mktemp -d) ; \
$(KUSTOMIZE) build $$TMP_MANIFEST_DIR -o $$TMP_DIR ;\
mkdir -p docs/api ;\
for crdmanifest in $$TMP_DIR/*; do \
filename="$$(basename -s .opentelemetry.io.yaml $$crdmanifest)" ;\
filename="$${filename#apiextensions.k8s.io_v1_customresourcedefinition_}" ;\
if [ "$$filename" = "clusterobservabilities" ]; then \
echo "Skipping API documentation generation for clusterobservabilities (internal alpha API)" ;\
else \
$(CRDOC) --resources $$crdmanifest --output docs/api/$$filename.md ;\
fi ;\
done;\
}
##@ Changelog
# Install chloggen tool
.PHONY: chlog-install
chlog-install: $(CHLOGGEN)
$(CHLOGGEN): $(LOCALBIN)
GOBIN=$(LOCALBIN) go install go.opentelemetry.io/build-tools/chloggen@v0.23.1
FILENAME?=$(shell git branch --show-current)
# Create new changelog entry
.PHONY: chlog-new
chlog-new: chlog-install
$(CHLOGGEN) new --filename $(FILENAME)
# Validate changelog entries
.PHONY: chlog-validate
chlog-validate: chlog-install
$(CHLOGGEN) validate
# Preview changelog update
.PHONY: chlog-preview
chlog-preview: chlog-install
$(CHLOGGEN) update --dry
# Update changelog for release
.PHONY: chlog-update
chlog-update: chlog-install chlog-insert-components
$(CHLOGGEN) update --version $(VERSION)
# Insert component versions into changelog
.PHONY: chlog-insert-components
chlog-insert-components:
@echo "### Components" > components.md
@echo "" >>components.md
@echo "* [OpenTelemetry Collector - v${OTELCOL_VERSION}](https://github.com/open-telemetry/opentelemetry-collector/releases/tag/v${OTELCOL_VERSION})" >>components.md
@echo "* [OpenTelemetry Contrib - v${OTELCOL_VERSION}](https://github.com/open-telemetry/opentelemetry-collector-contrib/releases/tag/v${OTELCOL_VERSION})" >>components.md
@echo "* [Java auto-instrumentation - v${DEFAULT_INSTRUMENTATION_JAVA_VERSION}](https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/tag/v${DEFAULT_INSTRUMENTATION_JAVA_VERSION})" >>components.md
@echo "* [.NET auto-instrumentation - v${DEFAULT_INSTRUMENTATION_DOTNET_VERSION}](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases/tag/v${DEFAULT_INSTRUMENTATION_DOTNET_VERSION})" >>components.md
@echo "* [Node.JS - v${DEFAULT_INSTRUMENTATION_NODEJS_VERSION}](https://github.com/open-telemetry/opentelemetry-js/releases/tag/experimental%2Fv${DEFAULT_INSTRUMENTATION_NODEJS_VERSION})" >>components.md
@echo "* [Python - v${DEFAULT_INSTRUMENTATION_PYTHON_VERSION}](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v${DEFAULT_INSTRUMENTATION_PYTHON_VERSION})" >>components.md
@echo "* [Go - ${DEFAULT_INSTRUMENTATION_GO_VERSION}](https://github.com/open-telemetry/opentelemetry-go-instrumentation/releases/tag/${DEFAULT_INSTRUMENTATION_GO_VERSION})" >>components.md
@echo "* [ApacheHTTPD - ${DEFAULT_INSTRUMENTATION_APACHE_HTTPD_VERSION}](https://github.com/open-telemetry/opentelemetry-cpp-contrib/releases/tag/webserver%2Fv${DEFAULT_INSTRUMENTATION_APACHE_HTTPD_VERSION})" >>components.md
@echo "* [Nginx - ${DEFAULT_INSTRUMENTATION_NGINX_VERSION}](https://github.com/open-telemetry/opentelemetry-cpp-contrib/releases/tag/webserver%2Fv${DEFAULT_INSTRUMENTATION_NGINX_VERSION})" >>components.md
@$(SED_INPLACE) '/<!-- next version -->/r ./components.md' CHANGELOG.md
@$(SED_INPLACE) '/<!-- next version -->/G' CHANGELOG.md
@rm components.md
##@ Catalog
# Download opm locally if necessary
.PHONY: opm
OPM = ./bin/opm
opm: ## Download opm locally if necessary.
ifeq (,$(wildcard $(OPM)))
ifeq (,$(shell which opm 2>/dev/null))
@{ \
set -e ;\
mkdir -p $(dir $(OPM)) ;\
OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.28.0/${OS}-${ARCH}-opm ;\
chmod +x $(OPM) ;\
}
else
OPM = $(shell which opm)
endif
endif
# A comma-separated list of bundle images (e.g. make catalog-build BUNDLE_IMGS=example.com/operator-bundle:v0.1.0,example.com/operator-bundle:v0.2.0).
# These images MUST exist in a registry and be pull-able.
BUNDLE_IMGS ?= $(BUNDLE_IMG)
# The image tag given to the resulting catalog image (e.g. make catalog-build CATALOG_IMG=example.com/operator-catalog:v0.2.0).
CATALOG_IMG ?= ${IMG_PREFIX}/${IMG_REPO}-catalog:${VERSION}
# Set CATALOG_BASE_IMG to an existing catalog image tag to add $BUNDLE_IMGS to that image.
ifneq ($(origin CATALOG_BASE_IMG), undefined)
FROM_INDEX_OPT := --from-index $(CATALOG_BASE_IMG)
endif
# Build a catalog image by adding bundle images to an empty catalog using the operator package manager tool, 'opm'.
## This recipe invokes 'opm' in 'semver' bundle add mode. For more information on add modes, see:
## https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator
.PHONY: catalog-build
catalog-build: opm bundle-build bundle-push ## Build a catalog image.
$(OPM) index add --container-tool docker --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT)
# Push the catalog image.
.PHONY: catalog-push
catalog-push: ## Push a catalog image.
docker push $(CATALOG_IMG)
##@ Release
# Create container image archive with all images
container-image-archive: IMAGE_LIST_FILE = images-$(VERSION).txt
container-image-archive: container container-target-allocator container-operator-opamp-bridge container-bridge-test-server container-instrumentation-all
ifeq ($(IMAGE_ARCHIVE),)
$(error "Use make container-image-archive IMAGE_ARCHIVE=<filename>")
endif
@rm -f $(IMAGE_LIST_FILE)
@echo "$(IMG)" >>$(IMAGE_LIST_FILE)
@echo "$(TARGETALLOCATOR_IMG)" >>$(IMAGE_LIST_FILE)
@echo "$(OPERATOROPAMPBRIDGE_IMG)" >>$(IMAGE_LIST_FILE)
@echo "$(BRIDGETESTSERVER_IMG)" >>$(IMAGE_LIST_FILE)
@echo "$(INSTRUMENTATION_JAVA_IMG)" >>$(IMAGE_LIST_FILE)
@echo "$(INSTRUMENTATION_NODEJS_IMG)" >>$(IMAGE_LIST_FILE)
@echo "$(INSTRUMENTATION_PYTHON_IMG)" >>$(IMAGE_LIST_FILE)
@echo "$(INSTRUMENTATION_DOTNET_IMG)" >>$(IMAGE_LIST_FILE)
@echo "$(INSTRUMENTATION_APACHE_HTTPD_IMG)" >>$(IMAGE_LIST_FILE)
xargs -x -n 50 docker save -o "$(IMAGE_ARCHIVE)" <$(IMAGE_LIST_FILE)
##@ Validation
# Check markdown files for broken links using linkspector
.PHONY: markdown-link-check
markdown-link-check:
@command -v linkspector >/dev/null 2>&1 || { \
echo "Install: npm install -g @umbrelladocs/linkspector"; \
exit 1; \
}
linkspector check