Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
219 lines (196 loc) · 8.95 KB
/
Copy pathMakefile
File metadata and controls
219 lines (196 loc) · 8.95 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
# Copyright (c) 2026 Ant Group Corporation.
#
# SPDX-License-Identifier: Apache-2.0
SHELL := /bin/bash
VENDOR ?= aliyun
ENV ?= default
IMAGE_TAG ?=
IMAGE_REPOSITORY ?=
OPEN_YR_CORE_WHEEL_URL ?=
OPEN_YR_CORE_WHEEL_SHA256 ?=
RRT_RUNTIME_URL ?=
RRT_RUNTIME_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 ?=
CHUNK_DB_SIZE ?=
ENABLE_RUNC ?=
SCHEDULE_PLACEMENT_POLICY ?=
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 config ENABLE_RUNC=true Build and register the optional runc runtime"
@echo " make config SCHEDULE_PLACEMENT_POLICY=binpack Use compact scheduling"
@echo " make build IMAGE_TAG=<tag> Build the all-in-one image"
@echo " make standalone Build current source and start local runsc"
@echo " make standalone-status Show local source profile health"
@echo " make standalone-stop Stop a drained local source profile"
@echo " make build RUNTIME_PROFILE=python Include optional Python runtimes"
@echo " make build AKERNEL_ENABLE_KATA=false Exclude the optional Kata payload"
@echo " make build AKERNEL_ENABLE_FIRECRACKER=false Exclude Firecracker"
@echo " make build AKERNEL_ENABLE_RUNC=true Include the optional runc payload"
@echo " make build AKERNEL_TARGETARCH=arm64 AKERNEL_ENABLE_KATA=false AKERNEL_ENABLE_FIRECRACKER=false AKERNEL_ENABLE_RUNC=true Build native arm64 runc image"
@echo " make build RRT_RUNTIME_URL=... RRT_RUNTIME_SHA256=... Override RRT artifact"
@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 deploy-standalone-test Test standalone deployment helpers"
@echo " make standalone-source-test Build, SDK-test and stop a fresh local profile"
@echo " make build-helper-test Test image-build helpers without Docker"
@echo " make e2e Run the basic SDK e2e example"
@echo " make destroy Destroy cloud resources"
.PHONY: check
check:
@./deploy/scripts/check-prereqs.sh --vendor "$(VENDOR)"
.PHONY: config
config:
@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 "$(CHUNK_DB_SIZE)" ]]; then args+=(--chunk-db-size "$(CHUNK_DB_SIZE)"); fi; \
if [[ -n "$(ENABLE_RUNC)" ]]; then args+=(--enable-runc "$(ENABLE_RUNC)"); fi; \
if [[ -n "$(SCHEDULE_PLACEMENT_POLICY)" ]]; then args+=(--schedule-placement-policy "$(SCHEDULE_PLACEMENT_POLICY)"); 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:
@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 "$(RUNTIME_PROFILE)" ]]; then args+=(--runtime-profile "$(RUNTIME_PROFILE)"); 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; \
if [[ -n "$(RRT_RUNTIME_URL)" ]]; then args+=(--rrt-runtime-url "$(RRT_RUNTIME_URL)"); fi; \
if [[ -n "$(RRT_RUNTIME_SHA256)" ]]; then args+=(--rrt-runtime-sha256 "$(RRT_RUNTIME_SHA256)"); fi; \
./deploy/scripts/build-image.sh "$${args[@]}"
.PHONY: versions
versions:
@./deploy/scripts/build-image.sh --print-component-versions
.PHONY: standalone standalone-status standalone-stop
standalone:
@python3 deploy/standalone/manage.py up
standalone-status:
@python3 deploy/standalone/manage.py status
standalone-stop:
@python3 deploy/standalone/manage.py stop
.PHONY: push
push:
@./deploy/scripts/push-image.sh --vendor "$(VENDOR)" --env "$(ENV)"
.PHONY: plan
plan:
@./deploy/scripts/deploy.sh --vendor "$(VENDOR)" --env "$(ENV)" --plan
.PHONY: deploy
deploy:
@./deploy/scripts/deploy.sh --vendor "$(VENDOR)" --env "$(ENV)" --apply
.PHONY: token
token:
@./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:
@./deploy/scripts/print-sdk-env.sh --vendor "$(VENDOR)" --env "$(ENV)"
.PHONY: e2e
e2e:
@./deploy/scripts/run-e2e.sh --env "$(ENV)"
.PHONY: sdk-test
sdk-test:
@PYTHONPATH=sdk/python python3 -m unittest discover \
-s sdk/python/tests/unit -t sdk/python -v
.PHONY: sdk-check
sdk-check: sdk-test
@set -e; \
cd sdk/python; \
python3 -m ruff check akernel_sdk tests; \
python3 -m mypy akernel_sdk
.PHONY: deploy-script-check
deploy-script-check:
@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: deploy-standalone-test
deploy-standalone-test:
@python3 -m unittest discover -s deploy/standalone -p 'test_*.py'
.PHONY: build-helper-test
build-helper-test:
@python3 builder/scripts/test-build-image.py
@python3 builder/scripts/test-apt-mirror.py
@python3 builder/scripts/test-elf-arch.py
.PHONY: standalone-source-test
standalone-source-test:
@bash deploy/standalone/test-source.sh
.PHONY: destroy
destroy:
@args=(--vendor "$(VENDOR)" --env "$(ENV)"); \
if [[ "$(AUTO_APPROVE)" == "1" ]]; then args+=(--yes); fi; \
./deploy/scripts/destroy.sh "$${args[@]}"