Skip to main content

Organize Kubernetes manifests in JavaScript.

Get StartedPlayground
npm install kosko -g

Write Less

Reuse variables, functions or any JavaScript libraries. Write Kubernetes manifests with less code. Eliminate duplicated YAML snippets here and there.

const labels = { app: "my-app" };
apiVersion: apps/v1
kind: Deployment
spec:
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
apiVersion: v1
kind: Service
metadata:
name: my-app
spec:
selector:
app: my-app
ports:
- port: 80
targetPort: 8080

Deploy Everywhere

Stop copy and paste when deploying to a new Kubernetes cluster. In Kosko, manifests are split into components and environments. It's faster to create a new environment file than copy and modify existing YAML files.

nginx.js
prod.js
stage.js
const env = require("@kosko/env");
const params = env.component("nginx");
module.exports = new Deployment({
metadata: {
name: "nginx",
namespace: params.namespace
},
spec: {
replicas: params.replicas,
template: {
spec: {
containers: [
{
name: "nginx",
image: params.image
}
]
}
}
}
});
Prod
Stage
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
namespace: prod
spec:
replicas: 15
template:
spec:
containers:
- name: nginx
image: nginx:stable

Type Safe

Kosko automatically validates manifests against Kubernetes OpenAPI schema, which helps you locate issues before applying to clusters.

With TypeScript support, you can get type definitions, documentation, autocomplete suggestions and more right in your editors.

new Deployment({
metadata: {
name: "my-app"
},
spec: {
replicas:
"wrong_replicas"
(property) IDeploymentSpec["replicas"]?: number
Number of desired pods. This is a pointer to distinguish between explicit zero and not specified. Defaults to 1.
,
selector: {
matchLabels: {
app: "my-app"
}
}
}
});
Type 'string' is not assignable to type 'number'.
ts(2322)