Kube Code Generator Save

Kubernetes code generator docker image

Project README

Kube code generator

Kubernetes release

Introduction

When we speak about Kubernetes operators or controllers, normally Go code, CR, CRDs... are required. To create all the autogenerated Kubernetes Go code (Clients, helpers...) and manifests (CRD), the process is a bit painful.

This small project tries making easy this process, by creating a small layer between Kubernetes official tooling that are used to get all this autogenerated stuff, and abstract options and infer some others, making a better UX for the user.

The projects that are used under the hood are:

Why and when use this

  • You don't like, need or use kubebuilder for your CRDs.
  • You want simple tooling to generate Kubernetes CRD Go clients and manifests.
  • You like safe standards and simple things.
  • You use CRDs for more/other things than operators (e.g: generating CLIs, storing state on k8s as APIs...).
  • You don't want to do hacky and ugly stuff to start creating Kubernetes tooling.

Features

  • Small API/configuration.
  • Safe standards
  • Ready to use Docker images.
  • Generates Go code like clients and informers (Used to implement operators, CLIs...).
  • Generates CRD manifests (Used for API registration on k8s clusters).

How to use it

The easiest way is to use the provided Docker image as it has all the required upstream dependencies.

Here is an example that mounts the current directory (a Go project) and generates the Go code and the CRDs by providing the APIs input directory and the generation output directories:

docker run -it --rm -v ${PWD}:/app ghcr.io/slok/kube-code-generator \
 --apis-in ./apis \
 --go-gen-out ./gen \
 --crd-gen-out ./gen/manifests

However, the best way to know how to use it is with a full example, you have it in _example dir.

Kubernetes versions

It's suggested that if you don't have an old Kubenretes version, you try the latest kube-code-generator (latest), however the ones described on the table here are known to work correctly on the specific version.

Kubernetes Docker image
v1.30 docker pull ghcr.io/slok/kube-code-generator:v0.2.0
v1.29 docker pull ghcr.io/slok/kube-code-generator:v0.2.0
v1.28 docker pull ghcr.io/slok/kube-code-generator:v0.2.0
v1.27 docker pull ghcr.io/slok/kube-code-generator:v0.2.0

Versions <v1.27

With the release of Kubernetes v1.30, this app was rewritten from bash hacky scripts into a proper Go application, that is easier, more extendable and safer to use.

In case you tested this new refactor and isn't working for you, Inwould suggest to try the previous versions, check the previous Readme.

Open Source Agenda is not affiliated with "Kube Code Generator" Project. README Source: slok/kube-code-generator

Open Source Agenda Badge

Open Source Agenda Rating