作者:阿乀胜69 | 来源:互联网 | 2023-09-24 09:05
#yaml文件内容apiVersion:appsv1kind:Deploymentmetadata:creationTimestamp:nulllabels:app:xxxxxxx
# yaml文件内容
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: xxxxxxxxxxx
name: xxxxxxxxxxx
spec:
replicas: 2 # 2 副本
selector:
matchLabels: # controller匹配pod标签
app: xxxxxxxxxxx
strategy: {}
template:
metadata:
creationTimestamp: null
labels: # 标签
app: xxxxxxxxxxx
spec:
containers:
- image: nginx:1.14 # 1.14版本nginx
name: nginx
resources: {}
status: {}
# 应用升级nginx到1.15
kubectl set image deployment xxxxxxxxxxx nginx=nginx:1.15
# 查看升级状态
kubectl rollout status deployment xxxxxxxxxxx
# 查看历史版本
kubectl rollout history deployment xxxxxxxxxxx
# 回滚,还原到上一个版本
kubectl rollout undo deployment xxxxxxxxxxx
# 回滚到指定版本
kubectl rollout undo deployment xxxxxxxxxxx --to-revision=2
# 2 表示版本?
# 弹性伸缩
kubectl scale deployment xxxxxxxxxxx --replicas=5