Cloud Native 20 min read

Why Kubernetes Is the Next‑Generation OS and How to Build Your First Operator

This article explains why Kubernetes should be seen as a next‑generation operating system, walks through a simple nginx deployment using declarative YAML, introduces the concepts of CRDs, custom controllers and Operators, and shows how to create and manage resources such as etcd clusters and virtual machines within Kubernetes.

Alibaba Cloud Native
Alibaba Cloud Native
Alibaba Cloud Native
Why Kubernetes Is the Next‑Generation OS and How to Build Your First Operator

Kubernetes as a declarative operating system

Kubernetes provides a virtually unlimited pool of resources and a declarative, distributed‑system‑native API that can serve as the primary platform for developing, testing, and deploying applications, while traditional Linux/Windows VMs remain as low‑level operating systems.

Simple "Hello World" deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app-name: my-nginx
  template:
    metadata:
      labels:
        app-name: my-nginx
    spec:
      containers:
      - name: nginx
        image: nginx
---
apiVersion: v1
kind: Service
metadata:
  name: nginx
spec:
  selector:
    app-name: my-nginx
  type: ClusterIP
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: 80

Apply the manifest with kubectl apply -f ./nginx.yaml. Kubernetes creates three nginx pods, a Service that load‑balances traffic, and a stable DNS name for the service.

Benefits of declarative deployment

Automatic replica management – failed pods are recreated.

Service abstraction provides load balancing and DNS without manual configuration.

Rolling updates and scaling are performed by editing the YAML and re‑applying.

Extending Kubernetes with Operators

Operators combine a CustomResourceDefinition (CRD) and a custom controller to encapsulate domain‑specific logic. Example: an etcd cluster operator.

apiVersion: "etcd.database.coreos.com/v1beta2"
kind: "EtcdCluster"
metadata:
  name: "example-etcd-cluster"
spec:
  size: 3

The operator watches these custom resources and creates the required etcd pods automatically.

Operator core reconcile logic (pseudo‑code)

// Reconcile is the main operator loop
func Reconcile(crName string) error {
    // Fetch the custom resource submitted by the user
    cr := client.getCR(crName)
    // Derive the desired Deployment from the CR
    desired := getDesiredDeployment(client, cr)
    // Get the current Deployment in the cluster
    current := client.GetDeployment(crName)
    // Update if there is a drift
    if diff(desired, current) {
        return client.UpdateDeployment(desired)
    }
    return nil
}

Unified API via the Kubernetes API server for all components.

Leverages community‑maintained operators (e.g., MySQL‑operator) to compose complex applications.

Reduces operational burden by handling lifecycle, scaling, and failover automatically.

Community operators

Curated list of high‑quality operators: https://github.com/operator-framework/awesome-operators

Pod as a VM‑like environment

apiVersion: v1
kind: Pod
metadata:
  name: my-vm-1
spec:
  containers:
  - name: vm
    image: ubuntu

Custom images can be built by adding a Dockerfile to the project and running make image.

Getting started with a cluster

For hands‑on practice, run Minikube locally or provision a Kubernetes cluster from a cloud provider.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DeploymentKubernetesOperatorDevOpsYAML
Alibaba Cloud Native
Written by

Alibaba Cloud Native

We publish cloud-native tech news, curate in-depth content, host regular events and live streams, and share Alibaba product and user case studies. Join us to explore and share the cloud-native insights you need.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.