创建deploy
#单副本
kubectl create deployment mytomcat --image=tomcat:8.5.68
#多副本
kubectl create deployment my-dep --image=nginx --replicas=3
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: my-dep
name: my-dep
spec:
replicas: 3
selector:
matchLabels:
app: my-dep
template:
metadata:
labels:
app: my-dep
spec:
containers:
- image: nginx
name: nginx
查询deploy
kubectl get deploy
删除deploy
kubectl delete deploy mytomcat
扩缩容
#命令行方式
kubectl scale --replicas=5 deployment/my-dep
#配置文件方式
kubectl edit deployment my-dep
滚动更新
#查看pod镜像-作为对比
kubectl get deploy my-dep -oyaml
#滚动更新
kubectl set image deployment/my-dep nginx=nginx:1.16.1 --record
版本回退
#历史记录
kubectl rollout history deployment/my-dep
#查看某个历史详情
kubectl rollout history deployment/my-dep --revision=2
#回滚(回到上次)
kubectl rollout undo deployment/my-dep
#回滚(回到指定版本)
kubectl rollout undo deployment/my-dep --to-revision=2