-
Notifications
You must be signed in to change notification settings - Fork 203
/
Makefile
258 lines (200 loc) · 8.99 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
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
TAG ?= $(shell odigos version --cluster)
ODIGOS_CLI_VERSION ?= $(shell odigos version --cli)
ORG ?= keyval
.PHONY: build-odiglet
build-odiglet:
docker build -t $(ORG)/odigos-odiglet:$(TAG) . -f odiglet/Dockerfile --build-arg ODIGOS_VERSION=$(TAG)
.PHONY: verify-nodejs-agent
verify-nodejs-agent:
@if [ ! -f ../opentelemetry-node/package.json ]; then \
echo "Error: To build odiglet agents from source, first clone the agents code locally"; \
exit 1; \
fi
.PHONY: build-odiglet-with-agents
build-odiglet-with-agents:
docker build -t $(ORG)/odigos-odiglet:$(TAG) . -f odiglet/Dockerfile --build-arg ODIGOS_VERSION=$(TAG) --build-context nodejs-agent-src=../opentelemetry-node
.PHONY: build-autoscaler
build-autoscaler:
docker build -t $(ORG)/odigos-autoscaler:$(TAG) . --build-arg SERVICE_NAME=autoscaler
.PHONY: build-instrumentor
build-instrumentor:
docker build -t $(ORG)/odigos-instrumentor:$(TAG) . --build-arg SERVICE_NAME=instrumentor
.PHONY: build-scheduler
build-scheduler:
docker build -t $(ORG)/odigos-scheduler:$(TAG) . --build-arg SERVICE_NAME=scheduler
.PHONY: build-collector
build-collector:
docker build -t $(ORG)/odigos-collector:$(TAG) collector -f collector/Dockerfile
.PHONY: build-ui
build-ui:
docker build -t $(ORG)/odigos-ui:$(TAG) . -f frontend/Dockerfile
.PHONY: build-images
build-images:
# prefer to build timeconsuimg images first to make better use of parallelism
make -j 3 build-ui build-collector build-odiglet build-autoscaler build-scheduler build-instrumentor TAG=$(TAG)
.PHONY: push-odiglet
push-odiglet:
docker buildx build --platform linux/amd64,linux/arm64/v8 --push -t $(ORG)/odigos-odiglet:$(TAG) . -f odiglet/Dockerfile
.PHONY: push-autoscaler
push-autoscaler:
docker buildx build --platform linux/amd64,linux/arm64/v8 --push -t $(ORG)/odigos-autoscaler:$(TAG) . --build-arg SERVICE_NAME=autoscaler
.PHONY: push-instrumentor
push-instrumentor:
docker buildx build --platform linux/amd64,linux/arm64/v8 --push -t $(ORG)/odigos-instrumentor:$(TAG) . --build-arg SERVICE_NAME=instrumentor
.PHONY: push-scheduler
push-scheduler:
docker buildx build --platform linux/amd64,linux/arm64/v8 --push -t $(ORG)/odigos-scheduler:$(TAG) . --build-arg SERVICE_NAME=scheduler
.PHONY: push-collector
push-collector:
docker buildx build --platform linux/amd64,linux/arm64/v8 --push -t $(ORG)/odigos-collector:$(TAG) collector -f collector/Dockerfile
.PHONY: push-ui
push-ui:
docker buildx build --platform linux/amd64,linux/arm64/v8 --push -t $(ORG)/odigos-ui:$(TAG) . -f frontend/Dockerfile
.PHONY: push-images
push-images:
make push-autoscaler TAG=$(TAG)
make push-scheduler TAG=$(TAG)
make push-odiglet TAG=$(TAG)
make push-instrumentor TAG=$(TAG)
make push-collector TAG=$(TAG)
make push-ui TAG=$(TAG)
.PHONY: load-to-kind-odiglet
load-to-kind-odiglet:
kind load docker-image $(ORG)/odigos-odiglet:$(TAG)
.PHONY: load-to-kind-autoscaler
load-to-kind-autoscaler:
kind load docker-image $(ORG)/odigos-autoscaler:$(TAG)
.PHONY: load-to-kind-collector
load-to-kind-collector:
kind load docker-image $(ORG)/odigos-collector:$(TAG)
.PHONY: load-to-kind-instrumentor
load-to-kind-instrumentor:
kind load docker-image $(ORG)/odigos-instrumentor:$(TAG)
.PHONY: load-to-kind-ui
load-to-kind-ui:
kind load docker-image $(ORG)/odigos-ui:$(TAG)
.PHONY: load-to-kind-scheduler
load-to-kind-scheduler:
kind load docker-image $(ORG)/odigos-scheduler:$(TAG)
.PHONY: load-to-kind
load-to-kind:
make -j 6 load-to-kind-instrumentor load-to-kind-autoscaler load-to-kind-scheduler load-to-kind-odiglet load-to-kind-collector load-to-kind-ui TAG=$(TAG)
.PHONY: restart-ui
restart-ui:
kubectl rollout restart deployment odigos-ui -n odigos-system
.PHONY: restart-odiglet
restart-odiglet:
kubectl rollout restart daemonset odiglet -n odigos-system
.PHONY: restart-autoscaler
restart-autoscaler:
kubectl rollout restart deployment odigos-autoscaler -n odigos-system
.PHONY: restart-instrumentor
restart-instrumentor:
kubectl rollout restart deployment odigos-instrumentor -n odigos-system
.PHONY: restart-scheduler
restart-scheduler:
kubectl rollout restart deployment odigos-scheduler -n odigos-system
.PHONY: restart-collector
restart-collector:
kubectl rollout restart deployment odigos-gateway -n odigos-system
# DaemonSets don't directly support the rollout restart command in the same way Deployments do. However, you can achieve the same result by updating an environment variable or any other field in the DaemonSet's pod template, triggering a rolling update of the pods managed by the DaemonSet
kubectl -n odigos-system patch daemonset odigos-data-collection -p "{\"spec\":{\"template\":{\"metadata\":{\"annotations\":{\"kubectl.kubernetes.io/restartedAt\":\"$(date +%Y-%m-%dT%H:%M:%S%z)\"}}}}}"
.PHONY: deploy-odiglet
deploy-odiglet:
make build-odiglet TAG=$(TAG) && make load-to-kind-odiglet TAG=$(TAG) && make restart-odiglet
# Use this target to deploy odiglet with local clones of the agents.
# To work, the agents must be cloned in the same directory as the odigos (e.g. in '../opentelemetry-node')
# There you can make code changes to the agents and deploy them with the odiglet.
.PHONY: deploy-odiglet-with-agents
deploy-odiglet-with-agents: verify-nodejs-agent build-odiglet-with-agents load-to-kind-odiglet restart-odiglet
.PHONY: deploy-autoscaler
deploy-autoscaler:
make build-autoscaler TAG=$(TAG) && make load-to-kind-autoscaler TAG=$(TAG) && make restart-autoscaler
.PHONY: deploy-collector
deploy-collector:
make build-collector TAG=$(TAG) && make load-to-kind-collector TAG=$(TAG) && make restart-collector
.PHONY: deploy-instrumentor
deploy-instrumentor:
make build-instrumentor TAG=$(TAG) && make load-to-kind-instrumentor TAG=$(TAG) && make restart-instrumentor
.PHONY: deploy-ui
deploy-ui:
make build-ui TAG=$(TAG) && make load-to-kind-ui TAG=$(TAG) && make restart-ui
.PHONY: deploy-scheduler
deploy-scheduler:
make build-scheduler TAG=$(TAG) && make load-to-kind-scheduler TAG=$(TAG) && make restart-scheduler
.PHONY: debug-odiglet
debug-odiglet:
docker build -t $(ORG)/odigos-odiglet:$(TAG) . -f odiglet/debug.Dockerfile
kind load docker-image $(ORG)/odigos-odiglet:$(TAG)
kubectl delete pod -n odigos-system -l app.kubernetes.io/name=odiglet
kubectl wait --for=condition=ready pod -n odigos-system -l app.kubernetes.io/name=odiglet --timeout=180s
kubectl port-forward -n odigos-system daemonset/odiglet 2345:2345
.PHONY: deploy
deploy: deploy-odiglet deploy-autoscaler deploy-collector deploy-instrumentor deploy-scheduler
,PHONY: e2e-test
e2e-test:
./e2e-test.sh
ALL_GO_MOD_DIRS := $(shell find . -type f -name 'go.mod' -exec dirname {} \; | sort)
.PHONY: go-mod-tidy
go-mod-tidy: $(ALL_GO_MOD_DIRS:%=go-mod-tidy/%)
go-mod-tidy/%: DIR=$*
go-mod-tidy/%:
@cd $(DIR) && go mod tidy -compat=1.21
.PHONY: check-clean-work-tree
check-clean-work-tree:
if [ -n "$$(git status --porcelain)" ]; then \
git status; \
git --no-pager diff; \
echo 'Working tree is not clean, did you forget to run "make go-mod-tidy"?'; \
exit 1; \
fi
# installs odigos from the local source, with local changes to api and cli directorie reflected in the odigos deployment
.PHONY: cli-install
cli-install:
@echo "Installing odigos from source. version: $(ODIGOS_CLI_VERSION)"
cd ./cli ; go run -tags=embed_manifests . install --version $(ODIGOS_CLI_VERSION)
.PHONY: cli-upgrade
cli-upgrade:
@echo "Upgrading odigos from source. version: $(ODIGOS_CLI_VERSION)"
cd ./cli ; go run -tags=embed_manifests . upgrade --version $(ODIGOS_CLI_VERSION) --yes
.PHONY: cli-build
cli-build:
@echo "Building the cli executable for tests"
cd cli && go build -tags=embed_manifests -o odigos .
.PHONY: cli-diagnose
cli-diagnose:
@echo "Diagnosing cluster data for debugging"
cd ./cli ; go run -tags=embed_manifests . diagnose
.PHONY: helm-install
helm-install:
@echo "Installing odigos using helm"
helm upgrade --install odigos ./helm/odigos --create-namespace --namespace odigos-system --set image.tag=$(ODIGOS_CLI_VERSION)
kubectl label namespace odigos-system odigos.io/system-object="true"
.PHONY: api-all
api-all:
make -C api all
.PHONY: crd-apply
crd-apply: api-all cli-upgrade
@echo "Applying changes to CRDs in api directory"
.PHONY: dev-tests-kind-cluster
dev-tests-kind-cluster:
@echo "Creating a kind cluster for development"
kind delete cluster
kind create cluster
.PHONY: dev-tests-setup
dev-tests-setup: TAG := e2e-test
dev-tests-setup: dev-tests-kind-cluster cli-build build-images load-to-kind
# Use this target to avoid rebuilding the images if all that changed is the e2e test code
.PHONY: dev-tests-setup-no-build
dev-tests-setup-no-build: TAG := e2e-test
dev-tests-setup-no-build: dev-tests-kind-cluster load-to-kind
# Use this for debug to add a destination which only prints samples of telemetry items to the cluster gateway collector logs
.PHONY: dev-debug-destination
dev-debug-destination:
kubectl apply -f ./tests/debug-exporter.yaml
.PHONY: dev-add-nop-destination
dev-nop-destination:
kubectl apply -f ./tests/nop-exporter.yaml
.PHONY: dev-add-backpressue-destination
dev-backpressue-destination:
kubectl apply -f ./tests/backpressure-exporter.yaml