Sign inSign up

slok/kube-code-generator

By slok

•Updated almost 8 years ago

Kubernetes code generator image

Image
0

1.5K

slok/kube-code-generator repository overview

⁠Kube code generator Docker Repository on Quay

A kubernetes code generator ready container to create your CRD autogenerated code like clients or openapi specs.

This uses the official util⁠ created by Kubernetes to autogenerate the code required by Kubernetes resources.

⁠Kubernetes type code generation

⁠Env vars required
  • PROJECT_PACKAGE: The project package path.
  • CLIENT_GENERATOR_OUT: The client generated out path.
  • APIS_ROOT: The path where our API/resources are.
  • GROUPS_VERSION: The groups of the resources.
  • GENERATION_TARGETS: The wanted generated code. [(deepcopy,defaulter,client,lister,informer) or "all"].
⁠Process

Having a project that would be on github.com/someone/myproject, wants to generate the client on github.com/someone/myproject/client, has its resources on github.com/someone/myproject/apis, has the resources github.com/someone/myproject/apis/test/v1alpha1 and github.com/someone/myproject/apis/test2/v1 and wants only deepcopy and client autogenerated code this would be:

PROJECT_PACKAGE=github.com/someone/myproject && \
docker run -it --rm \
    -v ${PWD}:/go/src/${PROJECT_PACKAGE}\
    -e PROJECT_PACKAGE=${PROJECT_PACKAGE} \
    -e CLIENT_GENERATOR_OUT=${PROJECT_PACKAGE}/client \
    -e APIS_ROOT=${PROJECT_PACKAGE}/apis \
    -e GROUPS_VERSION="test:v1alpha1 test2:v1" \
    -e GENERATION_TARGETS="deepcopy,client" \
    quay.io/slok/kube-code-generator

⁠Kubernetes type openapi spec generation

⁠Env vars required
  • CRD_PACKAGES: The packages where all the CRD types are (comma separated).
  • OPENAPI_OUTPUT_PACKAGE: The output package where the open api spec will be created.
⁠Process

Having a project that would be on github.com/someone/myproject, wants to generate the openapi spec for its types on github.com/someone/myproject/openapi, has its resources on github.com/someone/myproject/apis, has the resources github.com/someone/myproject/apis/test/v1alpha1 and github.com/someone/myproject/apis/test2/v1 autogenerated spec this would be:

PROJECT_PACKAGE=github.com/someone/myproject && \
docker run -it --rm \
    -v ${PWD}:/go/src/${PROJECT_PACKAGE}\
    -e CRD_PACKAGES=${PROJECT_PACKAGE}/apis/test/v1alpha1,${PROJECT_PACKAGE}/apis/test2/v1 \
    -e OPENAPI_OUTPUT_PACKAGE=${PROJECT_PACKAGE}/openapi \
    quay.io/slok/kube-code-generator ./update-openapi.sh

⁠Example

You have a project example in example⁠ path.

Tag summary

Content type

Image

Digest

Size

312.7 MB

Last updated

almost 8 years ago

docker pull slok/kube-code-generator