我正在使用滚动更新策略进行部署,使用这两个命令:
kubectl patch deployment.apps/<deployment-name> -n <namespace> -p '{\"spec\":{\"template\":{\"metadata\":{\"labels\":{\"date\":\"`date +'%s'`\"}}}}}'
kubectl apply -f ./kube.deploy.yml -n <namespace>
kubectl apply -f ./kube_service.yml -n <namespace>
滚动更新的 YAML 属性:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: "applyupui-persist-service-deployment"
spec:
# this replicas value is default
# modify it according to your case
replicas: 2
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 20%
template:
metadata:
labels:
app: "applyupui-persist-service-selector"
spec:
hostAliases:
- ip: "xx.xx.xx.xxx"
hostnames:
- "kafka02.prod.fr02.bat.cloud"
imagePullSecrets:
- name: tpdservice-devops-image-pull-secret
containers:
- name: applyupui-persist-service
image: gbs-bat-devops-preprod-docker-local.artifactory.swg-devops.com:443/applyupui-msg-persist-service:latest
imagePullPolicy: Always
env:
- name: KAFKA_BROKER
value: "10.194.6.221:9092,10.194.6.221:9093,10.194.6.203:9092"
- name: SCYLLA_DB
value: "scylla01.fr02.bat.cloud,scylla02.fr02.bat.cloud,scylla03.fr02.bat.cloud"
- name: SCYLLA_PORT
value: "9042"
- name: SCYLLA_DB_USER_ID
value: "kafcons"
- name: SCYLLA_DB_PASSWORD
value: "@%$lk*&we@45"
- name: SCYLLA_LOCAL_DC_NAME
value: "Frankfurt-DC"
- name: DC_LOCATION
value: "FRA"
- name: kafka.consumer.retry.topic.timeout.interval
value: "100"
- name: kafka.consumer.retry.topic.max.retry.count
value: "5"
- name: kafka.consumer.dlq.topic.timeout.interval
value: "100"
- name: kafka.producer.timeout.interval
value: "100"
- name: debug.log.enabled
value: "false"
- name: is-application-intransition-phase
value: "false"
- name: is-grace-period
value: "false"
- name: SCYLLA_KEYSPACE
value: "bat_tpd_pri_msg"
readinessProbe:
httpGet:
path: /greeting
port: 8080
initialDelaySeconds: 3
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
nodeSelector:
deployment: frankfurt
# resources:
# requests:
# cpu: 100m
# memory: 100Mi
我尝试更改参数maxsurge
和maxunavailable
不同的initialdelayseconds
参数。另外,我尝试给出livelinessprobe
参数
livenessprobe:
tcpSocket:
port: 8080
initialDelaySeconds: 15
periodSeconds: 20
,但都没有奏效。它给出了连接错误,表明某些 pod 已关闭,因此存在停机时间。