forked from inclusionAI/AKernel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
188 lines (171 loc) · 7.86 KB
/
Copy pathMakefile
File metadata and controls
188 lines (171 loc) · 7.86 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
# Copyright (c) 2026 Ant Group Corporation.
#
# SPDX-License-Identifier: Apache-2.0
SHELL := /usr/bin/bash
VENDOR ?= aliyun
ENV ?= default
IMAGE_TAG ?=
IMAGE_REPOSITORY ?=
GVISOR_RELEASE ?=
GVISOR_RELEASE_BASE_URL ?=
OPEN_YR_CORE_WHEEL_URL ?=
OPEN_YR_CORE_WHEEL_SHA256 ?=
TOKEN_TTL ?= $(if $(TTL),$(TTL),24h)
TENANT ?= default
ROLE ?= developer
FORCE ?= 0
NON_INTERACTIVE ?= 0
REGION ?=
CLUSTER_NAME ?=
ZONE_IDS ?=
AVAILABILITY_ZONE ?=
VSWITCH_CIDRS ?=
NODE_POOL_SIZE ?=
NODE_POOL_INSTANCE_TYPES ?=
NODE_FLAVOR_ID ?=
NODE_POOL_KEY_NAME ?=
NODE_POOL_LOGIN_PASSWORD ?=
ACR_NAMESPACE ?=
MONITOR_STORAGE_CLASS ?=
INSTALL_MONITOR ?=
INSTALL_DRAGONFLY ?=
GRAFANA_PUBLIC_ACCESS ?=
GRAFANA_ADMIN_PASSWORD ?=
IAM_SEED_HEX ?=
.PHONY: help
help:
@echo "AKernel helper targets"
@echo
@echo " VENDOR defaults to aliyun."
@echo
@echo " make check Check required local tools"
@echo " make config Create .akernel/default config"
@echo " make config ENV=<name> Create or update a named config"
@echo " make config FORCE=1 Overwrite an existing config without prompting"
@echo " make config NON_INTERACTIVE=1 ... Generate config from Make variables"
@echo " make config INSTALL_DRAGONFLY=true Enable optional P2P image distribution"
@echo " make build IMAGE_TAG=<tag> Build the all-in-one image"
@echo " make build GVISOR_RELEASE=<tag> Override the pinned official gVisor tag"
@echo " make versions Show locally selected component versions"
@echo " make push Push the configured all-in-one image"
@echo " make plan Terraform plan"
@echo " make deploy Terraform apply"
@echo " make token TTL=24h Generate a local JWT token"
@echo " make print-env Print SDK environment exports"
@echo " make sdk-check Lint, type-check, and test the Python SDK"
@echo " make deploy-script-check Check deployment script syntax"
@echo " make e2e Run the basic SDK e2e example"
@echo " make destroy Destroy cloud resources"
.PHONY: check
check:
@unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY ALL_PROXY all_proxy; \
./deploy/scripts/check-prereqs.sh --vendor "$(VENDOR)"
.PHONY: config
config:
@unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY ALL_PROXY all_proxy; \
args=(--vendor "$(VENDOR)" --env "$(ENV)"); \
if [[ "$(FORCE)" == "1" ]]; then args+=(--force); fi; \
if [[ "$(NON_INTERACTIVE)" == "1" ]]; then args+=(--non-interactive); fi; \
if [[ -n "$(REGION)" ]]; then args+=(--region "$(REGION)"); fi; \
if [[ -n "$(CLUSTER_NAME)" ]]; then args+=(--cluster-name "$(CLUSTER_NAME)"); fi; \
if [[ -n "$(ZONE_IDS)" ]]; then args+=(--zone-ids "$(ZONE_IDS)"); fi; \
if [[ -n "$(AVAILABILITY_ZONE)" ]]; then args+=(--availability-zone "$(AVAILABILITY_ZONE)"); fi; \
if [[ -n "$(VSWITCH_CIDRS)" ]]; then args+=(--vswitch-cidrs "$(VSWITCH_CIDRS)"); fi; \
if [[ -n "$(NODE_POOL_SIZE)" ]]; then args+=(--node-pool-size "$(NODE_POOL_SIZE)"); fi; \
if [[ -n "$(NODE_POOL_INSTANCE_TYPES)" ]]; then args+=(--node-pool-instance-types "$(NODE_POOL_INSTANCE_TYPES)"); fi; \
if [[ -n "$(NODE_FLAVOR_ID)" ]]; then args+=(--node-flavor-id "$(NODE_FLAVOR_ID)"); fi; \
if [[ -n "$(NODE_POOL_KEY_NAME)" ]]; then args+=(--node-pool-key-name "$(NODE_POOL_KEY_NAME)"); fi; \
if [[ -n "$(NODE_POOL_LOGIN_PASSWORD)" ]]; then args+=(--node-pool-login-password "$(NODE_POOL_LOGIN_PASSWORD)"); fi; \
if [[ -n "$(ACR_NAMESPACE)" ]]; then args+=(--acr-namespace "$(ACR_NAMESPACE)"); fi; \
if [[ -n "$(MONITOR_STORAGE_CLASS)" ]]; then args+=(--monitor-storage-class "$(MONITOR_STORAGE_CLASS)"); fi; \
if [[ -n "$(IMAGE_REPOSITORY)" ]]; then args+=(--image-repository "$(IMAGE_REPOSITORY)"); fi; \
if [[ -n "$(IMAGE_TAG)" ]]; then args+=(--image-tag "$(IMAGE_TAG)"); fi; \
if [[ -n "$(INSTALL_MONITOR)" ]]; then args+=(--install-monitor "$(INSTALL_MONITOR)"); fi; \
if [[ -n "$(INSTALL_DRAGONFLY)" ]]; then args+=(--install-dragonfly "$(INSTALL_DRAGONFLY)"); fi; \
if [[ -n "$(GRAFANA_PUBLIC_ACCESS)" ]]; then args+=(--grafana-public-access "$(GRAFANA_PUBLIC_ACCESS)"); fi; \
if [[ -n "$(GRAFANA_ADMIN_PASSWORD)" ]]; then args+=(--grafana-admin-password "$(GRAFANA_ADMIN_PASSWORD)"); fi; \
if [[ -n "$(IAM_SEED_HEX)" ]]; then args+=(--iam-seed-hex "$(IAM_SEED_HEX)"); fi; \
./deploy/scripts/configure.sh "$${args[@]}"
.PHONY: build
build:
@unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY ALL_PROXY all_proxy; \
args=(--env "$(ENV)"); \
if [[ -n "$(IMAGE_REPOSITORY)" ]]; then args+=(--repository "$(IMAGE_REPOSITORY)"); fi; \
if [[ -n "$(IMAGE_TAG)" ]]; then args+=(--tag "$(IMAGE_TAG)"); fi; \
if [[ -n "$(GVISOR_RELEASE)" ]]; then args+=(--gvisor-release "$(GVISOR_RELEASE)"); fi; \
if [[ -n "$(GVISOR_RELEASE_BASE_URL)" ]]; then args+=(--gvisor-release-base-url "$(GVISOR_RELEASE_BASE_URL)"); fi; \
if [[ -n "$(OPEN_YR_CORE_WHEEL_URL)" ]]; then args+=(--open-yr-core-wheel-url "$(OPEN_YR_CORE_WHEEL_URL)"); fi; \
if [[ -n "$(OPEN_YR_CORE_WHEEL_SHA256)" ]]; then args+=(--open-yr-core-wheel-sha256 "$(OPEN_YR_CORE_WHEEL_SHA256)"); fi; \
./deploy/scripts/build-image.sh "$${args[@]}"
.PHONY: versions
versions:
@unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY ALL_PROXY all_proxy; \
./deploy/scripts/build-image.sh --print-component-versions
.PHONY: push
push:
@unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY ALL_PROXY all_proxy; \
./deploy/scripts/push-image.sh --vendor "$(VENDOR)" --env "$(ENV)"
.PHONY: plan
plan:
@unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY ALL_PROXY all_proxy; \
./deploy/scripts/deploy.sh --vendor "$(VENDOR)" --env "$(ENV)" --plan
.PHONY: deploy
deploy:
@unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY ALL_PROXY all_proxy; \
./deploy/scripts/deploy.sh --vendor "$(VENDOR)" --env "$(ENV)" --apply
.PHONY: token
token:
@unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY ALL_PROXY all_proxy; \
./deploy/scripts/generate-token.py \
--env "$(ENV)" \
--tenant "$(TENANT)" \
--role "$(ROLE)" \
--ttl "$(TOKEN_TTL)" \
--print-export \
--write-file ".akernel/$(ENV)/token"
.PHONY: print-env
print-env:
@unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY ALL_PROXY all_proxy; \
./deploy/scripts/print-sdk-env.sh --vendor "$(VENDOR)" --env "$(ENV)"
.PHONY: e2e
e2e:
@unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY ALL_PROXY all_proxy; \
./deploy/scripts/run-e2e.sh --env "$(ENV)"
.PHONY: sdk-test
sdk-test:
@unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY all_proxy ALL_PROXY no_proxy NO_PROXY; \
PYTHONPATH=sdk/python python3 -m unittest discover \
-s sdk/python/tests/unit -t sdk/python -v
.PHONY: sdk-check
sdk-check: sdk-test
@unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY all_proxy ALL_PROXY no_proxy NO_PROXY; \
cd sdk/python; \
python3 -m ruff check akernel_sdk tests; \
python3 -m mypy akernel_sdk
.PHONY: deploy-script-check
deploy-script-check:
@unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY all_proxy ALL_PROXY no_proxy NO_PROXY; \
set -euo pipefail; \
while IFS= read -r -d '' script; do \
bash -n "$$script"; \
done < <(git ls-files -z -- 'deploy/**/*.sh'); \
while IFS= read -r -d '' template; do \
if ! bash -n <( \
sed \
-e '/^[[:space:]]*%{.*}[[:space:]]*$$/d' \
-e 's/[$$][$$]/$$/g' \
"$$template" \
); then \
echo "Invalid shell template syntax: $$template" >&2; \
exit 1; \
fi; \
done < <(git ls-files -z -- 'deploy/**/*.sh.tftpl'); \
git ls-files -z -- 'deploy/**/*.py' | \
xargs -0 -r python3 -c \
'import pathlib, sys; [compile(pathlib.Path(path).read_bytes(), path, "exec") for path in sys.argv[1:]]'
.PHONY: destroy
destroy:
@unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY ALL_PROXY all_proxy; \
args=(--vendor "$(VENDOR)" --env "$(ENV)"); \
if [[ "$(AUTO_APPROVE)" == "1" ]]; then args+=(--yes); fi; \
./deploy/scripts/destroy.sh "$${args[@]}"