debasish bhattacharya:
hi All,
question on LIGHTNING LABS, LIGHTNING LAB – 1,question 4.
i created this following template:
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: nginx-deploy
name: nginx-deploy
spec:
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 2
type: RollingUpdate
replicas: 4
selector:
matchLabels:
app: nginx-deploy
strategy: {}
template:
metadata:
creationTimestamp: null
After creating this deployment i see following in created deployment yaml output.
spec:
progressDeadlineSeconds: 600
replicas: 4
revisionHistoryLimit: 10
selector:
matchLabels:
app: nginx-deploy
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
This seems to be incorrect , i expect maxUnavailable should be 50%.
what am i doing wrong?
Mohamed Ayman:
Hello @debasish bhattacharya
Try this.
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: nginx-deploy
name: nginx-deploy
namespace: default
spec:
replicas: 4
selector:
matchLabels:
app: nginx-deploy
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 2
type: RollingUpdate
template:
metadata:
labels:
app: nginx-deploy
spec:
containers:
- image: nginx:1.16
imagePullPolicy: IfNotPresent
name: nginx
kubectl set image deployment/nginx-deploy nginx=nginx:1.17 --record
kubectl rollout undo deployment nginx-deploy
Thanks
KodeKloud Support
Trung Tran:
@debasish bhattacharya, look at your yaml file, there are 2 strategy section, the second one will overwrite the first one, and that why it set default value to your deployment.
You need check the yaml file and make sure only one strategy available.
debasish bhattacharya:
thanks @Trung Tran
Jason Lu:
So, to clarify, we can only run one strategy at a time? @Trung Tran
Trung Tran:
Yes @Jason Lu.