deployment解决了rc的与svc的label升级关联问题,如果rc的pod的label或者svc的selector有改动必须手动匹配才能建立关联。
deployment通过创建rs来管理容器,rs具有90%的rc特性。
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 3
selector:
matchLabels:
app: nginx-deployment
template:
metadata:
labels:
app: nginx-deployment
spec:
containers:
- name: nginx-deployment
image: nginx:1.13
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
kubectl apply -f nginx-deployment.yml --record //记录每一步的reversion
kubectl get deployment
kubectl scale deployment nginx-deployment --replicas=3
kubectl set image deployment/nginx-deployment nginx:1.15
kubectl rollback undo deployment/nginx-deployment
kubectl rollback status deployment/nginx-deployment
kubectl rollback history deployment/nginx-deployment
kubectl rollback undo deployment/nginx-deployment --to-reversion=3
.spec.revisionHistoryLimit 设置版本保存值