apiVersion: apps/v1
kind: Deployment
metadata:
name: my-nginx
# 描述...
spec:
replicas: 2
selector:
matchLabels:
app: my-nginx
template:
metadata:
labels:
app: my-nginx
# pod...
spec:
containers:
- name: my-nginx
image: nginx
ports:
- containerPort: 80
.
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name:
namespace:
labels:
spec:
replicas: # 设置Deployment的副本数量
selector:
matchLabels: # 设置匹配标签的POD来创建deployment实例
lable_name:
template: # 设置Pod模板
metadata:
name:
labels:
lable_name: label # 需要和上面的selector中的matchLabels保持一致
spec:
containers: # Pod里面运行的容器
- name: container_name1 # 设置容器名字
image: xx # 设置image地址
imagePullPolicy: # 设置下载镜像策略,常用选项Always、Never、IfNotPresent
args: # []列表类型 设置容器启动的参数,用于替换容器中cmd
command: # []列表类型 设置容器启动脚本 用于替换容器中EntryPoint
env:
- name: # 列表对象类型 设置容器启动环境变量
value:
lifecycle: # 描述容器的启动之前和启动之后的动作
postStart:
preStop:
ports:
livenessProbe: # 是否运行健康
readinessProbe: # 是否启动完成
restartPolicy: # Pod异常重启策略 Always、OnFailure 、Never
nodeSelector:
strategy: # 设置滚动更新策略
rollingUpdate:
参考
https://blog.csdn.net/yucaifu1989/article/details/106682256
https://www.cnblogs.com/xiaopaipai/p/10602984.html