Skip to content

Kubernetes

一句话解释

Kubernetes (K8s) 是 platform 那个 automates deploying, scaling, and managing containerized applications 跨越 clusters 的 machines.

用大白话说

Kubernetes, often abbreviated as K8s, is a system for managing containers at scale. When you have just a few containers, you can manage them manually with Docker. But when you have hundreds or thousands of containers running across dozens of servers, you need Kubernetes.

Kubernetes handles: scheduling (deciding which server runs which container), scaling (adding or removing containers based on load), self-healing (restarting failed containers), and rolling updates (updating without downtime).

You describe what you want in YAML files — e.g., "I 想要 3 replicas 的 my web app" — and Kubernetes makes it happen. If a server crashes, Kubernetes automatically moves the containers to healthy servers.

示例

yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
spec:
  replicas: 3
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
        - name: my-app
          image: my-app:latest

这个部署 tells Kubernetes 到运行 3 replicas 的 my-app 容器镜像.

工作原理

  1. You write YAML manifests describing your desired state (e.g., 3 replicas).
  2. You submit them to the Kubernetes API server with kubectl apply.
  3. The scheduler places pods on available nodes.
  4. Controllers continuously reconcile actual state to match desired state.
  5. If a pod dies, Kubernetes restarts it automatically.

常见混淆

  • 容易混淆的对象: Docker

    关键区别: Docker 构建 and 运行 individual 容器; Kubernetes orchestrates 许多容器跨越 cluster 的 machines.

相关术语

解读错误信息

用大白话解释常见错误——什么意思、为什么发生、如何修复。

查看错误

← 返回术语表