k7-sdk 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- k7_sdk/__init__.py +11 -0
- k7_sdk/client.py +550 -0
- k7_sdk-0.2.0.dist-info/METADATA +512 -0
- k7_sdk-0.2.0.dist-info/RECORD +8 -0
- k7_sdk-0.2.0.dist-info/WHEEL +5 -0
- k7_sdk-0.2.0.dist-info/licenses/LICENSE +203 -0
- k7_sdk-0.2.0.dist-info/top_level.txt +2 -0
- katakate/__init__.py +15 -0
k7_sdk/__init__.py
ADDED
k7_sdk/client.py
ADDED
|
@@ -0,0 +1,550 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import requests
|
|
4
|
+
|
|
5
|
+
try:
|
|
6
|
+
import httpx # optional dependency for async client
|
|
7
|
+
except Exception: # pragma: no cover
|
|
8
|
+
httpx = None
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class SandboxProxy:
|
|
12
|
+
"""Proxy object for sandbox operations."""
|
|
13
|
+
|
|
14
|
+
def __init__(self, name: str, namespace: str, client: Client):
|
|
15
|
+
self.name = name
|
|
16
|
+
self.namespace = namespace
|
|
17
|
+
self._client = client
|
|
18
|
+
|
|
19
|
+
def exec(self, code: str) -> dict:
|
|
20
|
+
"""Execute code in the sandbox."""
|
|
21
|
+
return self._client._exec_command(self.name, code, self.namespace)
|
|
22
|
+
|
|
23
|
+
def delete(self) -> dict:
|
|
24
|
+
"""Delete this sandbox."""
|
|
25
|
+
return self._client.delete(self.name, self.namespace)
|
|
26
|
+
|
|
27
|
+
def pause(self, snapshot: str | None = None) -> dict:
|
|
28
|
+
"""Pause this sandbox (scale to 0), optionally with a VolumeSnapshot.
|
|
29
|
+
|
|
30
|
+
Pass ``snapshot="my-snap"`` to create a crash-consistent
|
|
31
|
+
``VolumeSnapshot`` of the sandbox's root PVC before scaling to 0.
|
|
32
|
+
"""
|
|
33
|
+
return self._client.pause(self.name, namespace=self.namespace, snapshot=snapshot)
|
|
34
|
+
|
|
35
|
+
def resume(self) -> dict:
|
|
36
|
+
"""Resume this sandbox (scale back to 1)."""
|
|
37
|
+
return self._client.resume(self.name, namespace=self.namespace)
|
|
38
|
+
|
|
39
|
+
def fork(self, new_name: str, snapshot: str | None = None) -> SandboxProxy:
|
|
40
|
+
"""Fork this sandbox into ``new_name``; returns a proxy for the new sandbox.
|
|
41
|
+
|
|
42
|
+
Blocks until the cloned PVC is bound (the server-side `fork_sandbox`
|
|
43
|
+
waits for the new pod to schedule before returning).
|
|
44
|
+
"""
|
|
45
|
+
return self._client.fork(self.name, new_name, namespace=self.namespace, snapshot=snapshot)
|
|
46
|
+
|
|
47
|
+
def snapshot(self, snapshot_name: str) -> dict:
|
|
48
|
+
"""Snapshot this sandbox's root PVC without pausing it (kind=named)."""
|
|
49
|
+
return self._client.create_snapshot(self.name, snapshot_name, namespace=self.namespace)
|
|
50
|
+
|
|
51
|
+
def logs(self, tail: int = 200, container: str = "sandbox", since: int = 0) -> str:
|
|
52
|
+
"""Return a snapshot of this sandbox's pod logs."""
|
|
53
|
+
return self._client.logs(self.name, namespace=self.namespace, container=container, tail=tail, since=since)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class Client:
|
|
57
|
+
"""K7 Python SDK Client."""
|
|
58
|
+
|
|
59
|
+
def __init__(self, endpoint: str, api_key: str, verify_ssl: bool = True):
|
|
60
|
+
self.base_url = endpoint.rstrip("/")
|
|
61
|
+
self.api_key = api_key
|
|
62
|
+
self.session = requests.Session()
|
|
63
|
+
self.session.headers.update({"X-API-Key": api_key})
|
|
64
|
+
self.session.verify = verify_ssl
|
|
65
|
+
|
|
66
|
+
def _unwrap(self, response) -> dict:
|
|
67
|
+
data = response.json()
|
|
68
|
+
if isinstance(data, dict) and "data" in data:
|
|
69
|
+
return data["data"]
|
|
70
|
+
return data
|
|
71
|
+
|
|
72
|
+
def create(self, sandbox_config: dict) -> SandboxProxy:
|
|
73
|
+
"""Create a new sandbox and return a proxy object."""
|
|
74
|
+
response = self.session.post(f"{self.base_url}/api/v1/sandboxes", json=sandbox_config)
|
|
75
|
+
response.raise_for_status()
|
|
76
|
+
|
|
77
|
+
name = sandbox_config.get("name")
|
|
78
|
+
namespace = sandbox_config.get("namespace", "default")
|
|
79
|
+
|
|
80
|
+
return SandboxProxy(name, namespace, self)
|
|
81
|
+
|
|
82
|
+
def list(self, namespace: str | None = None) -> list[dict]:
|
|
83
|
+
"""List all sandboxes."""
|
|
84
|
+
params = {"namespace": namespace} if namespace else {}
|
|
85
|
+
response = self.session.get(f"{self.base_url}/api/v1/sandboxes", params=params)
|
|
86
|
+
response.raise_for_status()
|
|
87
|
+
return self._unwrap(response)
|
|
88
|
+
|
|
89
|
+
def delete(self, name: str, namespace: str = "default") -> dict:
|
|
90
|
+
"""Delete a sandbox."""
|
|
91
|
+
response = self.session.delete(f"{self.base_url}/api/v1/sandboxes/{name}", params={"namespace": namespace})
|
|
92
|
+
response.raise_for_status()
|
|
93
|
+
return self._unwrap(response)
|
|
94
|
+
|
|
95
|
+
def delete_all(self, namespace: str = "default") -> dict:
|
|
96
|
+
"""Delete all sandboxes in a namespace."""
|
|
97
|
+
response = self.session.delete(f"{self.base_url}/api/v1/sandboxes", params={"namespace": namespace})
|
|
98
|
+
response.raise_for_status()
|
|
99
|
+
return self._unwrap(response)
|
|
100
|
+
|
|
101
|
+
def install(
|
|
102
|
+
self,
|
|
103
|
+
playbook: str | None = None,
|
|
104
|
+
inventory: str | None = None,
|
|
105
|
+
verbose: bool = False,
|
|
106
|
+
) -> dict:
|
|
107
|
+
"""Install K7 on target hosts."""
|
|
108
|
+
response = self.session.post(
|
|
109
|
+
f"{self.base_url}/api/v1/install",
|
|
110
|
+
json={"playbook": playbook, "inventory": inventory, "verbose": verbose},
|
|
111
|
+
)
|
|
112
|
+
response.raise_for_status()
|
|
113
|
+
return self._unwrap(response)
|
|
114
|
+
|
|
115
|
+
def get_metrics(self, namespace: str | None = None) -> dict:
|
|
116
|
+
"""Get resource usage metrics for sandboxes."""
|
|
117
|
+
params = {"namespace": namespace} if namespace else {}
|
|
118
|
+
response = self.session.get(f"{self.base_url}/api/v1/sandboxes/metrics", params=params)
|
|
119
|
+
response.raise_for_status()
|
|
120
|
+
return self._unwrap(response)
|
|
121
|
+
|
|
122
|
+
def nodes_storage(self) -> dict:
|
|
123
|
+
"""Per-node storage-pool utilization (kfd thin-pool + k7d disks).
|
|
124
|
+
|
|
125
|
+
Returns a map of node name → ``{kata_thinpool, k7d_disks}`` (or
|
|
126
|
+
``{error: ...}`` when that node's agent is unreachable).
|
|
127
|
+
"""
|
|
128
|
+
response = self.session.get(f"{self.base_url}/api/v1/nodes/storage", timeout=120)
|
|
129
|
+
response.raise_for_status()
|
|
130
|
+
return self._unwrap(response)
|
|
131
|
+
|
|
132
|
+
def pause(
|
|
133
|
+
self,
|
|
134
|
+
name: str,
|
|
135
|
+
namespace: str = "default",
|
|
136
|
+
snapshot: str | None = None,
|
|
137
|
+
) -> dict:
|
|
138
|
+
"""Pause a sandbox (scale to 0), optionally taking a Longhorn VolumeSnapshot.
|
|
139
|
+
|
|
140
|
+
``snapshot``, when set, names a crash-consistent VolumeSnapshot taken
|
|
141
|
+
of the sandbox's root PVC. The PVC name and ``VolumeSnapshotClass``
|
|
142
|
+
are derived server-side (kata-qemu-longhorn convention + the playbook's
|
|
143
|
+
``longhorn`` class).
|
|
144
|
+
"""
|
|
145
|
+
body: dict = {"namespace": namespace}
|
|
146
|
+
if snapshot is not None:
|
|
147
|
+
body["snapshot"] = snapshot
|
|
148
|
+
response = self.session.post(f"{self.base_url}/api/v1/sandboxes/{name}/pause", json=body, timeout=120)
|
|
149
|
+
response.raise_for_status()
|
|
150
|
+
return self._unwrap(response)
|
|
151
|
+
|
|
152
|
+
def resume(self, name: str, namespace: str = "default") -> dict:
|
|
153
|
+
"""Resume a paused sandbox (scale back to 1)."""
|
|
154
|
+
response = self.session.post(
|
|
155
|
+
f"{self.base_url}/api/v1/sandboxes/{name}/resume",
|
|
156
|
+
json={"namespace": namespace},
|
|
157
|
+
timeout=30,
|
|
158
|
+
)
|
|
159
|
+
response.raise_for_status()
|
|
160
|
+
return self._unwrap(response)
|
|
161
|
+
|
|
162
|
+
def fork(
|
|
163
|
+
self,
|
|
164
|
+
source: str,
|
|
165
|
+
new_name: str,
|
|
166
|
+
namespace: str = "default",
|
|
167
|
+
snapshot: str | None = None,
|
|
168
|
+
) -> SandboxProxy:
|
|
169
|
+
"""Fork ``source`` into a new sandbox ``new_name``; returns a proxy for it.
|
|
170
|
+
|
|
171
|
+
Blocks until the cloned PVC is bound. Today this takes ~45s for
|
|
172
|
+
kata-qemu-longhorn; the HTTP request stays open for the duration.
|
|
173
|
+
"""
|
|
174
|
+
body: dict = {"new_name": new_name, "namespace": namespace}
|
|
175
|
+
if snapshot is not None:
|
|
176
|
+
body["snapshot"] = snapshot
|
|
177
|
+
response = self.session.post(f"{self.base_url}/api/v1/sandboxes/{source}/fork", json=body, timeout=600)
|
|
178
|
+
response.raise_for_status()
|
|
179
|
+
self._unwrap(response)
|
|
180
|
+
return SandboxProxy(new_name, namespace, self)
|
|
181
|
+
|
|
182
|
+
# ------------------------------------------------------------------
|
|
183
|
+
# Spec 10e: VolumeSnapshot CRUD + GC.
|
|
184
|
+
# ------------------------------------------------------------------
|
|
185
|
+
|
|
186
|
+
def list_snapshots(
|
|
187
|
+
self,
|
|
188
|
+
namespace: str = "default",
|
|
189
|
+
all_namespaces: bool = False,
|
|
190
|
+
sandbox: str | None = None,
|
|
191
|
+
kind: str | None = None,
|
|
192
|
+
) -> list[dict]:
|
|
193
|
+
params: dict = {"namespace": namespace, "all_namespaces": str(all_namespaces).lower()}
|
|
194
|
+
if sandbox is not None:
|
|
195
|
+
params["sandbox"] = sandbox
|
|
196
|
+
if kind is not None:
|
|
197
|
+
params["kind"] = kind
|
|
198
|
+
response = self.session.get(f"{self.base_url}/api/v1/snapshots", params=params, timeout=30)
|
|
199
|
+
response.raise_for_status()
|
|
200
|
+
return self._unwrap(response)
|
|
201
|
+
|
|
202
|
+
def get_snapshot(self, name: str, namespace: str = "default") -> dict | None:
|
|
203
|
+
response = self.session.get(
|
|
204
|
+
f"{self.base_url}/api/v1/snapshots/{name}", params={"namespace": namespace}, timeout=15
|
|
205
|
+
)
|
|
206
|
+
if response.status_code == 404:
|
|
207
|
+
return None
|
|
208
|
+
response.raise_for_status()
|
|
209
|
+
return self._unwrap(response)
|
|
210
|
+
|
|
211
|
+
def create_snapshot(self, sandbox: str, snapshot_name: str, namespace: str = "default") -> dict:
|
|
212
|
+
response = self.session.post(
|
|
213
|
+
f"{self.base_url}/api/v1/sandboxes/{sandbox}/snapshot",
|
|
214
|
+
json={"snapshot_name": snapshot_name, "namespace": namespace},
|
|
215
|
+
timeout=120,
|
|
216
|
+
)
|
|
217
|
+
response.raise_for_status()
|
|
218
|
+
return self._unwrap(response)
|
|
219
|
+
|
|
220
|
+
def delete_snapshot(self, name: str, namespace: str = "default") -> dict:
|
|
221
|
+
response = self.session.delete(
|
|
222
|
+
f"{self.base_url}/api/v1/snapshots/{name}", params={"namespace": namespace}, timeout=60
|
|
223
|
+
)
|
|
224
|
+
response.raise_for_status()
|
|
225
|
+
return self._unwrap(response)
|
|
226
|
+
|
|
227
|
+
def gc_snapshots(
|
|
228
|
+
self,
|
|
229
|
+
namespace: str = "default",
|
|
230
|
+
all_namespaces: bool = False,
|
|
231
|
+
keep_fork_for: str = "10m",
|
|
232
|
+
dry_run: bool = False,
|
|
233
|
+
) -> dict:
|
|
234
|
+
body: dict = {
|
|
235
|
+
"namespace": namespace,
|
|
236
|
+
"all_namespaces": all_namespaces,
|
|
237
|
+
"keep_fork_for": keep_fork_for,
|
|
238
|
+
"dry_run": dry_run,
|
|
239
|
+
}
|
|
240
|
+
response = self.session.post(f"{self.base_url}/api/v1/snapshots/gc", json=body, timeout=120)
|
|
241
|
+
response.raise_for_status()
|
|
242
|
+
return self._unwrap(response)
|
|
243
|
+
|
|
244
|
+
def restore(
|
|
245
|
+
self,
|
|
246
|
+
snapshot_name: str,
|
|
247
|
+
new_sandbox_name: str,
|
|
248
|
+
namespace: str = "default",
|
|
249
|
+
overrides: dict | None = None,
|
|
250
|
+
keep_snapshot: bool = True,
|
|
251
|
+
) -> SandboxProxy:
|
|
252
|
+
"""Restore a brand-new sandbox from a standalone VolumeSnapshot (Spec 10f).
|
|
253
|
+
|
|
254
|
+
``overrides`` is a JSON-serialisable dict matching ``SandboxConfigOverrides``
|
|
255
|
+
on the server (keys: ``image``, ``backend``, ``root_disk_size``, ``sidecar``,
|
|
256
|
+
``limits``, ``entrypoint``, ``cmd``, ``before_script``). Pass at minimum
|
|
257
|
+
``{"image": "..."}`` if the snapshot was created before Spec 10f and
|
|
258
|
+
therefore lacks the ``k7.io/source-image`` annotation.
|
|
259
|
+
|
|
260
|
+
Returns a ``SandboxProxy`` for the new sandbox. The server-side restore
|
|
261
|
+
waits for the cloned PVC to be Bound and the Deployment to be Ready
|
|
262
|
+
before responding, so the proxy is safe to ``exec`` against immediately.
|
|
263
|
+
"""
|
|
264
|
+
body: dict = {
|
|
265
|
+
"new_sandbox_name": new_sandbox_name,
|
|
266
|
+
"namespace": namespace,
|
|
267
|
+
"keep_snapshot": keep_snapshot,
|
|
268
|
+
}
|
|
269
|
+
if overrides:
|
|
270
|
+
body["overrides"] = overrides
|
|
271
|
+
response = self.session.post(
|
|
272
|
+
f"{self.base_url}/api/v1/snapshots/{snapshot_name}/restore",
|
|
273
|
+
json=body,
|
|
274
|
+
timeout=600,
|
|
275
|
+
)
|
|
276
|
+
response.raise_for_status()
|
|
277
|
+
self._unwrap(response)
|
|
278
|
+
return SandboxProxy(new_sandbox_name, namespace, self)
|
|
279
|
+
|
|
280
|
+
def exec(self, name: str, command: str, namespace: str = "default") -> dict:
|
|
281
|
+
"""Execute a shell command in a sandbox; returns ``{stdout, stderr, exit_code, duration_ms}``."""
|
|
282
|
+
return self._exec_command(name, command, namespace)
|
|
283
|
+
|
|
284
|
+
def logs(
|
|
285
|
+
self,
|
|
286
|
+
name: str,
|
|
287
|
+
namespace: str = "default",
|
|
288
|
+
container: str = "sandbox",
|
|
289
|
+
tail: int = 200,
|
|
290
|
+
since: int = 0,
|
|
291
|
+
) -> str:
|
|
292
|
+
"""Return a snapshot of the sandbox pod's logs (no streaming yet).
|
|
293
|
+
|
|
294
|
+
For interactive follow today, use ``k7 --core logs --follow`` on
|
|
295
|
+
the node. Streaming support is a separate spec.
|
|
296
|
+
"""
|
|
297
|
+
params: dict = {"namespace": namespace, "container": container, "tail": tail}
|
|
298
|
+
if since > 0:
|
|
299
|
+
params["since"] = since
|
|
300
|
+
response = self.session.get(
|
|
301
|
+
f"{self.base_url}/api/v1/sandboxes/{name}/logs",
|
|
302
|
+
params=params,
|
|
303
|
+
timeout=60,
|
|
304
|
+
)
|
|
305
|
+
response.raise_for_status()
|
|
306
|
+
data = self._unwrap(response)
|
|
307
|
+
if isinstance(data, dict):
|
|
308
|
+
return str(data.get("logs", ""))
|
|
309
|
+
return str(data)
|
|
310
|
+
|
|
311
|
+
def _exec_command(self, name: str, command: str, namespace: str) -> dict:
|
|
312
|
+
"""Internal method to execute command in sandbox."""
|
|
313
|
+
response = self.session.post(
|
|
314
|
+
f"{self.base_url}/api/v1/sandboxes/{name}/exec",
|
|
315
|
+
json={"command": command},
|
|
316
|
+
params={"namespace": namespace},
|
|
317
|
+
)
|
|
318
|
+
response.raise_for_status()
|
|
319
|
+
return self._unwrap(response)
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
class AsyncClient:
|
|
323
|
+
"""K7 Python SDK Async Client."""
|
|
324
|
+
|
|
325
|
+
def __init__(
|
|
326
|
+
self,
|
|
327
|
+
endpoint: str,
|
|
328
|
+
api_key: str,
|
|
329
|
+
verify_ssl: bool = True,
|
|
330
|
+
timeout: float = 30.0,
|
|
331
|
+
):
|
|
332
|
+
if httpx is None:
|
|
333
|
+
raise RuntimeError("httpx is required for AsyncClient. Install with `pip install httpx`.")
|
|
334
|
+
self.base_url = endpoint.rstrip("/")
|
|
335
|
+
self._client = httpx.AsyncClient(
|
|
336
|
+
base_url=self.base_url,
|
|
337
|
+
headers={"X-API-Key": api_key},
|
|
338
|
+
verify=verify_ssl,
|
|
339
|
+
timeout=timeout,
|
|
340
|
+
)
|
|
341
|
+
|
|
342
|
+
async def create(self, sandbox_config: dict) -> dict:
|
|
343
|
+
r = await self._client.post("/api/v1/sandboxes", json=sandbox_config)
|
|
344
|
+
r.raise_for_status()
|
|
345
|
+
return r.json()
|
|
346
|
+
|
|
347
|
+
async def list(self, namespace: str | None = None) -> list[dict]:
|
|
348
|
+
params = {"namespace": namespace} if namespace else {}
|
|
349
|
+
r = await self._client.get("/api/v1/sandboxes", params=params)
|
|
350
|
+
r.raise_for_status()
|
|
351
|
+
data = r.json()
|
|
352
|
+
if isinstance(data, dict) and "data" in data:
|
|
353
|
+
return data["data"]
|
|
354
|
+
return data
|
|
355
|
+
|
|
356
|
+
async def delete(self, name: str, namespace: str = "default") -> dict:
|
|
357
|
+
r = await self._client.delete(f"/api/v1/sandboxes/{name}", params={"namespace": namespace})
|
|
358
|
+
r.raise_for_status()
|
|
359
|
+
data = r.json()
|
|
360
|
+
if isinstance(data, dict) and "data" in data:
|
|
361
|
+
return data["data"]
|
|
362
|
+
return data
|
|
363
|
+
|
|
364
|
+
async def delete_all(self, namespace: str = "default") -> dict:
|
|
365
|
+
r = await self._client.delete("/api/v1/sandboxes", params={"namespace": namespace})
|
|
366
|
+
r.raise_for_status()
|
|
367
|
+
data = r.json()
|
|
368
|
+
if isinstance(data, dict) and "data" in data:
|
|
369
|
+
return data["data"]
|
|
370
|
+
return data
|
|
371
|
+
|
|
372
|
+
async def logs(
|
|
373
|
+
self,
|
|
374
|
+
name: str,
|
|
375
|
+
namespace: str = "default",
|
|
376
|
+
container: str = "sandbox",
|
|
377
|
+
tail: int = 200,
|
|
378
|
+
since: int = 0,
|
|
379
|
+
) -> str:
|
|
380
|
+
params: dict = {"namespace": namespace, "container": container, "tail": tail}
|
|
381
|
+
if since > 0:
|
|
382
|
+
params["since"] = since
|
|
383
|
+
r = await self._client.get(f"/api/v1/sandboxes/{name}/logs", params=params, timeout=60)
|
|
384
|
+
r.raise_for_status()
|
|
385
|
+
data = r.json()
|
|
386
|
+
unwrapped = data["data"] if isinstance(data, dict) and "data" in data else data
|
|
387
|
+
if isinstance(unwrapped, dict):
|
|
388
|
+
return str(unwrapped.get("logs", ""))
|
|
389
|
+
return str(unwrapped)
|
|
390
|
+
|
|
391
|
+
async def exec(self, name: str, command: str, namespace: str = "default") -> dict:
|
|
392
|
+
r = await self._client.post(
|
|
393
|
+
f"/api/v1/sandboxes/{name}/exec",
|
|
394
|
+
json={"command": command},
|
|
395
|
+
params={"namespace": namespace},
|
|
396
|
+
)
|
|
397
|
+
r.raise_for_status()
|
|
398
|
+
data = r.json()
|
|
399
|
+
if isinstance(data, dict) and "data" in data:
|
|
400
|
+
return data["data"]
|
|
401
|
+
return data
|
|
402
|
+
|
|
403
|
+
async def get_metrics(self, namespace: str | None = None) -> dict:
|
|
404
|
+
params = {"namespace": namespace} if namespace else {}
|
|
405
|
+
r = await self._client.get("/api/v1/sandboxes/metrics", params=params)
|
|
406
|
+
r.raise_for_status()
|
|
407
|
+
data = r.json()
|
|
408
|
+
if isinstance(data, dict) and "data" in data:
|
|
409
|
+
return data["data"]
|
|
410
|
+
return data
|
|
411
|
+
|
|
412
|
+
async def nodes_storage(self) -> dict:
|
|
413
|
+
"""Per-node storage-pool utilization (kfd thin-pool + k7d disks)."""
|
|
414
|
+
r = await self._client.get("/api/v1/nodes/storage", timeout=120)
|
|
415
|
+
r.raise_for_status()
|
|
416
|
+
data = r.json()
|
|
417
|
+
if isinstance(data, dict) and "data" in data:
|
|
418
|
+
return data["data"]
|
|
419
|
+
return data
|
|
420
|
+
|
|
421
|
+
async def pause(
|
|
422
|
+
self,
|
|
423
|
+
name: str,
|
|
424
|
+
namespace: str = "default",
|
|
425
|
+
snapshot: str | None = None,
|
|
426
|
+
) -> dict:
|
|
427
|
+
body: dict = {"namespace": namespace}
|
|
428
|
+
if snapshot is not None:
|
|
429
|
+
body["snapshot"] = snapshot
|
|
430
|
+
r = await self._client.post(f"/api/v1/sandboxes/{name}/pause", json=body, timeout=120)
|
|
431
|
+
r.raise_for_status()
|
|
432
|
+
data = r.json()
|
|
433
|
+
if isinstance(data, dict) and "data" in data:
|
|
434
|
+
return data["data"]
|
|
435
|
+
return data
|
|
436
|
+
|
|
437
|
+
async def resume(self, name: str, namespace: str = "default") -> dict:
|
|
438
|
+
r = await self._client.post(
|
|
439
|
+
f"/api/v1/sandboxes/{name}/resume",
|
|
440
|
+
json={"namespace": namespace},
|
|
441
|
+
timeout=30,
|
|
442
|
+
)
|
|
443
|
+
r.raise_for_status()
|
|
444
|
+
data = r.json()
|
|
445
|
+
if isinstance(data, dict) and "data" in data:
|
|
446
|
+
return data["data"]
|
|
447
|
+
return data
|
|
448
|
+
|
|
449
|
+
async def fork(
|
|
450
|
+
self,
|
|
451
|
+
source: str,
|
|
452
|
+
new_name: str,
|
|
453
|
+
namespace: str = "default",
|
|
454
|
+
snapshot: str | None = None,
|
|
455
|
+
) -> dict:
|
|
456
|
+
body: dict = {"new_name": new_name, "namespace": namespace}
|
|
457
|
+
if snapshot is not None:
|
|
458
|
+
body["snapshot"] = snapshot
|
|
459
|
+
r = await self._client.post(f"/api/v1/sandboxes/{source}/fork", json=body, timeout=600)
|
|
460
|
+
r.raise_for_status()
|
|
461
|
+
data = r.json()
|
|
462
|
+
if isinstance(data, dict) and "data" in data:
|
|
463
|
+
return data["data"]
|
|
464
|
+
return data
|
|
465
|
+
|
|
466
|
+
async def list_snapshots(
|
|
467
|
+
self,
|
|
468
|
+
namespace: str = "default",
|
|
469
|
+
all_namespaces: bool = False,
|
|
470
|
+
sandbox: str | None = None,
|
|
471
|
+
kind: str | None = None,
|
|
472
|
+
) -> list[dict]:
|
|
473
|
+
params: dict = {"namespace": namespace, "all_namespaces": str(all_namespaces).lower()}
|
|
474
|
+
if sandbox is not None:
|
|
475
|
+
params["sandbox"] = sandbox
|
|
476
|
+
if kind is not None:
|
|
477
|
+
params["kind"] = kind
|
|
478
|
+
r = await self._client.get("/api/v1/snapshots", params=params, timeout=30)
|
|
479
|
+
r.raise_for_status()
|
|
480
|
+
data = r.json()
|
|
481
|
+
return data["data"] if isinstance(data, dict) and "data" in data else data
|
|
482
|
+
|
|
483
|
+
async def get_snapshot(self, name: str, namespace: str = "default") -> dict | None:
|
|
484
|
+
r = await self._client.get(f"/api/v1/snapshots/{name}", params={"namespace": namespace}, timeout=15)
|
|
485
|
+
if r.status_code == 404:
|
|
486
|
+
return None
|
|
487
|
+
r.raise_for_status()
|
|
488
|
+
data = r.json()
|
|
489
|
+
return data["data"] if isinstance(data, dict) and "data" in data else data
|
|
490
|
+
|
|
491
|
+
async def create_snapshot(self, sandbox: str, snapshot_name: str, namespace: str = "default") -> dict:
|
|
492
|
+
r = await self._client.post(
|
|
493
|
+
f"/api/v1/sandboxes/{sandbox}/snapshot",
|
|
494
|
+
json={"snapshot_name": snapshot_name, "namespace": namespace},
|
|
495
|
+
timeout=120,
|
|
496
|
+
)
|
|
497
|
+
r.raise_for_status()
|
|
498
|
+
data = r.json()
|
|
499
|
+
return data["data"] if isinstance(data, dict) and "data" in data else data
|
|
500
|
+
|
|
501
|
+
async def delete_snapshot(self, name: str, namespace: str = "default") -> dict:
|
|
502
|
+
r = await self._client.delete(f"/api/v1/snapshots/{name}", params={"namespace": namespace}, timeout=60)
|
|
503
|
+
r.raise_for_status()
|
|
504
|
+
data = r.json()
|
|
505
|
+
return data["data"] if isinstance(data, dict) and "data" in data else data
|
|
506
|
+
|
|
507
|
+
async def gc_snapshots(
|
|
508
|
+
self,
|
|
509
|
+
namespace: str = "default",
|
|
510
|
+
all_namespaces: bool = False,
|
|
511
|
+
keep_fork_for: str = "10m",
|
|
512
|
+
dry_run: bool = False,
|
|
513
|
+
) -> dict:
|
|
514
|
+
body: dict = {
|
|
515
|
+
"namespace": namespace,
|
|
516
|
+
"all_namespaces": all_namespaces,
|
|
517
|
+
"keep_fork_for": keep_fork_for,
|
|
518
|
+
"dry_run": dry_run,
|
|
519
|
+
}
|
|
520
|
+
r = await self._client.post("/api/v1/snapshots/gc", json=body, timeout=120)
|
|
521
|
+
r.raise_for_status()
|
|
522
|
+
data = r.json()
|
|
523
|
+
return data["data"] if isinstance(data, dict) and "data" in data else data
|
|
524
|
+
|
|
525
|
+
async def restore(
|
|
526
|
+
self,
|
|
527
|
+
snapshot_name: str,
|
|
528
|
+
new_sandbox_name: str,
|
|
529
|
+
namespace: str = "default",
|
|
530
|
+
overrides: dict | None = None,
|
|
531
|
+
keep_snapshot: bool = True,
|
|
532
|
+
) -> dict:
|
|
533
|
+
body: dict = {
|
|
534
|
+
"new_sandbox_name": new_sandbox_name,
|
|
535
|
+
"namespace": namespace,
|
|
536
|
+
"keep_snapshot": keep_snapshot,
|
|
537
|
+
}
|
|
538
|
+
if overrides:
|
|
539
|
+
body["overrides"] = overrides
|
|
540
|
+
r = await self._client.post(
|
|
541
|
+
f"/api/v1/snapshots/{snapshot_name}/restore",
|
|
542
|
+
json=body,
|
|
543
|
+
timeout=600,
|
|
544
|
+
)
|
|
545
|
+
r.raise_for_status()
|
|
546
|
+
data = r.json()
|
|
547
|
+
return data["data"] if isinstance(data, dict) and "data" in data else data
|
|
548
|
+
|
|
549
|
+
async def aclose(self):
|
|
550
|
+
await self._client.aclose()
|
|
@@ -0,0 +1,512 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: k7-sdk
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: K7 sandbox management Python SDK (HTTP client for the k7 API)
|
|
5
|
+
Home-page: https://github.com/Katakate/k7
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: requests>=2.31.0
|
|
11
|
+
Provides-Extra: async
|
|
12
|
+
Requires-Dist: httpx>=0.27.0; extra == "async"
|
|
13
|
+
Provides-Extra: sdk-async
|
|
14
|
+
Requires-Dist: httpx>=0.27.0; extra == "sdk-async"
|
|
15
|
+
Dynamic: description
|
|
16
|
+
Dynamic: description-content-type
|
|
17
|
+
Dynamic: home-page
|
|
18
|
+
Dynamic: license
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
Dynamic: provides-extra
|
|
21
|
+
Dynamic: requires-dist
|
|
22
|
+
Dynamic: requires-python
|
|
23
|
+
Dynamic: summary
|
|
24
|
+
|
|
25
|
+
<h1 align="center">k7</h1>
|
|
26
|
+
|
|
27
|
+
<p align="center">
|
|
28
|
+
<b>Self-hosted secure VM sandboxes for AI compute at scale</b>
|
|
29
|
+
</p>
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
<p align="center">
|
|
33
|
+
<a href="https://katakate.org"><img src="https://img.shields.io/badge/website-katakate.org-orange"></a>
|
|
34
|
+
<a href="https://github.com/Katakate/k7/stargazers"><img src="https://img.shields.io/github/stars/Katakate/k7?style=social"></a>
|
|
35
|
+
<a href="https://docs.katakate.org">
|
|
36
|
+
<img src="https://img.shields.io/badge/docs-docs.katakate.org-orange" />
|
|
37
|
+
</a>
|
|
38
|
+
</p>
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
<p align="center">
|
|
42
|
+
<a href="https://news.ycombinator.com/item?id=45656952">
|
|
43
|
+
<img src="https://img.shields.io/badge/Show%20HN-%231%20🔥-orange" alt="Show HN #1">
|
|
44
|
+
</a>
|
|
45
|
+
<a href="assets/show-hn_nb1_post-id-45656952.png" title="Screenshot proof">📸</a>
|
|
46
|
+
<a href="https://console.dev">
|
|
47
|
+
<img src="https://img.shields.io/badge/Featured%20on-Console.dev-blue" alt="Featured on Console.dev">
|
|
48
|
+
</a>
|
|
49
|
+
<a href="assets/k7-console-dev.png" title="Screenshot proof">📸</a>
|
|
50
|
+
<a href="https://www.youtube.com/watch?v=2tgqzZvmbak">
|
|
51
|
+
<img src="https://img.shields.io/badge/GitHub%20Trending-Oct%2023%2C%202025-black?logo=github" alt="GitHub Trending (Oct 23, 2025)">
|
|
52
|
+
</a>
|
|
53
|
+
</p>
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
<p align="center">
|
|
57
|
+
<img src="assets/k7-cover-upgrade.png" alt="Katakate Logo" width="3600" style="vertical-align: middle;"/>
|
|
58
|
+
|
|
59
|
+
</p>
|
|
60
|
+
|
|
61
|
+
<p align="center">
|
|
62
|
+
<a href="https://deepwiki.com/Katakate/k7">
|
|
63
|
+
<img src="https://deepwiki.com/badge.svg" />
|
|
64
|
+
</a>
|
|
65
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/license-Apache%202.0-blue.svg"></a>
|
|
66
|
+
<img src="https://img.shields.io/badge/install%20with-apt-blue?logo=debian">
|
|
67
|
+
<img src="https://img.shields.io/pypi/v/k7-sdk">
|
|
68
|
+
</p>
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
<p align="center">
|
|
73
|
+
<img src="assets/demo-k7.gif" alt="K7 Demo" width="900"/>
|
|
74
|
+
</p>
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
<i><b>Katakate</b></i> aims to make it easy to create, manage and orchestrate lightweight safe VM sandboxes for executing untrusted code, at scale. It is built on battle-tested VM isolation with Kata, Firecracker, QEMU, Longhorn, and Kubernetes — plus Katakate's own <i><b>k7d</b></i> runtime. It is orignally motivated by AI agents that need to run arbitrary code at scale but it is also great for:
|
|
81
|
+
- Custom serverless (like AWS Fargate, but yours)
|
|
82
|
+
- Hardened CI/CD runners (no Docker-in-Docker risks)
|
|
83
|
+
- Blockchain execution layers for AI dApps
|
|
84
|
+
|
|
85
|
+
> <b>100% open‑source</b> (Apache‑2.0). For technical support, write us at: hi@katakate.org
|
|
86
|
+
|
|
87
|
+
<h3 align="left">
|
|
88
|
+
The Tech Stack
|
|
89
|
+
</h3>
|
|
90
|
+
|
|
91
|
+
<i><b>Katakate</b></i> is built on:
|
|
92
|
+
- <i><b>Kubernetes</b></i> for orchestration, with K3s which is prod-ready and a great choice for edge nodes,
|
|
93
|
+
- <i><b>Kata</b></i> to encapsulate containers into light-weight virtual-machines,
|
|
94
|
+
- <i><b>Firecracker</b></i> (`kfd`) for super-fast boots, light footprints and minimal attack surface (with the jailer),
|
|
95
|
+
- <i><b>Devmapper Snapshotter</b></i> with <i><b>thin-pool provisioning of logical volumes</b></i> for efficient disk use across many Firecracker VMs per node,
|
|
96
|
+
- <i><b>QEMU</b></i> (`kql`) via Kata when you want a fuller VMM and durable sandbox disks,
|
|
97
|
+
- <i><b>Longhorn</b></i> for replicated PVC-backed root disks on the QEMU path — named snapshots, restore, disk-only fork, and cross-node mobility,
|
|
98
|
+
- <i><b>k7d</b></i> — Katakate's own microVM runtime daemon (<a href="https://github.com/Katakate/k7d">katakate/k7d</a>) with VM-level warm fork (CoW disk+memory) and in-place pause/resume.
|
|
99
|
+
|
|
100
|
+
<h3 align="left">
|
|
101
|
+
Sandbox backends
|
|
102
|
+
</h3>
|
|
103
|
+
|
|
104
|
+
`k7 install --backend <kfd|kql|k7d>` provisions one or more backends per node; `k7 create --backend …` picks one per sandbox. See [docs/BACKENDS.md](docs/BACKENDS.md) for the architecture and [PERFORMANCE.md](PERFORMANCE.md) for the full measurements (Hetzner AX41 node, medians).
|
|
105
|
+
|
|
106
|
+
| | `kfd` (kata-firecracker-devmapper) | `kql` (kata-qemu-longhorn) | `k7d` |
|
|
107
|
+
|---|---|---|---|
|
|
108
|
+
| VMM | Firecracker (Kata) | QEMU (Kata) | k7d (custom KVM VMM) |
|
|
109
|
+
| RuntimeClass | `kata` | `kata-qemu` | `k7` |
|
|
110
|
+
| Sandbox storage | devmapper thin-pool (needs a spare raw disk) | Longhorn PVC (replicated, persistent) | erofs images + reflink XFS + guest tmpfs |
|
|
111
|
+
| Create → Ready* | not re-measured† | 17.1s | **2.1s** |
|
|
112
|
+
| Named snapshot* | — | 6.5s (Longhorn, disk-only) | — (VM snapshot trees via the k7d API) |
|
|
113
|
+
| Fork → usable* | — | 46.7s (disk clone + cold boot) | **~5 ms VM CoW fork**; **~2.4 s** end-to-end via k7/k8s (pod Ready + exec) |
|
|
114
|
+
| Pause / resume* | scale to 0 / 1 | 1.3s / 4.1s (disk survives) | **0.2s / 0.3s (VM frozen in place, memory survives)** |
|
|
115
|
+
| Docker-in-VM sidecar | ✅ (ephemeral docker data) | ✅ (persistent docker data; fastest `docker pull`) | ✅ (VM-lifetime docker data) |
|
|
116
|
+
| Cross-pod persistence | ✗ | ✅ snapshots/restore | ✗ (fork carries state instead) |
|
|
117
|
+
|
|
118
|
+
\* medians of 3 on one Hetzner AX41 node — methodology, ranges, and the docker-sidecar
|
|
119
|
+
numbers are in [PERFORMANCE.md](PERFORMANCE.md).
|
|
120
|
+
† kfd needs a spare raw disk the benchmark node didn't have; its docker-workload numbers
|
|
121
|
+
are in the [PERFORMANCE.md](PERFORMANCE.md) spec-10b section.
|
|
122
|
+
|
|
123
|
+
<h3 align="left">
|
|
124
|
+
Also available today
|
|
125
|
+
</h3>
|
|
126
|
+
|
|
127
|
+
- 🛠️ Docker <code>build</code> / <code>run</code> inside VM sandboxes (docker sidecar on <b>kfd</b>, <b>kql</b>, and <b>k7d</b>; see [PERFORMANCE.md](PERFORMANCE.md))
|
|
128
|
+
- ⚡ <b>Warm VM fork</b> on the k7d backend: <code>k7 fork</code> CoW-clones a running sandbox's disk <i>and memory</i> in ~5 ms at the VMM; end-to-end through k7/Kubernetes is ~2 s to a Ready pod
|
|
129
|
+
- 🌐 Multi-node clusters (Ansible + Longhorn)
|
|
130
|
+
- 🔍 Cilium CNI with FQDN egress policies
|
|
131
|
+
- 📸 Pause / resume / fork / restore and <code>k7 snapshot</code> lifecycle
|
|
132
|
+
- 🐍 Python SDK: <code>pip install k7-sdk</code> (<code>katakate</code> package deprecated)
|
|
133
|
+
|
|
134
|
+
📋 **See [ROADMAP.md](ROADMAP.md) for upcoming work (GPU passthrough, …).**
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
<p align="left" style="margin-top: 40px; font-size: 14px;">
|
|
138
|
+
<strong>Note:</strong> Katakate is currently in <em>beta</em> and under security review. Use with caution for highly sensitive workloads.
|
|
139
|
+
</p>
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
# Usage
|
|
143
|
+
|
|
144
|
+
For usage you need:
|
|
145
|
+
- **Node(s)** that will host the VM sandboxes
|
|
146
|
+
- **Client** from where to send requests
|
|
147
|
+
|
|
148
|
+
We provide a:
|
|
149
|
+
|
|
150
|
+
- **CLI**: to use on the node(s) directly --> `apt install k7`
|
|
151
|
+
- **API**: deployed automatically by `k7 install` (toggle with `k7 api enable` / `k7 api disable`)
|
|
152
|
+
- **Python SDK**: HTTP client sync/async --> `pip install k7-sdk`
|
|
153
|
+
|
|
154
|
+
## Current requirements
|
|
155
|
+
|
|
156
|
+
### For the node(s)
|
|
157
|
+
|
|
158
|
+
- Ubuntu (amd64 or arm64) host.
|
|
159
|
+
- **`k7d` backend is amd64 / x86_64 only** (same ISA; Debian calls it `amd64`,
|
|
160
|
+
the release tarball is `*-x86_64-linux.tar.gz`). `kfd` and `kql` support
|
|
161
|
+
amd64 and arm64.
|
|
162
|
+
- Hardware virtualization (KVM) available and accessible
|
|
163
|
+
- Check: `ls /dev/kvm` should exist.
|
|
164
|
+
- This is typically available on your own Linux machine.
|
|
165
|
+
- On cloud providers, it varies.
|
|
166
|
+
- Hetzner (the only one I tested so far) yes for their `Robot` instances only, i.e. "dedicated": robot.hetzner.com.
|
|
167
|
+
- AWS: only `.metal` EC2 instances.
|
|
168
|
+
- GCP: virtualization friendly, most instances, with `--enable-nested-virtualization` flag.
|
|
169
|
+
- Azure: Dv3, Ev3, Dv4, Ev4, Dv5, Ev5 (Intel/AMD x86) or Dpdsv5, Dpldsv5, Epsv5 (ARM64).
|
|
170
|
+
- DigitalOcean: Premium Intel and AMD droplets with nested virtualization enabled.
|
|
171
|
+
- Others: in general, hardware virtualization is not exposed on cloud VPS, so you'll likely want a dedicated / bare metal.
|
|
172
|
+
- One raw disk (unformatted, unpartitioned) for the thin-pool that k7 will provision for efficient disk usage of sandboxes.
|
|
173
|
+
- Use `./utils/wipe-disk.sh /your/disk` to wipe a disk clean before provisioning. DANGER: destructive - it will remove data/partitions/formatting/SWRAID.
|
|
174
|
+
- Ansible (for installer):
|
|
175
|
+
```bash
|
|
176
|
+
sudo add-apt-repository universe -y
|
|
177
|
+
sudo apt update
|
|
178
|
+
sudo apt install -y ansible
|
|
179
|
+
```
|
|
180
|
+
- Docker and Docker Compose (for the API):
|
|
181
|
+
```bash
|
|
182
|
+
curl -fsSL https://get.docker.com | sh
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Already tested setups:
|
|
186
|
+
- Hetzner Robot dedicated with Ubuntu 24.04 and a **spare raw NVMe** for the `kfd` thin-pool. Dual-NVMe boxes (no third drive): install the OS on one disk only — see [tutorials/k7_hetzner_node_setup.md](tutorials/k7_hetzner_node_setup.md). (Older PDF that assumed an add-on third NVMe: [tutorials/k7_hetzner_node_setup.pdf](tutorials/k7_hetzner_node_setup.pdf).)
|
|
187
|
+
|
|
188
|
+
### For the client
|
|
189
|
+
|
|
190
|
+
Recent Python, or the **`k7`** CLI / **`k7-sdk`** from a Linux node or your laptop (API URL + key).
|
|
191
|
+
|
|
192
|
+
#### Development on macOS
|
|
193
|
+
|
|
194
|
+
The **`.deb` / PPA package is Linux-only** (amd64/arm64). On a MacBook:
|
|
195
|
+
|
|
196
|
+
- **CLI from source:** `./src/k7/cli/dev.sh` (same commands as `k7`; uses `uv` + `PYTHONPATH=src`)
|
|
197
|
+
- **API client from laptop:** set `K7_API_URL` and `K7_API_KEY`, then `dev.sh create` / `dev.sh list` (no `--core`)
|
|
198
|
+
- **`k7 install`** targets Linux servers with KVM — run on the node or via SSH, not on macOS locally
|
|
199
|
+
- **`pip install k7-sdk`** for Python scripts only
|
|
200
|
+
|
|
201
|
+
Do not install the Ubuntu `.deb` on macOS.
|
|
202
|
+
|
|
203
|
+
## Quick Start
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
### Get your node(s) ready
|
|
207
|
+
|
|
208
|
+
First install `k7` on your Linux server that will host the VMs:
|
|
209
|
+
```shell
|
|
210
|
+
sudo add-apt-repository ppa:katakate.org/k7
|
|
211
|
+
sudo apt update
|
|
212
|
+
sudo apt install k7
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
Then let `k7` get your node ready with everything:
|
|
217
|
+
```console
|
|
218
|
+
$ k7 install
|
|
219
|
+
Current task: Reminder about logging out and back in for group changes
|
|
220
|
+
Installing K7 on 1 host(s)... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:41
|
|
221
|
+
✅ Installation completed successfully!
|
|
222
|
+
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Optionally pass `-v` for a verbose output.
|
|
226
|
+
|
|
227
|
+
> It will also tell you which raw disk was auto-selected for the LVM thin-pool. If you prefer, specify the disk explicitly (on a dual-NVMe Hetzner box this is usually the spare, e.g. `/dev/nvme1n1`):
|
|
228
|
+
> ```bash
|
|
229
|
+
> k7 install --disk /dev/nvme1n1
|
|
230
|
+
> ```
|
|
231
|
+
|
|
232
|
+
This will install and most importantly connect together the following components (depending on `--backend`):
|
|
233
|
+
- Kubernetes (K3s prod-ready distribution)
|
|
234
|
+
- Kata (for container virtualization)
|
|
235
|
+
- Firecracker + Jailer + devmapper thin-pool (`kfd`)
|
|
236
|
+
- QEMU via Kata + Longhorn PVC-backed roots (`kql`)
|
|
237
|
+
- k7d daemon + `containerd-shim-k7-v1` + RuntimeClass `k7` (`k7d`)
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
Careful design: config updates will not touch your existing Docker or containerd setups. We chose to use K3s' own containerd for minimal disruption. Installation may however overwrite existing installations of K3s, Kata, Firecracker, Jailer, QEMU/Kata config, or Longhorn.
|
|
241
|
+
|
|
242
|
+
### CLI Usage
|
|
243
|
+
|
|
244
|
+
You can run workloads directly from the node(s) using the CLI. To create a sandbox, just create a yaml config for it.
|
|
245
|
+
|
|
246
|
+
#### k7.yaml example:
|
|
247
|
+
|
|
248
|
+
```yaml
|
|
249
|
+
name: my-sandbox-123
|
|
250
|
+
image: alpine:latest
|
|
251
|
+
namespace: default
|
|
252
|
+
|
|
253
|
+
# Optional: restrict egress (safe pattern: whitelist only your own egress proxy IP)
|
|
254
|
+
egress_whitelist:
|
|
255
|
+
- "10.0.0.5/32" # Your private egress proxy/gateway
|
|
256
|
+
|
|
257
|
+
# Optional: resource limits
|
|
258
|
+
limits:
|
|
259
|
+
cpu: "1"
|
|
260
|
+
memory: "1Gi"
|
|
261
|
+
ephemeral-storage: "2Gi"
|
|
262
|
+
|
|
263
|
+
# Optional: run before_script inside the container once at start. Network restrictions apply after the before-script, so you can install packages here, pull git repos, etc
|
|
264
|
+
before_script: |
|
|
265
|
+
apk add --no-cache git curl
|
|
266
|
+
|
|
267
|
+
# Optional: load environment variables from a file. These will be available both during the before-script, and in the sandbox
|
|
268
|
+
env_file: path/to/your/secrets/.env
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
#### Running commands
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
# Create a sandbox (uses k7.yaml in the current directory by default, but you can also pass: -f myfile.yaml)
|
|
277
|
+
k7 create
|
|
278
|
+
|
|
279
|
+
# Or pick a backend explicitly (kfd | kql | k7d — aliases for the full names)
|
|
280
|
+
k7 create -f k7.yaml --backend k7d
|
|
281
|
+
|
|
282
|
+
# List sandboxes
|
|
283
|
+
k7 list
|
|
284
|
+
|
|
285
|
+
# Delete a sandbox
|
|
286
|
+
k7 delete my-sandbox-123
|
|
287
|
+
|
|
288
|
+
# Delete all sandboxes. You can also pass a namespace
|
|
289
|
+
k7 delete-all
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
#### Fork / pause / snapshot
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
# Warm CoW fork (disk + memory) — source must be a k7d sandbox
|
|
296
|
+
k7 create -f k7.yaml --backend k7d # name from yaml, e.g. my-sandbox-123
|
|
297
|
+
k7 exec my-sandbox-123 sh -c 'echo hi > /tmp/state.txt'
|
|
298
|
+
k7 fork my-sandbox-123 branch-a
|
|
299
|
+
k7 exec branch-a cat /tmp/state.txt # inherited memory + disk
|
|
300
|
+
|
|
301
|
+
# Disk-only fork (cold boot from cloned PVC) — kql / kata-qemu-longhorn
|
|
302
|
+
k7 create -f k7.yaml --backend kql
|
|
303
|
+
k7 fork my-sandbox-123 branch-b
|
|
304
|
+
# optional: pin the Longhorn VolumeSnapshot name used for the clone
|
|
305
|
+
k7 fork my-sandbox-123 branch-c --snapshot my-snap
|
|
306
|
+
|
|
307
|
+
# Parallel branches from one base
|
|
308
|
+
for i in $(seq 0 7); do k7 fork my-sandbox-123 exp-$i & done; wait
|
|
309
|
+
|
|
310
|
+
# Pause / resume (kql keeps the PVC; k7d freezes the live VM)
|
|
311
|
+
k7 pause my-sandbox-123
|
|
312
|
+
k7 resume my-sandbox-123
|
|
313
|
+
|
|
314
|
+
# Named disk snapshot without pausing (kql)
|
|
315
|
+
k7 snapshot create my-sandbox-123 my-named-snap
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
On **k7d**, the VMM fork itself is ~5 ms; end-to-end through Kubernetes
|
|
319
|
+
to a Ready pod is ~2 s. On **kql**, fork is a Longhorn snapshot + PVC
|
|
320
|
+
clone + cold boot (~45 s). See [PERFORMANCE.md](PERFORMANCE.md) and
|
|
321
|
+
[docs/BACKENDS.md](docs/BACKENDS.md).
|
|
322
|
+
|
|
323
|
+
### API usage
|
|
324
|
+
|
|
325
|
+
The K7 API is deployed automatically by `k7 install` as the `k7-api`
|
|
326
|
+
Deployment in `kube-system`. K3s keeps it running on its own; there's no
|
|
327
|
+
separate "start" step.
|
|
328
|
+
|
|
329
|
+
```shell
|
|
330
|
+
# Check status + endpoint
|
|
331
|
+
k7 api status
|
|
332
|
+
k7 api endpoint
|
|
333
|
+
|
|
334
|
+
# Generate API key
|
|
335
|
+
k7 generate-api-key my-key1
|
|
336
|
+
|
|
337
|
+
# Temporarily disable / re-enable
|
|
338
|
+
k7 api disable
|
|
339
|
+
k7 api enable
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
Generating / listing / revoking keys talks to `/etc/k7/api_keys.json`, so
|
|
343
|
+
those subcommands need to run on the node (typically `sudo` or `root`).
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
### Python SDK Usage
|
|
347
|
+
|
|
348
|
+
After your k7 API is up, usage is very simple.
|
|
349
|
+
|
|
350
|
+
Install the Python SDK via:
|
|
351
|
+
```shell
|
|
352
|
+
pip install k7-sdk
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
Or if you want async support:
|
|
356
|
+
```shell
|
|
357
|
+
pip install "k7-sdk[async]"
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
The legacy `katakate` PyPI name remains as a one-release shim that re-exports `k7_sdk` with a deprecation warning.
|
|
361
|
+
|
|
362
|
+
Then use with:
|
|
363
|
+
```python
|
|
364
|
+
from k7_sdk import Client
|
|
365
|
+
|
|
366
|
+
k7 = Client(
|
|
367
|
+
endpoint='https://<your-endpoint>',
|
|
368
|
+
api_key='your-key')
|
|
369
|
+
|
|
370
|
+
# Create sandbox (pick backend: kata-firecracker-devmapper | kata-qemu-longhorn | k7d)
|
|
371
|
+
sb = k7.create({
|
|
372
|
+
"name": "base",
|
|
373
|
+
"image": "alpine:latest",
|
|
374
|
+
"backend": "k7d",
|
|
375
|
+
})
|
|
376
|
+
|
|
377
|
+
# Execute code
|
|
378
|
+
result = sb.exec('echo "Hello World" > /tmp/hi.txt && cat /tmp/hi.txt')
|
|
379
|
+
print(result['stdout'])
|
|
380
|
+
|
|
381
|
+
# Fork: k7d = warm CoW (disk + memory); kql = disk clone + cold boot
|
|
382
|
+
branch = sb.fork("branch-a")
|
|
383
|
+
print(branch.exec("cat /tmp/hi.txt")["stdout"]) # still there on k7d
|
|
384
|
+
|
|
385
|
+
# Parallel exploration
|
|
386
|
+
forks = [sb.fork(f"exp-{i}") for i in range(4)]
|
|
387
|
+
|
|
388
|
+
# List / delete
|
|
389
|
+
sandboxes = k7.list()
|
|
390
|
+
sb.delete()
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
#### Async variant
|
|
394
|
+
```python
|
|
395
|
+
import asyncio
|
|
396
|
+
from k7_sdk import AsyncClient
|
|
397
|
+
|
|
398
|
+
async def main():
|
|
399
|
+
k7 = AsyncClient(
|
|
400
|
+
endpoint='https://<your-endpoint>',
|
|
401
|
+
api_key='your-key'
|
|
402
|
+
)
|
|
403
|
+
print(await k7.list())
|
|
404
|
+
await k7.aclose()
|
|
405
|
+
|
|
406
|
+
asyncio.run(main())
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
### Tutorials
|
|
411
|
+
|
|
412
|
+
- LangChain ReAct agent with a K7 sandbox tool
|
|
413
|
+
- Path: tutorials/langchain-react-agent
|
|
414
|
+
- Setup: copy .env.example to .env and fill K7_ENDPOINT/K7_API_KEY/OPENAI_API_KEY
|
|
415
|
+
- Run: python agent.py
|
|
416
|
+
- Try asking it anything! e.g. "List files from '/'"
|
|
417
|
+
|
|
418
|
+
## Build from source
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
First install make if not already available:
|
|
422
|
+
```bash
|
|
423
|
+
sudo add-apt-repository universe -y
|
|
424
|
+
sudo apt update
|
|
425
|
+
sudo apt install make
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
To build the `k7` CLI and API into `.deb` package:
|
|
430
|
+
```shell
|
|
431
|
+
make build
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
You can then install it with:
|
|
435
|
+
```shell
|
|
436
|
+
sudo make install
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
To uninstall later:
|
|
440
|
+
```shell
|
|
441
|
+
sudo make uninstall
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
Note: we recommend running `make uninstall` before reinstalling if it is not your first install, to avoid stale copies of cached files in the .deb package.
|
|
445
|
+
|
|
446
|
+
|
|
447
|
+
### Build and run the API container
|
|
448
|
+
|
|
449
|
+
Local dev image:
|
|
450
|
+
```bash
|
|
451
|
+
# Build the API image locally
|
|
452
|
+
make api-build-local
|
|
453
|
+
|
|
454
|
+
# Run API using local image (no pull)
|
|
455
|
+
make api-run-local
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
### Build the k7-sdk Python SDK from source
|
|
460
|
+
|
|
461
|
+
Preferred (uv):
|
|
462
|
+
|
|
463
|
+
```bash
|
|
464
|
+
# create env
|
|
465
|
+
uv venv .venv-build
|
|
466
|
+
. .venv-build/bin/activate
|
|
467
|
+
|
|
468
|
+
# install directly from source in editable mode
|
|
469
|
+
uv pip install -e .
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
## Security
|
|
474
|
+
|
|
475
|
+
K7 sandboxes are hardened by default with multiple layers of security:
|
|
476
|
+
|
|
477
|
+
- **VM isolation**: Kata Containers (Firecracker or QEMU) or the k7d RuntimeClass provide hardware-level isolation via lightweight VMs
|
|
478
|
+
- On `kfd`, Firecracker processes are further restricted into a chroot using the Jailer
|
|
479
|
+
- Kata's Seccomp restrictions are enabled on the Kata backends
|
|
480
|
+
- `kql` uses QEMU + Longhorn for durable, cross-node-mobile disks; `k7d` has its own CoW-fork isolation trade-offs (see k7d `SECURITY.md`)
|
|
481
|
+
|
|
482
|
+
- **Linux capabilities**: All capabilities are dropped by default (`drop: ALL`) for defense-in-depth
|
|
483
|
+
- Only explicitly add back capabilities you need via `cap_add` parameter
|
|
484
|
+
- `allow_privilege_escalation` is always set to `false`
|
|
485
|
+
- Seccomp profile: `RuntimeDefault`
|
|
486
|
+
|
|
487
|
+
- **Non-root execution**: Optionally run containers and pods as non-root user (UID 65532):
|
|
488
|
+
- `container_non_root`: Run the main container as non-root and disable privilege escalation
|
|
489
|
+
- `pod_non_root`: Run the entire pod as non-root with consistent filesystem ownership (UID/GID/FSGroup 65532)
|
|
490
|
+
|
|
491
|
+
- **API security**:
|
|
492
|
+
- API keys stored as SHA256 hashes with timing-attack-resistant comparison
|
|
493
|
+
- Expiry enforced; last-used timestamp recorded
|
|
494
|
+
- File-based storage with 600 permissions (`/etc/k7/api_keys.json` by default)
|
|
495
|
+
|
|
496
|
+
- **Network policies**: Complete network isolation for VM sandboxes
|
|
497
|
+
- **Ingress isolation**: All inter-VM communication is blocked by default to prevent sandbox-to-sandbox access
|
|
498
|
+
- **Egress lockdown**: per-sandbox allowlists — CIDRs via Kubernetes NetworkPolicy, or **FQDN / domain** allowlists via Cilium (`CiliumNetworkPolicy`; default CNI)
|
|
499
|
+
- **DNS is blocked** when egress is locked down; only entries in `egress_whitelist` (CIDR or domain) are reachable
|
|
500
|
+
- Administrative access via `kubectl exec` and `k7 shell` is preserved (uses Kubernetes API, not pod networking)
|
|
501
|
+
|
|
502
|
+
More security features are on the roadmap (e.g. AppArmor).
|
|
503
|
+
|
|
504
|
+
## Packaging & Releases
|
|
505
|
+
|
|
506
|
+
- Layout uses `src/`:
|
|
507
|
+
- CLI, API, core live under `src/k7/`
|
|
508
|
+
- SDK under `src/k7_sdk/` (PyPI package `k7-sdk`; `src/katakate/` is a deprecation shim)
|
|
509
|
+
- Root `setup.py` publishes the SDK; assets under `src/k7/` belong to the Debian CLI / API image, not the PyPI wheel.
|
|
510
|
+
- User docs: `~/docs/k7/` (Mintlify). See `docs/README.md` in this repo.
|
|
511
|
+
- The CLI Debian package is built via `src/k7/cli/build.sh` and produces `dist/k7_<version>_amd64.deb` and `dist/k7_<version>_arm64.deb`.
|
|
512
|
+
- CI (tags `v*`) can publish the PyPI SDK and upload the `.deb` artifact.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
k7_sdk/__init__.py,sha256=I1_tE4JG0IPN_ZxLMHbayaNgBMk6sq3pF_CQ_Um-2eM,198
|
|
2
|
+
k7_sdk/client.py,sha256=m_l-3TtkmErWinDTvYy_DtrwgQKDpdE-nvNVwoK0Gak,20951
|
|
3
|
+
k7_sdk-0.2.0.dist-info/licenses/LICENSE,sha256=Hp2KxCkjKstZxex7Q5HUfDHekGYqDCQzObK4G9L_taw,11346
|
|
4
|
+
katakate/__init__.py,sha256=laNubgO2CnBTkcDr4qkWn7Zllxj017h8yLlFTRPIVhI,400
|
|
5
|
+
k7_sdk-0.2.0.dist-info/METADATA,sha256=yZh9rApF6VpYJ9ZEleVUAzD33OzXWgetaZRh58OJtsE,19039
|
|
6
|
+
k7_sdk-0.2.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
7
|
+
k7_sdk-0.2.0.dist-info/top_level.txt,sha256=rHv5V3_UB_wnBAf4YfqLS4TgiYcGtwAhNAS9eXrQVqQ,16
|
|
8
|
+
k7_sdk-0.2.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Gary Becigneul
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
203
|
+
|
katakate/__init__.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""Deprecated compatibility shim — use ``k7_sdk`` (``pip install k7-sdk``)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import warnings
|
|
6
|
+
|
|
7
|
+
from k7_sdk import AsyncClient, Client, SandboxProxy
|
|
8
|
+
|
|
9
|
+
warnings.warn(
|
|
10
|
+
"The 'katakate' package is deprecated; pip install k7-sdk and use: from k7_sdk import Client",
|
|
11
|
+
DeprecationWarning,
|
|
12
|
+
stacklevel=2,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
__all__ = ["Client", "AsyncClient", "SandboxProxy"]
|