1、首先是探针设置
readinessProbe:
failureThreshold: 3
httpGet:
path: /actuator/health
port: 8080
scheme: HTTP
initialDelaySeconds: 10
periodSeconds: 3
successThreshold: 1
timeoutSeconds: 1
livenessProbe:
failureThreshold: 3
httpGet:
path: /actuator/health
port: 8080
scheme: HTTP
initialDelaySeconds: 10
periodSeconds: 5
successThreshold: 1
timeoutSeconds: 1
备注:对以上参数解释
readinessProbe:就绪检测。用于确定容器是否已准备好接收流量。
livenessProbe:存活检测。用于确定容器是否仍然处于运行状态。
对以上参数描述如下:
就绪检测:
当容器启动10s后进行以http的方式首次就绪检测,每隔3s检测一次,如果成功1次,应用将准备接收流量,连续检测失败3次,容器将被认为不可用,不会接收流量。超时时间为1s。
存活检测:
当容器启动10s后进行以http的方式首次存活检测,每隔5s检测一次,如果检测失败3次,就认为容器不在健康,Kubernetes将尝试重启容器。检测超时时间为1s。
2、资源限制
resources:
limits:
cpu: 1000m
memory: 1024Mi
requests:
cpu: 100m
memory: 256Mi
备注:以上为Kubernetes资源的请求与限制
request:资源请求(指定容器运行时对资源的最小需求)低于实际使用时有可能会发生资源抢占,影响其他容器性能,节点资源不足,如果没有limits,有可能会导致节点OOM
limits:资源限制(指定容器能够使用的资源上限)超出限制后容器有会发生OOM,或者被集群驱出
1C=1000m(1核=1000毫核)