部署
一句话解释
部署是 Kubernetes resource 那个 manages 设置的 Pods, 启用 scaling, 更新, and rollbacks.
用大白话说
A Deployment is one of the most important Kubernetes resources. It manages a set of identical Pods and provides features like scaling, rolling updates, and rollbacks.
Instead of creating Pods directly (which are ephemeral and hard to manage), you create a Deployment. You tell it "I 想要 3 replicas 的 my app" and the Deployment creates 3 Pods. If one Pod dies, the Deployment automatically creates a new one.
When you update your application (e.g., new image version), the Deployment performs a rolling update — it gradually replaces old Pods with new ones, so there is no downtime. If something goes wrong, you can roll back to the previous version with a single command.
示例
# Update the image and Kubernetes rolls out gradually
kubectl set image deployment/my-app my-app=my-app:v2
# Roll back if something goes wrong
kubectl rollout undo deployment/my-app首先 command 更新容器镜像; Kubernetes 执行 rolling 更新. 其次 command rolls 后面到 上一个 version.
工作原理
- You define a Deployment with a desired number of replicas.
- The Deployment controller creates Pods to match the desired count.
- When you update the image, it creates new Pods and gradually removes old ones.
- You can roll back to a previous revision if the new version has issues.
常见混淆
容易混淆的对象: Pod
关键区别: Pod 是单个实例; 部署 manages 多个 Pods and provides scaling, 更新, and self-healing.
相关术语
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。