Skip to content
/ k8skonf Public

Kubernetes in Typescript. Like CDK8s / Helm but simpler.

License

Notifications You must be signed in to change notification settings

konfjs/k8skonf

Repository files navigation

k8skonf

Kubernetes in Typescript. Like CDK8s / Helm but simpler.

Usage

Source

import { K8sApp } from '@k8skonf/core';
import { Deploymentv1 } from '@k8skonf/core/Deploymentv1';

const app = new K8sApp('my-k8s-app');

new Deploymentv1(app, 'my-nginx-deployment', {
    spec: {
        selector: {
            matchLabels: {
                app: 'nginx',
            },
        },
        template: {
            metadata: {
                labels: {
                    app: 'nginx',
                },
            },
            spec: {
                containers: [
                    {
                        name: 'nginx',
                        image: 'nginx:alpine',
                        ports: [
                            {
                                containerPort: 80,
                                name: 'http',
                            },
                        ],
                    },
                ],
            },
        },
    },
});

app.save();

Output

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-nginx-deployment
spec:
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
        - name: nginx
          image: nginx:alpine
          ports:
            - containerPort: 80
              name: http

CRDs

Usage:

npx @k8skonf/cli "https://raw.githubusercontent.com/argoproj/argo-cd/refs/tags/v2.13.2/manifests/crds/appproject-crd.yaml"