Kubernetes Operator
Tags: kubernetes, kubernetesoperator, cloud, cloudnative
Published: 2021-05-12 19:01:05

###What is Kubernetes or k8s?
Kubernetes is an open source containerized orchestration platform. Which basically help you to deploy, manage and scale your application automatically. 


###What is Kubernetes operator?
Kubernetes operator is method of deploying, managing, scaling and packaging k8s application.



*Now the confusion come up, both are deploying, managing, scaling the application then what is the difference between them.🤔 Let's see how both works*

###How Kubernetes works
**Kubernetes** automate the lifecycle of a [stateless application](https://www.redhat.com/en/topics/cloud-native-apps/stateful-vs-stateless) like web application, Mobile application etc. So, it does not store the previous user's state to the server. 
As server does not store the state, so when one application pod fail then Kubernetes can replace it with another pod automatically and Kubernetes does not have to configure extra things for stateless application.

Now question is how does Kubernetes knows I have deployed application with these number of replicas(let's say 3 replicas) and I always be having my desired number of replicas(3 replicas) up and running (feature of auto-scaling)? 😮

So Kubernetes is having **controller component** which is responsible to implement **control-loop**. Control-loop always observe the desire state and actual state of the cluster. If there is any difference then fix that immediately.

 ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/osobw46fat99eknxwl0z.PNG)                    
  

Even though Kubernetes does not have **domain/application knowledge**, It can deploy your application without any knowledge of your application.

###How Kubernetes Operator works
Now think, you want to deploy [Stateful application](https://www.redhat.com/en/topics/cloud-native-apps/stateful-vs-stateless) or complex application where you want storage, networking, cluster connection and pod should have their own volume.
You want that Kubernetes should deploy the application automatically With these requirements. But Kubernetes does not have domain/application knowledge right?

So the **Kubernetes operator** come into the picture. **Kubernetes Operator** can manage above requirements of your application using **Custom Resource(CR)**.
If we use any type of **CR** we first have to register that CR to Kubernetes cluster, To register the CR we use Custom Resource Definition(CRD). This CRD handled by K8s API.

Now if I want to deploy my application and I want auto-scaling for my application as same Kubernetes did for stateless application. So **Kubernetes Operator** is a **custom Kubernetes Controller** (implement control-loop) which watch the CR and It takes action to match the desired state.

`The action Kubernetes Operator takes almost everything like scale-up the complex application, upgrade the new version of application, configure application endpoints etc.`

That's how Kubernetes and Kubernetes Operator work. Choose it wisely based on your application. 

*I hope, this blog give little bit idea about the difference between Kubernetes and Kubernetes Operator. And how they work differently.*

[GitHub](https://github.com/PayalSasmal10)
[Twitter](https://twitter.com/payalsasmal)
[Linkedin](https://www.linkedin.com/in/payal-sasmal-64204311a/)