@computesdk/k8s
v0.2.3
Published
Kubernetes provider for ComputeSDK - run sandboxes as pods
Maintainers
Readme
@computesdk/k8s
Kubernetes provider for ComputeSDK.
Run each sandbox as a Pod in your cluster, execute code/commands with pods/exec, and expose app ports through a Service.
Installation
npm install @computesdk/k8sQuick Start
import { k8s } from '@computesdk/k8s';
const compute = k8s({
namespace: 'default',
runtime: 'node',
});
const sandbox = await compute.sandbox.create();
const result = await sandbox.runCommand('node -e "console.log(\"hello from k8s\")"');
console.log(result.stdout);
await sandbox.destroy();Configuration
interface K8sConfig {
kubeConfigPath?: string;
kubeConfigRaw?: string;
context?: string;
namespace?: string;
image?: string;
runtime?: 'node' | 'python';
timeout?: number;
podNamePrefix?: string;
urlTemplate?: string;
}Kubeconfig loading precedence:
kubeConfigRawKUBECONFIG_B64(base64-encoded kubeconfig)kubeConfigPath- default kubeconfig resolution
Notes
- Sandboxes are labeled with
computesdk.io/managed=true. getUrlis template-based in this MVP. SeturlTemplate(for example via your gateway/ingress pattern) to return a routable URL.
