We know how boring and time-consuming it is to map K8s resource YAML into an unstructured object. Here is a tool to auto-generate dynamic client go code

This page summarizes the projects mentioned and recommended in the original post on /r/kubernetes

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • kyaml2go

    K8s Go client code generator from Kubernetes resource yamls

  • kyaml2go generated Go code for equivalent kubectl operations on k8s resource. It can generate code with the typed client and dynamic client. We don't have to figure out which k8s packages to import and waste time in populating the resource objects. You can give it a try at: https://kyaml2go.prasadg.dev. Whereas, https://github.com/mholt/json-to-go is totally different tool for different use case. It generated Go type definitions (structs) from JSON. But for K8s resources, we don't have to generate Go type as they are already defined in the `k8s.io/api` packages. kyaml2go helps you finding correct packages and populate the struct as per the yaml specs and call correct methods to manage the resource.

  • JSON-to-Go

    Translates JSON into a Go type in your browser instantly (original)

  • kyaml2go generated Go code for equivalent kubectl operations on k8s resource. It can generate code with the typed client and dynamic client. We don't have to figure out which k8s packages to import and waste time in populating the resource objects. You can give it a try at: https://kyaml2go.prasadg.dev. Whereas, https://github.com/mholt/json-to-go is totally different tool for different use case. It generated Go type definitions (structs) from JSON. But for K8s resources, we don't have to generate Go type as they are already defined in the `k8s.io/api` packages. kyaml2go helps you finding correct packages and populate the struct as per the yaml specs and call correct methods to manage the resource.

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

    SurveyJS logo
  • controller-utils

  • For a working example, you can take a look at https://github.com/coderanger/controller-utils/blob/main/components/template.go and the code pulled in from there (ignore that it uses vfsgen instead of go:embed, this code predates go:embed being available, same idea though).

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts