Learning Library

← Back to Library

Kubernetes Operators and Control Loop

Key Points

  • The Operators framework, originally created by CoreOS in 2016 and now part of Red Hat/IBM, provides a way to automate the management of complex Kubernetes and OpenShift applications.
  • It builds on Kubernetes’ core control loop—**observe**, **diff**, **act**—which continuously reconciles the actual cluster state with the desired state defined in resources.
  • Without an operator, deploying an app requires manually writing and applying separate YAML manifests (e.g., Deployments, Services) and relies on the control loop to create pods and handle updates.
  • For multi‑component or frequently changing workloads, this manual approach becomes cumbersome because every scaling, secret, or configuration change means editing or adding new Kubernetes resources, a problem that Operators aim to solve by encoding that logic in code.

Full Transcript

# Kubernetes Operators and Control Loop **Source:** [https://www.youtube.com/watch?v=i9V4oCa5f9I](https://www.youtube.com/watch?v=i9V4oCa5f9I) **Duration:** 00:09:36 ## Summary - The Operators framework, originally created by CoreOS in 2016 and now part of Red Hat/IBM, provides a way to automate the management of complex Kubernetes and OpenShift applications. - It builds on Kubernetes’ core control loop—**observe**, **diff**, **act**—which continuously reconciles the actual cluster state with the desired state defined in resources. - Without an operator, deploying an app requires manually writing and applying separate YAML manifests (e.g., Deployments, Services) and relies on the control loop to create pods and handle updates. - For multi‑component or frequently changing workloads, this manual approach becomes cumbersome because every scaling, secret, or configuration change means editing or adding new Kubernetes resources, a problem that Operators aim to solve by encoding that logic in code. ## Sections - [00:00:00](https://www.youtube.com/watch?v=i9V4oCa5f9I&t=0s) **Kubernetes Operators and Control Loop** - Sai Vennam of the IBM Cloud team introduces the operators framework for Kubernetes/OpenShift, explains its origins, and breaks down the core Kubernetes control loop of observe‑diff‑act used to manage complex applications. - [00:03:05](https://www.youtube.com/watch?v=i9V4oCa5f9I&t=185s) **Simplifying K8s Deployments with Operators** - The speaker explains how operators—installed via the Operator Lifecycle Manager and composed of Custom Resource Definitions and controllers—automate scaling, configuration, and secret management in Kubernetes, eliminating the need for repetitive manual resource edits. - [00:06:13](https://www.youtube.com/watch?v=i9V4oCa5f9I&t=373s) **Building Custom Operators with Helm** - The speaker explains how to create custom Kubernetes operators using the Operator SDK, highlights that the Helm‑based operator quickly achieves the first two maturity levels (basic install and upgrade), and notes that achieving the remaining advanced levels requires using Go or Ansible. - [00:09:19](https://www.youtube.com/watch?v=i9V4oCa5f9I&t=559s) **Video Outro and Call‑to‑Action** - The speaker thanks viewers, invites questions, encourages likes and subscriptions, and promotes signing up for a free IBM Cloud account. ## Full Transcript
0:00Hi everyone, my name is Sai Vennam 0:02and I'm with the IBM Cloud team. 0:03Today we want to talk about operators, 0:05and no, I'm not actually talking about operations teams, 0:08but instead the operators framework 0:10which can be used on Kubernetes or OpenShift. 0:13CoreOS actually introduced the operator framework back in 2016. 0:17CoreOS is now a part of Red Hat and IBM. 0:20Operator framework is quickly picking up traction 0:24as it's a great way of managing complex Kubernetes applications. 0:28Now, before I jump into this, 0:30we want to actually introduce what the Kubernetes control loop is 0:34because it's a core part of the operators framework. 0:36In this video, we're going to be talking about things like deployments and pods, 0:40so if you're not familiar with those 0:42be sure to check out the"Kubernetes Explained" video 0:44that I've done on those topics. 0:46But let's get started with exactly what the control loop is 0:50in Kubernetes. 0:54Now, essentially the way it starts, 0:56the control loop is the core part of Kubernetes, 0:58it observes the state of what's in your actual cluster. 1:02So, that's the first step: "observe". 1:06Next, what it's going to do, 1:08Kubernetes is going to double-check 1:10that the state in the actual cluster 1:13versus the state that you want it to be. 1:15So it's going to do a diff. 1:19And finally, it wants to resolve that diff by acting on it. 1:24So, the last phase of the control loop is "act". 1:29Now, the control loop is core to how Kubernetes works 1:31and there's a controller that basically acts on that 1:34for every default resource. 1:36Kubernetes comes with a number of default resources. 1:39Let's see an example of deploying an application without operators 1:43using these default resources. 1:46So, as an end user, 1:47essentially the first thing you're going to want to do 1:50is write up some YAML, 1:52the specification for that actual application. 1:54And, for our particular example, let's say that 1:57we're doing a deployment. 2:02And in this deployment, we'll have to define some configuration. 2:06Things like, "What's the image?", and maybe 2:09the replicas, and maybe some other configuration. 2:16So, that's one Kubernetes resource. 2:19And, essentially what you would do, is take that 2:22and deploy it into your Kubernetes cluster 2:25at which point a deployment is made. 2:29Here's where the control loop kicks in: 2:31so Kubernetes observes the state of your cluster, 2:34so we've got a Kubernetes cluster here, 2:35and checks for the difference between what you want versus what's there. 2:39First thing it notices: there's no pods. 2:42So, it's gonna act on that difference, 2:45and it's gonna create some pods. 2:48Now, let's say for a fairly complex application 2:51we don't just have one YAML 2:53but we have a second YAML, maybe it's for the backend, 2:56and so that deploys in the second deployment, 2:59and that in turn deploys a pod 3:02using the controllers in the control loop. 3:05Now, it's a simple example, but say you want to go through here, 3:09scale up the application, make some changes, 3:11set up some secrets, environment variables, 3:14- every single time you have to either create new Kubernetes resources, 3:17or go in here and edit the existing ones. 3:20That can start to get fairly difficult. 3:23Now, let's see how that's done in a world where we're using operators. 3:26Now, the first thing you would need to do 3:28is install the operator itself. 3:30So, someone on your team has to create the operator, 3:33or maybe you can use one of the many that are out there on OperatorHub, 3:36or the community is building on the operators that are available. 3:40So, the first thing you need in your Kubernetes cluster 3:43is the OLM, which is the "Operator Lifecycle Manager", 3:46which basically manages operators that you have installed. 3:49Next, you deploy your actual operator into the cluster. 3:56The operator is made up of two major components. 4:00The first component in an operator is going to be the CRD. 4:07The other one is going to be the controller. 4:11Now, the CRD is basically a "Custom Resource Definition". 4:14So, we've talked about default resources - things like deployments and pods. 4:18A custom resource is something that you define as a user in Kubernetes, 4:23or maybe an operator defines, it so that you can create YAML 4:26to work against that custom config. 4:29The controller is basically a custom control loop 4:32which runs as a pod in your cluster 4:35and runs this control loop against your custom resource definition. 4:39So, let's say that an operator is created for our custom application deployment here, 4:45so instead of having to write multiple deployments 4:48and setting up config maps and secrets for whatever our cluster needs, 4:51we instead, as an end user, we'll just deploy one YAML. 4:59Maybe we called this operator MyApp. 5:03It could be a little bit more meaningful - we can call it "stateful app", "front-end app", 5:07whatever we want it to be. 5:09And then, we could define some config here, 5:14or we can use the defaults that are set. 5:16We of have a choice of options here. 5:19Then we take this operator 5:22and we deploy it directly into the cluster. 5:25At this point the operator takes over, 5:27and this is actually responsible for running that control loop, 5:30and figuring out exactly what needs to be running. 5:33So, it's going to realize that 5:35we need a couple of deployments and the pods. 5:43Now, this is a kind of a format, or an approach 5:48to managing applications 5:49that's inherently easier - and scales better - than this approach, 5:53because, as an end-user, you really only have to worry about 5:57the config that's been exposed to you, 5:59and the operator itself manages the control loop 6:01and the state of the application - how it needs to look. 6:04Now, there are great operators out there already, 6:07things like managing etcd, or various databases, 6:11or even IBM Cloud Services. 6:13So, all of those operators currently exist on OperatorHub. 6:16But say you want to develop your own, maybe a custom operator for 6:20for something that is native to your application architecture, 6:24kind of like what we sketched out here. 6:26Well, there's a number of ways you can do that. 6:28And there's something called Operator SDK that allows you 6:31to start building out operators yourself. 6:34Now, I'd say the easiest way to get started with an operator, 6:37is to use the Helm operator. 6:39So, Helm. 6:41As you may already know, 6:43there is a video that where David Okun goes over exactly how Helm works. 6:47Be sure to check that one out. 6:48The Helm approach allows you to take a Helm chart 6:52and apply that towards an operator, expose config - 6:55so, it allows you to get to a fairly mature level of an operator. 6:59Kind of something like this for a chart that's already there. 7:03Now the maturity of operators, what I've sketched out down here, 7:07falls into 5 different levels. 7:08Now, Helm actually hits the first 2 levels of maturity. 7:14Let's talk about what those levels are. 7:16The first one is a basic install. 7:21Essentially, the first level is basically going to allow you to do 7:25just provisioning of the resources required. 7:27Now, the second phase goes a little bit further 7:31it's gonna allow you to do upgrades. 7:34So, this supports minor and patch version upgrades 7:37to whatever is defined in your operator. 7:39Now Helm gets you that far, 7:41what about for the next 3 levels of maturity? 7:44For these, you're going want to use either Go, 7:49or, you can also use Ansible. 7:53Now, these will allow you to actually get to 7:57all 5 levels of maturity with operators. 8:02Let's quickly talk about what those are. 8:05At the third level, we've got full lifecycle support. 8:09So, this is storage lifecycle, app lifecycle. 8:13It's also going to allow you to do things like backup and failure recovery. 8:16So, that's something that would be configured 8:19and developed into the operator, 8:21who ever developed that one. 8:24Fourth, what we've got here is insights. 8:31This is going to allow you to get deep metrics, and analysis, 8:34logging, that kind of thing, from your actual operator. 8:37And finally, what we have is something called "autopilot". 8:41And just as the name implies, 8:44this is going to have a lot more functionality built into operator itself. 8:48Basically it's going to allow you to do automatic scaling, 8:50- horizontal and vertically. 8:52It's going to do automatic config tuning. 8:54If your operator-based app gets into a bad state, 8:57it's gonna identify that automatically. 9:00So, these are the 5 levels of maturity that operators can have. 9:04By looking on OperatorHub, you can see 9:06the ones that the community has developed 9:08and see what level of maturity that they hit, 9:10and then, again, by using operator SDK, 9:13you can build your own operators using either Helm, Go, or Ansible. 9:19Thanks for joining me for this video on operators. 9:21If you have any questions be sure to drop us a line below. 9:24If you want to see more videos like this in the future, 9:27please "like' and subscribe. 9:28And don't forget, you can always get started on the cloud at no cost 9:32by signing up for a free IBM Cloud account.