Cloud Native Rejekts EU (Valencia) 2022

Reverse K8s resources: from YAML to Go stucts
05-15, 17:30–17:35 (Europe/Madrid), Main Room

In the Kubernetes world, it is a common use case to convert API resources written in Go to YAML manifests for further distribution whether as part of helm chart, kustomize template or other tools. How hard can it be to go the other way around, take a YAML manifest and generate a valid Go code from that? This session looks at Kubernetes codecs, scheme, Go reflections, and Go AST parsers from a little unusual perspective.


This session can help drive a little more interest into lower levels of Kubernetes apimachinery and provide alternative use cases for standard Kubernetes components.

At Kubermatic, we have a use for custom controllers encapsulating open-source Kubernetes applications distributed by helm charts. The original workflow we had was to reimplement the resources from rendered helm chart as go structures for additional safety provided by static types, wrap around our generic controllers and build. The pattern to generate the go code from YAML manifests instead of manually maintaining aims to reduce the tedious and not so fun part of the workflow.

Jan Wozniak is a software engineer at Kubermatic. Throughout his career, he contributed to various parts of the Kubernetes ecosystem as well as few Erlang based opensource projects.