React renderer for Kubernetes configurations.
JSX instead of clumsy YAML, declarative and type-safe configurations.
-
Leverage programming:
Use variables, functions, type-safety, conditional rendering, etc. -
Leverage React:
Context aware configurations, Reusable components, Package ecosystem
Install node if you don't have it already.
As option, install one of the following package managers:
-
Init the project
mkdir /your/project cd /your/project npm init # You could use pnpm or yarn if you prefer
-
Add Rekube base components package to the project:
npm install -D rekube @rekube/base
or
pnpm install -D rekube @rekube/base yarn add -D rekube @rekube/base
-
Create a file
k8s.tsx
with the following content:import { Deployment } from "@rekube/base/apps/v1"; import { Container, ContainerPort, PodTemplateSpec, Service, ServicePort } from "@rekube/base/core/v1"; export default function App() { const labels = { app: "nginx" }; return ( <> <Deployment meta:name="nginx" replicas={3} selector={{ matchLabels: labels }} > <PodTemplateSpec meta:labels={labels}> <Container name="nginx" image="nginx:1.14.2"> <ContainerPort containerPort={80} /> </Container> </PodTemplateSpec> </Deployment> <Service meta:name="nginx-svc" selector={{ labels }}> <ServicePort port={80} targetPort={80} protocol="TCP" /> </Service> </> ); }
-
Run
rekube
cli in the project directory.It will render the k8s.tsx file to stdout:
npx rekube npx rekube ./other/file.tsx npx rekube > k8s.yaml
or pipe it directly to kubectl:
npx rekube | kubectl apply -f -
Rekube utilizes the npm ecosystem.
You can publish your Rekube components just like any other npm package.
Moreover, Rebuke includes a built-in transpiler that enables you to directly publish tsx/jsx
files.
Rekube includes a built-in transpiler that enables you to directly convert yaml
files to tsx
files.
npx rekube convert ./path/to/your/file.yaml
Any contribution is welcome. Either it's a bug report, a feature request, or a pull request. Reach me out if you have any questions or need help with anything.