In Kubernetes, operators allow the API to be extended to your heart content. If one task requires too much YAML, it’s easy to create an operator to take care of the repetitive cruft, and only require a minimum amount of YAML.
On the other hand, since its beginnings, the Go language has been advertised as closer to the hardware, and is now ubiquitous in low-level programming. Kubernetes has been rewritten from Java to Go, and its whole ecosystem revolves around Go. For that reason, It’s only natural that Kubernetes provides a Go-based framework to create your own operator. While it makes sense, it requires organizations willing to go down this road to have Go developers, and/or train their teams in Go. While perfectly acceptable, this is not the only option. In fact, since Kubernetes is based on REST, why settle for Go and not use your own favorite language?
In this talk, I’ll describe what is an operator, how they work, how to design one, and finally demo a Java-based operator that is as good as a Go one.
2. @nicolas_frankel
Me, myself and I
Former developer, team lead, architect,
blah-blah
Developer Advocate
Interested in better and faster delivery
Curious about Kubernetes
3. @nicolas_frankel
Hazelcast
HAZELCAST IMDG is an operational,
in-memory, distributed computing
platform that manages data using
in-memory storage, and performs
execution for breakthrough
and scale.
HAZELCAST JET is the ultra
fast, application embeddable,
3rd generation stream
processing engine for low
latency batch and stream
processing.
6. @nicolas_frankel
Kubernetes API Server
“The Kubernetes API server validates and
configures data for the api objects which
include pods, services, replication
controllers, and others. The API Server
services REST operations and provides
the frontend to the cluster’s shared state
through which all other components
interact.”
8. @nicolas_frankel
Controllers
“In Kubernetes, controllers are control
loops that watch the state of your cluster,
then make or request changes where
needed. Each controller tries to move the
current cluster state closer to the desired
state.”
10. @nicolas_frankel
Where are controllers located?
Out-of-the-box controllers run in the
control plane
Custom controllers can run anywhere
• As a Pod (or multiple Pods) inside the
cluster
• As anything outside the cluster
11. @nicolas_frankel
Operator vs. controller
“An Operator is an application-specific
controller that extends the Kubernetes
API to create, configure and manage
instances of complex stateful applications
on behalf of a Kubernetes user. It builds
upon the basic Kubernetes resource and
controller concepts, but also includes
domain or application-specific
knowledge to automate common tasks
better managed by computers.”
12. @nicolas_frankel
Custom Resource Definition
“Defining a CRD object creates a new
custom resource with a name and schema
that you specify. The Kubernetes API
serves and handles the storage of your
custom resource.”
14. @nicolas_frankel
Operator vs. controller
To simplify, an operator is just a
controller that manages a CRD
If you know how to develop a controller,
you know how to develop an operator
15. @nicolas_frankel
The technology stack of controllers
Must “talk” to the API server
REST-based
One can create a controller using the
shell only
17. @nicolas_frankel
Why not Go?
varFoo, err := GetFoo()
if err != nil {
return err
}
sliceBar, err := SliceTheBar(varFoo)
if err != nil {
return err
}
err := CheckBarSlice(sliceBar)
if err != nil {
return err
}
18. @nicolas_frankel
Why X?
Making the switch to a new language is hard
• Learning the syntax
• Using it in an idiomatic way
• Getting to know the libraries
• Getting the right tooling
• Getting used to it
Your team already knows X, use it