Giter VIP home page Giter VIP logo

rekube's Introduction

RE:KUBE PROJECT

React renderer for Kubernetes configurations.
JSX instead of clumsy YAML, declarative and type-safe configurations.

Why Rekube?

  1. Leverage programming:
    Use variables, functions, type-safety, conditional rendering, etc.

  2. Leverage React:
    Context aware configurations, Reusable components, Package ecosystem

Before you start

Install node if you don't have it already.

As option, install one of the following package managers:

Getting started

  1. Init the project

    mkdir /your/project
    cd /your/project
    npm init # You could use pnpm or yarn if you prefer
  2. 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
  3. 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>
            </>
        );
    }
  4. 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 -

Publishing your Rekube packages on npm

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.

Generating Rekube Components out of yaml file

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

Contributing

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.

rekube's People

Contributors

cah4a avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

rekube's Issues

Add external configuration.

I just had the same idea for using react components to model k8s resources and found your repo. Great work!

I think to step more in the foots of Helm, there should be a way to add external configuration.

The developer could define a schema for it's configuration with Zod or something similar.
With something like npx rekube -c prod-config.json an external configuration could be laoded. The external configuration could be toml, json, yaml or pkl and is validated against the Zod schema.

It is then provided as props for the root component or in some other way so it can be used by the resource components.

Pnpm install `ERR_PNPM_WORKSPACE_PKG_NOT_FOUND`

``Steps to reproduce:

  1. clone the repo
  2. pnpm i

Error:

Scope: all 5 workspace projects
/Users/1cedsoda/code/rekube/example:
 ERR_PNPM_WORKSPACE_PKG_NOT_FOUND  In example: "@rekube/components@workspace:" is in the dependencies but no package named "@rekube/components" is present in the workspace

This error happened while installing a direct dependency of /Users/1cedsoda/code/rekube/example

Packages found in the workspace: @rekube/codegen, rekube-example, @rekube/base, @rekube/converter, rekube

Provide a way to use helm charts

Something like the following will be a nice way to utilize battle-tested helm charts:

<HelmChart 
    repo="bitnami/wordpress"
    name="happy-panda"
    values={...}
/>

It will coordinate poorly with Rekube components but is a way to reuse Helm ecosystem.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.