livecycle / deploykit

A Deno toolkit for generating deployment configuration files based on Typescript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Deploykit

A Deno based toolkit for generating deployment configuration files using typescript with focus on k8s resources.
Inspired by Pulumi, JKCfg, ts-kubernetes-models, CDK, Helm and others...

** This project is in very early and experimental stage

Quick example

deploy.ts (./examples/deploy.ts)

import { createMicroservice } from "https://deno.land/x/deploykit@0.0.24/blueprint/k8s/app.ts";
import {
  addDeployment,
  addService,
  expose,
} from "https://deno.land/x/deploykit@0.0.24/blueprint/k8s/operators/all.ts";

createMicroservice().with(
  addDeployment({ image: "my-image" }),
  addService({ port: 80 }),
  expose({ domain: "my-app.com" }),
).dump(
  { name: "my-app", namespace: "my-namespace", labels: { app: "my-app" } },
);

Run deno run https://raw.githubusercontent.com/Yshayy/deploykit/master/examples/deploy.ts

Output
apiVersion: extensions/v1beta1
kind: Ingress
spec:
  rules:
    - host: my-app.com
      http:
        paths:
          - backend:
              serviceName: my-app
              servicePort: 80
metadata:
  name: my-app
  namespace: my-namespace
  labels:
    app: my-app
---
apiVersion: v1
kind: Service
spec:
  ports:
    - port: 80
      targetPort: 80
metadata:
  name: my-app
  namespace: my-namespace
  labels:
    app: my-app
---
apiVersion: apps/v1
kind: Deployment
spec:
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
        - name: app
          image: my-image
metadata:
  name: my-app
  namespace: my-namespace
  labels:
    app: my-app

Usage with kubectl:
deno run ./deploy.ts | kubectl apply -f -

Why Deno?

Deno brings back some of the script-y aspects of JS and the web, but with the safety of Typescript. It has several advantages such as:

  • No need for typescript toolchain (tsc, prettier, etc...)
  • No need to manage dependencies or package.json or deployment project folder
  • Easy to publish, import and share code pieces (blueprint/operators/scripts)
  • Sandboxed security - scripts can output configuration files and nothing more

These capabilies allow us to easily create a single deploy.ts file that is easy to manage, execute, extend, integrate in CI/CD.

Why Typescript

TBD

What's Inside

  • generated/k8s - TS definitions for all k8s native resourcesn based on k8s OpenAPI defintions, some CRDs are also imported. (crds are defined here)
  • generators/openapi - library for generating TS files from open-api and CRD files currently tailored to k8s.
  • blueprint - Library for creating, sharing and reusing high level abstractions of deployments
  • blueprint/k8s - Base blueprint factory and operators for creating and manipulating common k8s resources

Compared to other solutions

TBD

Roadmap

TBD

About

A Deno toolkit for generating deployment configuration files based on Typescript

License:MIT License


Languages

Language:TypeScript 100.0%Language:Dockerfile 0.0%Language:Shell 0.0%