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.
3. @nicolas_frankel
Hazelcast
HAZELCAST IMDG is an operational,
in-memory, distributed computing
platform that manages data using
in-memory storage, and performs
parallel execution for breakthrough
application speed and scale.
HAZELCAST JET is the ultra fast,
application embeddable, 3rd
generation stream processing
engine for low latency batch
and stream processing.
4. @nicolas_frankel
“Kubernetes (K8s) is an open-source
system for automating
deployment, scaling, and
management of containerized
applications.”
Kubernetes
6. @nicolas_frankel
“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.”
Kubernetes API Server
8. @nicolas_frankel
“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.”
Controllers
10. @nicolas_frankel
• 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
Where are controllers located?
11. @nicolas_frankel
“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.”
Operator vs. controller
12. @nicolas_frankel
“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.”
Custom Resource Definition
14. @nicolas_frankel
• 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
Operator vs. controller
15. @nicolas_frankel
• Must “talk” to the API server
• REST-based
• One can create a controller using
the shell only
The technology stack of controllers
17. @nicolas_frankel
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
}
Why not Go?
18. @nicolas_frankel
• 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
Why X?