Skip to content

Kubernetes Operator

A Kubernetes Operator is a method of packaging, deploying, and managing a Kubernetes application.^[400-devops-06-kubernetes-k8s-paas-readme.md]

Overview

Operators function as an extension of the Kubernetes Control Plane. They are designed to automate the lifecycle management of complex, stateful applications—such as databases, caching systems, and messaging queues—by encoding domain-specific knowledge into software.^[400-devops-06-kubernetes-k8s-paas-readme.md]

While Kubernetes natively handles stateless workloads effectively, stateful applications often require human intervention for tasks like scaling, upgrades, or failovers. An Operator acts as a "site reliability engineer" (SRE) embedded in the software, handling these operational tasks automatically based on custom resources and logic.^[400-devops-06-kubernetes-k8s-paas-readme.md]

Working Principle

The core functionality of an Operator relies on the Reconciliation Loop (调谐循环).^[400-devops-06-kubernetes-k8s-paas-readme.md]

  1. Observe: The Operator continuously monitors the cluster for the state of resources (Custom Resources) and the actual running state of the application.
  2. Diff: It compares the current state (Actual State) with the desired state (Desired State) defined in the resource configuration.
  3. Act: If there is a difference (drift), the Operator executes specific actions—such as creating a Pod, updating a Service, or modifying a configuration—to bring the actual state in line with the desired state.^[400-devops-06-kubernetes-k8s-paas-readme.md]

This cycle ensures the application maintains its configuration and availability without manual intervention, adhering to the Kubernetes philosophy of [[Declarative Management]].

  • [[Custom Resource Definition (CRD)]]
  • [[Controller]]
  • Kubernetes
  • [[Reconciliation Loop]]

Sources

^[400-devops-06-kubernetes-k8s-paas-readme.md]