DEV Community

Cover image for Kubernetes Operator

Posted on • Updated on

Kubernetes Operator

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 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

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 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.


Top comments (6)

thekrprince profile image
Kumar Prince

Really liked the way you have explained it!! 👍

payalsasmal profile image

Thank you so much. It really means to me

phaniharsha2908 profile image

Very well explained about Kubernetes Operator

payalsasmal profile image

I am glad that you found the article insightful. Thank you 😃

pathikritsanyal profile image
pathikrit sanyal

Really helpfull 101 explanation on operator.

payalsasmal profile image

Thank you so much 😀