---
# System prepended metadata

title: Beyond Kubebuilder -  Generating entire kubeneretes controller implementation

---

# Beyond Kubebuilder -  Generating entire kubeneretes controller implementation

Jay Pipes, Amine Hilaly - AWS

Wednesday 28 October 2022

KubeCon Detroit MI, USA

---

## Outline

- Background - 30 seconds
- Controller concept - 1minute
- Native k8s controllers examples (`ReplicasSet`/`Deployment`) - 30seconds
- Custom Controllers, the what why and how - 1 minute
    - talk about related concept of an "Operator", which generally is a custom controller and the CRDs
- Current tooling (`Kubebuilder`, `controller-gen`, `operator-framework`...) - 2 mins
    - Want to learn about using these tools? Come to workshop with Amine and Weave folks :)
- Generators responsability (skeletton controller) vs Developer responsability (Logic, conditions etc...) - 2 min
- ACK and the 200+ AWS services (why we don't/shoudn't manually write our controllers) - 2 min
- From API Definition schema to Controller implementation - 20 mins
    - Show the generation pipeline diagram
  - Detecting possible CRDs (Create operations) (`ack-generate`)
  - Infering Spec and Status fields (`ack-generate`)
  - Generating `zz_deepcopy` and `crd`definition files (`kubebuilder` + `controller-gen`)
  - Runtime and common utilities (One generic reconcile loop, defined set of conditions etc...), # talk about runtime Interface types 
  - Generating interface implementations (`pkg/${resource}`/`sdk.go`/`delta.go` etc...)
  - Generating helm charts
- Some lessons learned
    - APIReader vs clientCache
    - Need to understand difference between Update and Patch
    - Understanding revision versus resourceVersion
    - CRs don't automatically "requeue", there is a cache flush but that's not same thing


---
  ++ Nice to haves
  - Why Go made it easier to generate code? probably for same reasons kubernetes is written in Go
  - Generating attributions.md
  - Prow automation to regenerate code
  - Generation cycle

NOTES 11 oct 2022

- We should add lessons learned
- there is no way to save just the status or just the spec.
- APIReader vs clientCache


Diagrams https://github.com/aws-controllers-k8s/community/blob/main/docs/content/docs/contributor-docs/code-generation.md