apiVersion: apps/v1
kind: Deployment
metadata:
name: test
namespace: ns
spec:
replicas: 1
selector:
matchLabels:
app: test
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1 #使用默认的滚动更新升级策略的一个 Deployment 定义,在更新过程中最多可以有一个超过副本数的容器(maxSurge)
maxUnavailable: 0 #在更新过程中没有不可用的容器
template:
metadata:
name: test
labels:
app: test
version: v1
spec:
serviceAccountName: sa-admin
imagePullSecrets:
- name: docker-hub-secret
containers:
- image: ns/test:test
name: test
imagePullPolicy: Always #测试环境总是Always
ports:
- name: http
containerPort: 80
readinessProbe:
httpGet:
path: /actuator/health
port: http
initialDelaySeconds: 5 #容器启动后要等待多少秒后存活和就绪探测器才被初始化,默认是 0 秒,最小值是 0。
timeoutSeconds: 2 #探测的超时后等待多少秒。默认值是 1 秒。最小值是 1。
periodSeconds: 3 #执行探测的时间间隔(单位是秒)。默认是 10 秒。最小值是 1。
failureThreshold: 4 #探测失败时,Kubernetes 的重试次数。 存活探测情况下的放弃就意味着重新启动容器。 就绪探测情况下的放弃 Pod 会被打上未就绪的标签。默认值是 3。最小值是 1。
livenessProbe:
httpGet:
path: /actuator/health
port: http
initialDelaySeconds: 3
resources:
requests:
cpu: 500m
memory: 600Mi
limits:
cpu: 1500m
memory: 3000Mi
nodeSelector:
os: centos
K8S滚动部署 存活探针以及就绪探针
最新推荐文章于 2023-11-07 01:28:36 发布