Go for Control-Plane Development
The subset of Go that matters when you are writing controllers, admission webhooks, and platform APIs — context propagation, the error model, concurrency failure modes, and production diagnostics.
Overview
Go for control-plane software
This topic is not a Go tutorial. It is the slice of Go you get asked about when the job is writing control-plane software: operators, admission webhooks, platform APIs and CLI tooling that talks to the Kubernetes API. It assumes you can write a loop and a struct, and explains the model behind the idioms in controller-runtime, client-go and Terraform providers.
A control-plane process is mostly a loop that observes remote state, compares it with desired state and issues remote writes. Every pass of that loop goes the same way.
- Observe the remote state.
- Check whether it matches the desired state. If it does, go back to step 1 and keep observing.
- If it does not, issue remote writes, then go back to step 1.
Three Go features sit on that loop. A context.Context carries cancellation and a deadline into every remote write. Goroutines and channels run many of these loops at once. Error values make failure explicit at the point where the loop checks state.
Key concepts
- context.Context
- Goroutine
- select
- Error wrapping
- Accept interfaces, return structs
- Struct tags
- Race detector
- pprof
Interview questions
- Explain context.Context and how it flows through a controller. What actually breaks if you ignore it?
- How does Go error handling work in a control-plane service, and when is panic acceptable?
- Walk me through the concurrency bugs that actually bite in controllers and how you find them.
- A controller pod has been running for three days and its RSS has grown from 80 MB to 1.4 GB. Walk me through diagnosing it in place.
- Implement graceful shutdown for a Go service that serves HTTP, runs background workers, and holds a leader-election lease.
- How would you structure and test a Go control-plane package so it is actually testable?
Sign up free to read the full topic
More DevOps topics
Start free on Cariara · Coding problems · System design studio