KEMBAR78
OSCONF - Your own Kubernetes controller: not only in Go | PPTX
@nicolas_frankel
Your own Kubernetes
Operator Controller:
Not Only In Go!
@nicolas_frankel
• Former developer, team lead,
architect, blah-blah
• Curious about Kubernetes
• Stuck at home
Me, myself and I
@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.
@nicolas_frankel
“Kubernetes (K8s) is an open-source
system for automating
deployment, scaling, and
management of containerized
applications.”
Kubernetes
@nicolas_frankel
Kubernetes architecture
In Kubernetes in Action by Marko Luksa, Fig. 1.9
@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
@nicolas_frankel
• Command-line tool that interacts
with the API server
• kubectl get pods --v=6
kubectl
@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
@nicolas_frankel
• Deployment controller
• Job controller
• etc.
Out-of-the-box controllers
@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?
@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
@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
@nicolas_frankel
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: hazelcasts.hazelcast.com
spec:
group: hazelcast.com
names:
kind: Hazelcast
listKind: HazelcastList
plural: hazelcasts
singular: hazelcast
scope: Namespaced
subresources:
status: {}
versions:
- name: v1alpha1
served: true
storage: true
Defining a CRD
@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
@nicolas_frankel
• Must “talk” to the API server
• REST-based
• One can create a controller using
the shell only
The technology stack of controllers
@nicolas_frankel
• Kubernetes is written in Go
• Rewritten from Java
• Go is pervasive in the K8s
ecosystem
Why Go?
@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?
@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?
@nicolas_frankel
You know where I’m heading to…
I know Java
@nicolas_frankel
@nicolas_frankel
A word about GraalVM
• JVM platform
• Polyglot
• Java, Python, JavaScript, R, Ruby, C
• Truffle:
• Programming Language implementation
helper
• Substrate VM:
• Create native executables from bytecode
@nicolas_frankel
Recap
• What are Controllers
• Controllers vs. operators
• No tech stack required
• JVM for the win!
• With some GraalVM love
@nicolas_frankel
• https://blog.frankel.ch/
• @nicolas_frankel
• http://bit.ly/jvm-controller
Thanks a lot!

OSCONF - Your own Kubernetes controller: not only in Go