This repository was archived by the owner on Apr 21, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
112 lines (90 loc) · 3.76 KB
/
Makefile
File metadata and controls
112 lines (90 loc) · 3.76 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
export API_TAGS ?= ExternalClusterAPI,AuthTokenAPI,OperationsAPI,AutoscalerAPI
export SWAGGER_LOCATION ?= https://api.cast.ai/v1/spec/openapi.json
GO_INSTALL = ./hack/go-install.sh
TOOLS_DIR=bin
ROOT_DIR=$(abspath .)
TOOLS_GOBIN_DIR := $(abspath $(TOOLS_DIR))
GOLANGCI_LINT_VER := v2.11.2
GOLANGCI_LINT_BIN := golangci-lint
GOLANGCI_LINT := $(TOOLS_GOBIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER)
DOCKER_REPOSITORY ?= us-docker.pkg.dev/castai-hub/library/cluster-controller
ARCH ?= $(shell uname -m)
ifeq ($(ARCH),x86_64)
ARCH=amd64
endif
$(GOLANGCI_LINT):
GOBIN=$(TOOLS_GOBIN_DIR) $(GO_INSTALL) github.com/golangci/golangci-lint/v2/cmd/golangci-lint $(GOLANGCI_LINT_BIN) $(GOLANGCI_LINT_VER)
## build: Build the binary for the specified architecture and create a Docker image. Usually this means ARCH=amd64 should be set if running on an ARM machine. Use `go build .` for simple local build.
build:
CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH) go build -ldflags "-s -w" -o bin/castai-cluster-controller-$(ARCH) .
docker build --platform=linux/$(ARCH) --build-arg TARGETARCH=$(ARCH) -t $(DOCKER_REPOSITORY):$(VERSION) .
push:
docker push $(DOCKER_REPOSITORY):$(VERSION)
release: build push
lint: $(GOLANGCI_LINT)
$(GOLANGCI_LINT) run --timeout 20m ./...
.PHONY: lint
fix: $(GOLANGCI_LINT)
$(GOLANGCI_LINT) run --fix ./...
.PHONY: fix
test:
go test ./... -short -race -parallel=20
.PHONY: test
generate-e2e-client:
go generate ./e2e/client
.PHONY: generate-e2e-client
## deploy-loadtest: Build, push, and deploy the loadtest environment with cluster-controller
deploy-loadtest: release
IMAGE_REPOSITORY=$(DOCKER_REPOSITORY) \
IMAGE_TAG=$(VERSION) \
LOADTEST_IMAGE_REPOSITORY=$(DOCKER_REPOSITORY) \
LOADTEST_IMAGE_TAG=$(VERSION) \
./hack/loadtest/deploy-helm.sh \
$(if $(KWOK_VALUES_FILE),--kwok-values $(KWOK_VALUES_FILE)) \
$(if $(CC_VALUES_FILE),--cc-values $(CC_VALUES_FILE)) \
$(if $(LOADTEST_VALUES_FILE),--loadtest-values $(LOADTEST_VALUES_FILE))
.PHONY: deploy-loadtest
## deploy-loadtest-only: Deploy loadtest environment without building (uses existing image)
deploy-loadtest-only:
IMAGE_REPOSITORY=$(DOCKER_REPOSITORY) \
IMAGE_TAG=$(VERSION) \
LOADTEST_IMAGE_REPOSITORY=$(DOCKER_REPOSITORY) \
LOADTEST_IMAGE_TAG=$(VERSION) \
./hack/loadtest/deploy-helm.sh \
$(if $(KWOK_VALUES_FILE),--kwok-values $(KWOK_VALUES_FILE)) \
$(if $(CC_VALUES_FILE),--cc-values $(CC_VALUES_FILE)) \
$(if $(LOADTEST_VALUES_FILE),--loadtest-values $(LOADTEST_VALUES_FILE))
.PHONY: deploy-loadtest-only
## undeploy-loadtest: Remove the loadtest environment
undeploy-loadtest:
./hack/loadtest/undeploy-helm.sh
.PHONY: undeploy-loadtest
## loadtest-status: Check the status of loadtest deployment
loadtest-status:
@echo "==> Helm releases:"
@helm list -n castai-agent
@echo ""
@echo "==> Pods:"
@kubectl get pods -n castai-agent
@echo ""
@echo "==> Services:"
@kubectl get svc -n castai-agent | grep -E '(NAME|loadtest|prometheus|grafana|loki)'
.PHONY: loadtest-status
## loadtest-logs: Tail logs from loadtest agent
loadtest-logs:
kubectl logs -n castai-agent -l app=castai-loadtest-agent -f
.PHONY: loadtest-logs
## loadtest-forward-grafana: Port-forward Grafana to localhost:3000
loadtest-forward-grafana:
@echo "Grafana will be available at http://localhost:3000"
kubectl port-forward -n castai-agent svc/castai-loadtest-grafana 3000:80
.PHONY: loadtest-forward-grafana
## loadtest-forward-prometheus: Port-forward Prometheus to localhost:9090
loadtest-forward-prometheus:
@echo "Prometheus will be available at http://localhost:9090"
kubectl port-forward -n castai-agent svc/castai-loadtest-prometheus-server 9090:9090
.PHONY: loadtest-forward-prometheus
## loadtest-helm-deps: Build Helm chart dependencies
loadtest-helm-deps:
helm dependency build ./hack/loadtest/chart
.PHONY: loadtest-helm-deps