Pod 是最小调度单位,Deployment 管理副本,Service 提供访问入口。
本节要点
- Pod 包含一个或多个容器
- Deployment 保证副本数
- Service 提供稳定访问地址
代码示例
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
spec:
replicas: 2
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: web
image: nginx:1.27
ports:
- containerPort: 80