探针探测对sts pod域名解析是否成功的影响
k8s 1.19.0
初始情况
apiVersion: v1
kind: Service
metadata:
name: nginx
spec:
ports:
- port: 80
selector:
app: nginx
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: nginx
spec:
podManagementPolicy: Parallel
serviceName: nginx
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.9.1
创建ClusterIP类型的service和StatefulSet之后,Pod域名可以直接解析。
10.16.0.17是coredns IP。
场景一:只增加readinessProbe
readinessProbe:
httpGet:
scheme: HTTP
port: 80
initialDelaySeconds: 300
periodSeconds: 10
timeoutSeconds: 1
successThreshold: 1
failureThreshold: 3
在readinessProbe检查成功之前,endpoint一直没有且Pod域名解析失败。
场景二:只增加livenessProbe
livenessProbe:
httpGet:
scheme: HTTP
port: 80
initialDelaySeconds: 60
periodSeconds: 10
timeoutSeconds: 1
successThreshold: 1
failureThreshold: 3
在livenessProbe检查成功之前,endpoint一直有且Pod域名解析成功。
场景三:只增加startupProbe
startupProbe:
httpGet:
scheme: HTTP
port: 80
initialDelaySeconds: 60
periodSeconds: 10
timeoutSeconds: 1
successThreshold: 1
failureThreshold: 3
在startupProbe检查成功之前,endpoint一直没有且Pod域名解析失败。