📚 Documentation • 💬 Discord • 🚀 Getting Started
TypeKro is a TypeScript-first framework for orchestrating Kubernetes resources with type safety and runtime intelligence. Write infrastructure in pure TypeScript with full IDE support, then deploy directly to clusters or generate deterministic YAML for GitOps workflows.
bun add typekro arktypeimport { type } from 'arktype';
import { kubernetesComposition } from 'typekro';
import { Deployment, Service } from 'typekro/simple';
// Define a reusable WebApp composition
const WebApp = kubernetesComposition({
name: 'webapp',
apiVersion: 'example.com/v1',
kind: 'WebApp',
spec: type({ name: 'string', image: 'string', replicas: 'number' }),
status: type({ ready: 'boolean', endpoint: 'string' })
}, (spec) => {
const deploy = Deployment({ id: 'app', name: spec.name, image: spec.image, replicas: spec.replicas });
const svc = Service({ id: 'svc', name: `${spec.name}-svc`, selector: { app: spec.name }, ports: [{ port: 80 }] });
return {
ready: deploy.status.readyReplicas > 0, // ✨ JavaScript → CEL
endpoint: `http://${svc.status.clusterIP}` // ✨ Template → CEL
};
});
// Deploy multiple instances with a simple loop
const apps = [
{ name: 'frontend', image: 'nginx', replicas: 3 },
{ name: 'api', image: 'node:20', replicas: 2 }
];
const factory = WebApp.factory('direct', { namespace: 'production' });
for (const app of apps) await factory.deploy(app);What this demonstrates:
- Reusable compositions - Define once, deploy many times
- Type-safe schemas - ArkType validates at compile-time and runtime
- Cross-resource references -
svc.status.clusterIPreferences live cluster state - JavaScript-to-CEL - Status expressions become runtime CEL
- Native loops - Just
for...ofto deploy multiple apps
| Feature | TypeKro | Pulumi | CDK8s | Helm |
|---|---|---|---|---|
| Type Safety | ✅ Full TypeScript | ✅ Multi-lang | ✅ TypeScript | ❌ Templates |
| GitOps Ready | ✅ Deterministic YAML | ❌ State backend | ✅ YAML output | ✅ Charts |
| Runtime Refs | ✅ CEL expressions | ❌ Deploy-time | ❌ Static | ❌ Templates |
| Learning Curve | 🟢 Just TypeScript | 🔴 New concepts | 🟡 TS + K8s | 🔴 Templates |
| Stateless | ✅ | ❌ State backend | ✅ | ✅ |
| Cross-Resource | ✅ Runtime resolution | ❌ Deploy-time | ❌ Manual | ❌ Manual |
TypeKro supports multiple deployment strategies from the same code:
// 1. Direct deployment - immediate, no Kro required
const factory = graph.factory('direct', { namespace: 'dev' });
await factory.deploy(spec);
// 2. Kro deployment - runtime CEL evaluation
const kroFactory = graph.factory('kro', { namespace: 'prod' });
await kroFactory.deploy(spec);
// 3. YAML generation - GitOps workflows
const yaml = kroFactory.toYaml();
writeFileSync('k8s/app.yaml', yaml);const AppSpec = type({
name: 'string',
image: 'string',
replicas: 'number',
'environment?': '"dev" | "staging" | "prod"'
});const db = Deployment({ id: 'database', name: 'postgres', image: 'postgres:15' });
const api = Deployment({
id: 'api',
name: 'api-server',
image: 'node:20',
env: {
DB_HOST: db.metadata.name // Runtime reference
}
});Write natural JavaScript - TypeKro converts to CEL:
return {
ready: deploy.status.readyReplicas > 0, // → ${app.status.readyReplicas > 0}
url: `http://${svc.status.clusterIP}`, // → http://${svc.status.clusterIP}
phase: deploy.status.phase === 'Running' ? 'up' : 'down'
};import { helmRelease, helmRepository } from 'typekro';
const repo = helmRepository({
name: 'bitnami',
url: 'https://charts.bitnami.com/bitnami'
});
const release = helmRelease({
name: 'nginx',
repository: repo,
chart: 'nginx',
values: {
replicaCount: spec.replicas // Type-safe values
}
});import { yamlFile } from 'typekro';
const existing = yamlFile({
path: './k8s/existing-deployment.yaml',
namespace: 'default'
});TypeKro provides 50+ factory functions for Kubernetes resources:
Workloads: Deployment, StatefulSet, DaemonSet, Job, CronJob
Networking: Service, Ingress, NetworkPolicy
Config: ConfigMap, Secret
Storage: PersistentVolumeClaim, PersistentVolume, StorageClass
RBAC: ServiceAccount, Role, RoleBinding, ClusterRole, ClusterRoleBinding
Kubernetes Resource Orchestrator (Kro) is an open-source project by AWS Labs that enables resources to reference each other's runtime state using CEL expressions.
TypeKro works in Direct Mode (no Kro required) for simple deployments, or Kro Mode for advanced orchestration with runtime dependencies.
- Getting Started - 5-minute quick start
- Core Concepts - kubernetesComposition API
- API Reference - Complete API documentation
- Examples - Real-world patterns
# Using bun (recommended)
bun add typekro arktype
# Using npm
npm install typekro arktype
# Using yarn
yarn add typekro arktype- Node.js 18+ or Bun
- TypeScript 5.0+
- Kubernetes cluster (for deployment)
- Kro controller (optional, for runtime features)
We welcome contributions! See CONTRIBUTING.md for guidelines.
# Clone the repository
git clone https://github.com/yehudacohen/typekro.git
cd typekro
# Install dependencies
bun install
# Run tests
bun run test
# Build
bun run buildApache 2.0 - See LICENSE for details.