將健康情況探查新增至您的服務
依預設,輸入控制器會為公開的 Pod 佈建 HTTP GET 探查。
您可以將整備或即時性探查新增至您的 deployment
/pod
規格,以自訂探查屬性。
搭配 readinessProbe
或 livenessProbe
apiVersion: networking.k8s.io/v1
kind: Deployment
metadata:
name: aspnetapp
spec:
replicas: 3
template:
metadata:
labels:
service: site
spec:
containers:
- name: aspnetapp
image: mcr.microsoft.com/dotnet/samples:aspnetapp
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
readinessProbe:
httpGet:
path: /
port: 80
periodSeconds: 3
timeoutSeconds: 1
Kubernetes API 參考:
注意
- 設定使用
readinessProbe
時,支援livenessProbe
和httpGet
。 - 目前不支援探查 Pod 上公開的連接埠以外的連接埠。
- 不支援
HttpHeaders
、InitialDelaySeconds
、SuccessThreshold
。
不含 readinessProbe
或 livenessProbe
如果未提供上述探查,則輸入控制器會假設服務可在為 backend-path-prefix
註釋指定的 Path
上或為服務的 ingress
定義中指定的 path
上連線。
健康情況探查的預設值
對於無法由整備/即時性探查推斷的任何屬性,會設定預設值。
應用程式閘道探查屬性 | 預設值 |
---|---|
Path |
/ |
Host |
localhost |
Protocol |
HTTP |
Timeout |
30 |
Interval |
30 |
UnhealthyThreshold |
3 |