我已经设置了一个部署的2个副本。
当我使用
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
当我通过Set Image更新它时,它只会更新1个Pod。第二个pod不会使用新代码进行更新。这意味着1个具有运行不同图像的2个容器。
当我将maxSurge设置为25%,将maxUnavailable设置为25%时,吊舱根本不会被替换。
这是完整的Yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "89"
creationTimestamp: 2018-11-26T09:40:48Z
generation: 94
labels:
io.kompose.service: servicing
name: servicing
namespace: default
resourceVersion: "6858872"
selfLink: /apis/extensions/v1beta1/namespaces/default/deployments/servicing
uid: 5adb98c8-f15f-11e8-8752-42010a800188
spec:
replicas: 2
selector:
matchLabels:
io.kompose.service: servicing
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
io.kompose.service: servicing
spec:
containers:
- env:
- name: JWT_KEY
value: ABCD
- name: PORT
value: "3001"
image: gcr.io/something/something
imagePullPolicy: Always
name: servicing-container
ports:
- containerPort: 3001
protocol: TCP
readinessProbe:
failureThreshold: 3
httpGet:
path: /
port: 3001
scheme: HTTP
initialDelaySeconds: 5
periodSeconds: 5
successThreshold: 1
timeoutSeconds: 1
resources:
requests:
cpu: 25m
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
status:
availableReplicas: 2
conditions:
- lastTransitionTime: 2018-12-13T11:55:00Z
lastUpdateTime: 2018-12-13T11:55:00Z
message: Deployment has minimum availability.
reason: MinimumReplicasAvailable
status: "True"
type: Available
observedGeneration: 94
readyReplicas: 2
replicas: 2
updatedReplicas: 2
答案 0 :(得分:1)
您已将initialDelaySeconds
设置为5,将periodSeconds
设置为5,将failureThreshold
设置为3,这意味着kubernetes将等待最初的5秒钟,以便首先探测您的应用程序是否准备就绪然后每5秒钟定期检查一次您的应用程序(如果尚未准备就绪),并将执行3次。因此,您的应用程序将在10秒,15秒和20秒时进行检查,如果pod在这段时间内没有出现,它将无法升级而无法运行。
您可能需要增加此failureThreshold
,以便您的应用确实有足够的时间上架。
此外,我建议您将maxUnavailable
设置为0,以便仅在更换新的吊舱时才删除吊舱。
在此处查看我的答案以更好地理解:
Kubernetes 0 Downtime using Readiness Probe and RollBack strategy not working