forked from kubernetes-sigs/headlamp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
283 lines (236 loc) · 8.35 KB
/
Copy pathMakefile
File metadata and controls
283 lines (236 loc) · 8.35 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
GO111MODULE=on
export GO111MODULE
SERVER_EXE_EXT ?=
DOCKER_CMD ?= docker
DOCKER_BUILDX_CMD ?= buildx
DOCKER_REPO ?= ghcr.io/headlamp-k8s
DOCKER_EXT_REPO ?= docker.io/headlamp
DOCKER_IMAGE_NAME ?= headlamp
DOCKER_PLUGINS_IMAGE_NAME ?= plugins
DOCKER_IMAGE_VERSION ?= $(shell git describe --tags --always --dirty)
DOCKER_PLATFORM ?= local
DOCKER_PUSH ?= false
ifeq ($(OS), Windows_NT)
SERVER_EXE_EXT = .exe
endif
ifeq ($(OS), Windows_NT)
UNIXSHELL = false
ifdef BASH_VERSION
UNIXSHELL = true
endif
ifdef BASH_VERSION
UNIXSHELL = true
endif
else
UNIXSHELL = true
endif
all: backend frontend
tools/golangci-lint: backend/go.mod backend/go.sum
GOBIN=`pwd`/backend/tools go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64
backend-lint: tools/golangci-lint
cd backend && ./tools/golangci-lint run
backend-lint-fix: tools/golangci-lint
cd backend && ./tools/golangci-lint run --fix
frontend/build:
make frontend
.PHONY: app
app-build: frontend/build
cd app && npm install && node ./scripts/setup-plugins.js && npm run build
app: app-build
cd app && npm run package -- --win --linux --mac
app-win: app-build
cd app && npm run package -- --win
app-win-msi: app-build
cd app && npm run package-msi
app-linux: app-build
cd app && npm run package -- --linux
app-mac: app-build
cd app && npm run package -- --mac
app-test:
cd app && npm install
cd app && npm run test
app-tsc:
cd app && npm install
cd app && npm run tsc
.PHONY: backend
backend:
cd backend && go build -o ./headlamp-server${SERVER_EXE_EXT} ./cmd
.PHONY: backend-test
backend-test:
cd backend && go test -v -p 1 ./...
.PHONY: backend-coverage
backend-coverage:
cd backend && go test -v -p 1 -coverprofile=coverage.out ./...
cd backend && go tool cover -func=coverage.out
.PHONY: backend-coverage-html
backend-coverage-html:
cd backend && go test -v -p 1 -coverprofile=coverage.out ./...
cd backend && go tool cover -html=coverage.out
.PHONY: backend-format
backend-format:
cd backend && go fmt ./cmd/ ./pkg/**
frontend-install:
cd frontend && npm install
frontend-install-ci:
cd frontend && npm ci
.PHONY: frontend
frontend: frontend-install
cd frontend && npm run build
.PHONY: frontend-build
frontend-build:
cd frontend && npm run build
.PHONY: frontend-build-storybook
frontend-build-storybook:
cd frontend && npm run build-storybook
run-backend:
@echo "**** Warning: Running with Helm and dynamic-clusters endpoints enabled. ****"
ifeq ($(UNIXSHELL),true)
HEADLAMP_BACKEND_TOKEN=headlamp HEADLAMP_CONFIG_ENABLE_HELM=true HEADLAMP_CONFIG_ENABLE_DYNAMIC_CLUSTERS=true ./backend/headlamp-server -dev -proxy-urls https://artifacthub.io/* -listen-addr=localhost
else
@echo "**** Running on Windows without bash or zsh. ****"
@cmd /c "set HEADLAMP_BACKEND_TOKEN=headlamp&& set HEADLAMP_CONFIG_ENABLE_HELM=true&& set HEADLAMP_CONFIG_ENABLE_DYNAMIC_CLUSTERS=true&& backend\headlamp-server -dev -proxy-urls https://artifacthub.io/* -listen-addr=localhost"
endif
run-dev:
@echo "Starting Headlamp backend in dev mode with Air..."
cd backend && air
run-backend-with-metrics:
@echo "**** Running backend with Prometheus metrics enabled ****"
ifeq ($(UNIXSHELL),true)
HEADLAMP_BACKEND_TOKEN=headlamp \
HEADLAMP_CONFIG_METRICS_ENABLED=true \
HEADLAMP_CONFIG_ENABLE_HELM=true \
HEADLAMP_CONFIG_ENABLE_DYNAMIC_CLUSTERS=true \
./backend/headlamp-server -dev -proxy-urls https://artifacthub.io/* -listen-addr=localhost
else
@echo "**** Running on Windows without bash or zsh. ****"
@cmd /c "set HEADLAMP_BACKEND_TOKEN=headlamp&& set HEADLAMP_CONFIG_METRICS_ENABLED=true&& set HEADLAMP_CONFIG_ENABLE_HELM=true&& set HEADLAMP_CONFIG_ENABLE_DYNAMIC_CLUSTERS=true&& backend\headlamp-server -dev -proxy-urls https://artifacthub.io/* -listen-addr=localhost"
endif
run-backend-with-traces:
@echo "**** Running backend with distributed tracing enabled ****"
ifeq ($(UNIXSHELL),true)
HEADLAMP_BACKEND_TOKEN=headlamp \
HEADLAMP_CONFIG_TRACING_ENABLED=true \
HEADLAMP_CONFIG_ENABLE_HELM=true \
HEADLAMP_CONFIG_ENABLE_DYNAMIC_CLUSTERS=true \
./backend/headlamp-server -dev -proxy-urls https://artifacthub.io/* -listen-addr=localhost
else
@echo "**** Running on Windows without bash or zsh. ****"
@cmd /c "set HEADLAMP_BACKEND_TOKEN=headlamp&& set HEADLAMP_CONFIG_TRACING_ENABLED=true&& set HEADLAMP_CONFIG_ENABLE_HELM=true&& set HEADLAMP_CONFIG_ENABLE_DYNAMIC_CLUSTERS=true&& backend\headlamp-server -dev -proxy-urls https://artifacthub.io/* -listen-addr=localhost"
endif
run-frontend:
ifeq ($(UNIXSHELL),true)
cd frontend && nice -16 npm start
else
cd frontend && npm start
endif
run-app:
cd app && npm install && node ./scripts/setup-plugins.js && npm run start
run-only-app:
cd app && npm install && node ./scripts/setup-plugins.js && npm run dev-only-app
frontend-lint:
cd frontend && npm run lint -- --max-warnings 0 && npm run format-check
frontend-lint-fix:
cd frontend && npm run lint -- --fix && npm run format
.PHONY: frontend-tsc
frontend-tsc:
cd frontend && npm run tsc
.PHONY: frontend-i18n-check
frontend-i18n-check:
@echo "Checking translations. If this fails use: 'npm run i18n'"
cd frontend && npm run i18n -- --fail-on-update
frontend-test:
cd frontend && npm run test -- --coverage
.PHONY: lint
lint: backend-lint frontend-lint
.PHONY: lint-fix
lint-fix: backend-lint-fix frontend-lint-fix
plugins-test:
cd plugins/headlamp-plugin && npm install && ./test-headlamp-plugin.js
cd plugins/headlamp-plugin && ./test-plugins-examples.sh
cd plugins/pluginctl/src && npm install && node ./plugin-management.e2e.js
cd plugins/pluginctl && npx jest src/multi-plugin-management.test.js
cd plugins/pluginctl && npx jest src/plugin-management.test.js
cd plugins/pluginctl && npm run test
# IMAGE_BASE can be used to specify a base final image.
# IMAGE_BASE=debian:latest make image
image:
@if [ -n "${IMAGE_BASE}" ]; then \
BUILD_ARG="--build-arg IMAGE_BASE=${IMAGE_BASE}"; \
else \
BUILD_ARG=""; \
fi; \
$(DOCKER_CMD) $(DOCKER_BUILDX_CMD) build \
--pull \
--platform=$(DOCKER_PLATFORM) \
$$BUILD_ARG \
--push=$(DOCKER_PUSH) \
-t $(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_VERSION) -f \
Dockerfile \
.
.PHONY: build-plugins-container
build-plugins-container:
$(DOCKER_CMD) $(DOCKER_BUILDX_CMD) build \
--pull \
--platform=linux/amd64 \
--push=$(DOCKER_PUSH) \
-t $(DOCKER_REPO)/$(DOCKER_PLUGINS_IMAGE_NAME):$(DOCKER_IMAGE_VERSION) -f \
Dockerfile.plugins \
.
docker-ext:
$(eval LATEST_TAG=$(shell git tag --list --sort=version:refname 'v*' | tail -1 | sed 's/^.//'))
$(DOCKER_CMD) $(DOCKER_BUILDX_CMD) build \
--platform=linux/amd64,linux/arm64 \
--push \
-t $(DOCKER_EXT_REPO)/$(DOCKER_IMAGE_NAME)-docker-extension:${LATEST_TAG} \
-t $(DOCKER_EXT_REPO)/$(DOCKER_IMAGE_NAME)-docker-extension:latest -f \
./docker-extension/Dockerfile \
./docker-extension
.PHONY: docs
docs:
cd frontend && npm install && npm run build-typedoc
.PHONY: storybook
storybook:
cd frontend && npm install && npm run storybook
i18n:
cd app && npm run i18n
cd frontend && npm run i18n
.PHONY: helm-template-test
helm-template-test:
charts/headlamp/tests/test.sh
.PHONY: helm-update-template-version
helm-update-template-version:
charts/headlamp/tests/update-version.sh
# TODO: add windows compatibility
.PHONY: run-jaeger
run-jaeger:
@echo "Starting Jaeger container..."
@docker rm -f jaeger 2>/dev/null || true
@docker run -d --name jaeger \
-p 16686:16686 \
-p 4317:4317 \
-p 4318:4318 \
-e COLLECTOR_OTLP_ENABLED=true \
jaegertracing/all-in-one:latest
@echo "Jaeger UI will be available at http://localhost:16686"
@echo "OTLP endpoints: grpc://localhost:4317, http://localhost:4318"
.PHONY: run-prometheus
run-prometheus:
@echo "Starting Prometheus container..."
@docker rm -f prometheus 2>/dev/null || true
@docker run -d \
--name prometheus \
--network host \
-p 9090:9090 \
-v $(PWD)/backend/pkg/telemetry/prometheus.yaml:/etc/prometheus.yaml \
prom/prometheus:latest --config.file=/etc/prometheus.yaml
@echo "Prometheus UI will be available at http://localhost:9090"
.PHONY: run-monitoring
run-monitoring: run-jaeger run-prometheus
@echo "Monitoring stack is ready:"
@echo "- Jaeger UI: http://localhost:16686"
@echo "- Prometheus UI: http://localhost:9090"
.PHONY: stop-monitoring
stop-monitoring:
@echo "Stopping monitoring containers..."
@docker rm -f jaeger prometheus 2>/dev/null || true
@echo "Monitoring containers stopped"