<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Pause 容器 :: Ay Docs</title>
    <link>https://ops.docs.72602.space/using/k8s/pause/index.html</link>
    <description>Kubernetes Pause 容器的用途 Pause 容器是 Kubernetes 中一个非常小但极其重要的基础设施容器。很多人会忽略它,但它是 Pod 网络和命名空间共享的核心。&#xA;🎯 核心作用 1. 作为 Pod 的&#34;根容器&#34;(Infrastructure Container) Pause 容器是每个 Pod 中第一个启动的容器,它的生命周期代表整个 Pod 的生命周期。&#xA;Pod 生命周期: 创建 Pod → 启动 Pause 容器 → 启动业务容器 → ... → 业务容器结束 → 删除 Pause 容器 → Pod 销毁 2. 持有和共享 Linux 命名空间 Pause 容器创建并持有以下命名空间,供 Pod 内其他容器共享:&#xA;Network Namespace (网络命名空间) - 最重要! IPC Namespace (进程间通信) UTS Namespace (主机名) # 查看 Pod 中的容器 docker ps | grep pause # 你会看到类似输出: # k8s_POD_mypod_default_xxx k8s.gcr.io/pause:3.9 # k8s_app_mypod_default_xxx myapp:latest 🌐 网络命名空间共享(最关键的用途) 工作原理 ┌─────────────────── Pod ───────────────────┐ │ │ │ ┌─────────────┐ │ │ │ Pause │ ← 创建网络命名空间 │ │ │ Container │ ← 拥有 Pod IP │ │ └──────┬──────┘ │ │ │ (共享网络栈) │ │ ┌──────┴──────┬──────────┬──────────┐ │ │ │ Container A │Container B│Container C│ │ │ │ (业务容器) │ (业务容器)│ (业务容器) │ │ │ └─────────────┴──────────┴──────────┘ │ │ │ │ 所有容器共享: │ │ - 同一个 IP 地址 (Pod IP) │ │ - 同一个网络接口 │ │ - 同一个端口空间 │ │ - 可以通过 localhost 互相访问 │ └────────────────────────────────────────────┘ 实际效果 # 示例 Pod apiVersion: v1 kind: Pod metadata: name: multi-container-pod spec: containers: - name: nginx image: nginx ports: - containerPort: 80 - name: sidecar image: busybox command: [&#39;sh&#39;, &#39;-c&#39;, &#39;while true; do wget -O- localhost:80; sleep 5; done&#39;] 在这个例子中:</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate></lastBuildDate>
    <atom:link href="https://ops.docs.72602.space/using/k8s/pause/index.xml" rel="self" type="application/rss+xml" />
  </channel>
</rss>