Kubernetes Operators 🦄 simply explained
Tags: kubernetes, devops, docker, tutorial
Published: 2020-08-14 15:14:39

###Learn what a Kubernetes Operator is, why this operator concept even emerged and when you should use them ###
----

OVERVIEW:
To give you an overview, operators are used mainly for stateful applications. So I first compare how Kubernetes manages stateless and stateful applications. And then compare deploying and managing stateful applications without an operator compared to deploying it with a Kubernetes Operator.

- 1. StateLESS applications on Kubernetes 🚀
- 2. StateFUL applications WITHOUT Operator 🤯
- 3. StateFUL applications WITH Operator 🦄

---------
► Watch the complete video 🎬 here: [Kubernetes Operators explained](https://youtu.be/ha3LjlD6g7g)

###1. Stateless applications on Kubernetes 🚀 ###
Kubernetes can manage the complete lifecycle of stateless applications in a **fully automated way**, because these applications don’t have business logic for deployment. 

This means K8s doesn’t need to know any application-specific business logic to automatically create, update and delete them. 🔝

So basically, once you deployed the application, you don’t have to sit there and control that your application is running properly. And when you carry out small changes, like update or scale up, it works pretty much **without problems**. 

That's great! 😎


### 2. Stateful applications without Operator 🤯###

For stateful applications, like databases, the whole process isn’t as straightforward.
They need more **"hand-holding"  during its whole lifecycle**, because the replicas of stateful apps aren't identical. 

![Stateful applications without operator](https://dev-to-uploads.s3.amazonaws.com/i/x6y2tqelme191c4wdkb1.png)

*Each has its state and identity.* This means, they need to be started, updated and destroyed in a certain order. These details will even vary for each application: Mysql will have its own specific way of doing this, Postgres and Elasticsearch have another way of doing it etc. 🙄

So, Kubernetes natively/internally doesn’t have all the knowledge required 🤷🏻‍♂️ to automate the process of deploying every single stateful application. 

That’s why these kind of applications require **manual intervention** - people who **"operate"** these applications. 👩🏻‍💻

### 3. Stateful applications with Operator 🦄###
Operator solves this problem and basically **replaces this "human" operator with a "software" operator**. 

All the manual tasks that devOps teams would do is now packed into a program that has the knowledge and intelligence about how to deploy that specific application, like Postgres or Prometheus. 💡

####So how does Operator do this? 🤔 ####
At its core it has the same control loop mechanism that k8s has, that watches for changes in the application state. 

![Kubernetes Control Loop](https://dev-to-uploads.s3.amazonaws.com/i/ckcp0ruzvxmsutvk1m5t.png)

It also uses CRDs, which is basically a custom K8s component which extends the Kubernetes API.

So, it takes the basic Kubernetes resources and its controller concept as a foundation to build upon, and on top of that **includes domain or application-specific knowledge to automate the entire life cycle of the application it "operates"**:
![Stateful Applications with operator](https://dev-to-uploads.s3.amazonaws.com/i/m91hlkbcerz3wivv8kjw.png)


More details in the video here 👩🏻‍💻
{% youtube ha3LjlD6g7g %}

-----------------
**Kubernetes 101** ► [Compact and easy-to-read ebook bundle 🚀](https://www.techworld-with-nana.com/e-books) 
It's a handy way to quickly look something up or refresh your knowledge at work and use it as your cheatsheet  😎

**Like, share and follow me** 😍 for more content:
- [Private FB group](https://www.facebook.com/groups/techworldwithnana)
- [Twitter](https://twitter.com/Njuchi_)
- [YouTube](https://www.youtube.com/channel/UCdngmbVKX1Tgre699-XLlUA?sub_confirmation=1)
- [Instagram](https://www.instagram.com/techworld_with_nana/)
- [LinkedIn](linkedin.com/in/nana-janashia)