Learning - Kubernetes Operator
Used for Stateful Applications on K8s
Stateless Applications on K8s
Control loop
Observe => Check Differences => Take Action => Observe ...
- Recreate died pods
- restart updated pods
Stateful Applications WITHOUT Operator
Data Persistence
-
more "hand-holding" needed
-
throughout whole lifecycle
-
all 3 replicas are different
-
own state and identity
-
order important
-
Process different for each application
-
So, no standard solution
-
manual intervention necessary
-
people, who "operate" these applications
-
can not archive automation, self-healing
Stateful application WITH Operator
To manage stateful application
Replaces human operator with software operator.
-
How to deploy the app?
-
How to create cluster of replicas?
-
How to recover?
-
tasks are automated and reusable
-
One 1 standard automated process
-
more complex/more environments => more benefits
Control loop mechanism
watch for changes
Observe => Check Differences => Take Action => Observe ...
It is custom control loop
make use of CRD's
Custom Resource Definitions
- custom K8s component (extends K8s API)
Your own custom component
domain/app-specific knowledge
CRD's, StatefulSet, ConfigMap, Service, ...
automates entire lifecycle of the app it operates
Summary
- Managing complete lifecycle of stateless apps
No business logic necessary to: create, update, delete - K8s can't automate the process natively for stateful apps
Operators: prometheus-operator, mysql-operator, postgres-operator, elastic-operator
For example: MySQL
- How to create the mysql cluster
- How to run it
- How to synchronize the data
- How to update
OperatorHub.io
Operator SDK to create own operator