配置上游健康检查
健康检查是一种根据上游服务的响应能力来确定其健康状况的机制。启用健康检查后,APISIX 将仅将请求转发到被视为健康的上游服务,而不会将请求转发到被视为不健康的服务。
健康检查通常有两种方法:
- 主动健康检查:APISIX 主动并定期向上游服务发送请求,并根据这些请求的响应确定其健康状况。
- 被动健康检查:APISIX 根据上游服务对客户端请求的响应来确定其健康状况,而无需主动探测。
本指南将向你展示如何为你的上游服务配置主动和被动健康检查。
如果你将 APISIX Ingress Controller RC5 与独立模式下的 APISIX 一起使用,目前存在一个问题,即 Control API 不返回健康检查数据。当 APISIX 在带有 etcd 的传统模式下运行时,不会发生此问题。
前置条件
启动示例上游服务
- Docker
- Kubernetes
在与 APISIX 相同的 Docker 网络中启动两个 NGINX 实例作为示例上游服务:
DOCKER_NETWORK=apisix-quickstart-net
docker run -d -p 8080:80 --network=${DOCKER_NETWORK} --name nginx1 nginx
docker run -d -p 8081:80 --network=${DOCKER_NETWORK} --name nginx2 nginx
为部署两个 NGINX 实例作为示例上游服务创建一个 Kubernetes 清单文件:
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: ingress-apisix
name: nginx1
spec:
replicas: 1
selector:
matchLabels:
app: nginx1
template:
metadata:
labels:
app: nginx1
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
namespace: ingress-apisix
name: nginx1
spec:
selector:
app: nginx1
ports:
- port: 8080
targetPort: 80
---
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: ingress-apisix
name: nginx2
spec:
replicas: 1
selector:
matchLabels:
app: nginx2
template:
metadata:
labels:
app: nginx2
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
namespace: ingress-apisix
name: nginx2
spec:
selector:
app: nginx2
ports:
- port: 8081
targetPort: 80
将配置应用到你的集群:
kubectl apply -f nginx.yaml
通过端口转发将 NGINX 服务端口暴露到本地计算机:
kubectl port-forward svc/nginx1 8080:8080 &
kubectl port-forward svc/nginx2 8081:8081 &
验证两个 NGINX 实例都在运行:
for port in 8080 8081; do
curl -s "http://127.0.0.1:$port" | grep -q "Welcome to nginx" &&
echo "NGINX welcome page available on port $port."
done
你应该看到以下响应:
NGINX welcome page available on port 8080.
NGINX welcome page available on port 8081.
配置主动健康检查
主动检查通过定期向服务发送请求或探测并查看它们的响应情况来确定上游服务的健康状况。
在本节中,你将通过两个带有验证步骤的示例来了解:
- 主动检查如何检测上游状态的变化
- 当所有上游状态都不健康时,APISIX 如何将客户端请求转发到上游服务
示例:上游服务状态更改
以下示例演示了 APISIX 主动健康检查如何响应健康上游服务变为:部分不可用、全部不可用以及全部恢复的情况。
创建一个指向这两个服务的路由,并配置每 2 秒运行一次的主动健康检查:
- Admin API
- ADC
- Ingress Controller
curl "http://127.0.0.1:9180/apisix/admin/routes" -X PUT -d '
{
"id": "example-hc-route",
"uri":"/",
"upstream": {
"type":"roundrobin",
"nodes": {
"nginx1:80": 1,
"nginx2:80": 1
},
"checks": {
"active": {
// Annotate 1
"type": "http",
// Annotate 2
"http_path": "/",
"healthy": {
// Annotate 3
"interval": 2,
// Annotate 4
"successes": 1
},
"unhealthy": {
// Annotate 5
"interval": 1,
// Annotate 6
"timeouts": 3
}
}
}
}
}'
❶ type:主动健康检查的类型。
❷ http_path:要主动探测的 HTTP 请求路径。
❸ healthy.interval:定期检查健康节点的时间间隔(以秒为单位)。
❹ healthy.successes:判定上游节点为健康的成功计数阈值。
❺ unhealthy.interval:定期检查不健康节点的时间间隔(以秒为单位)。
❻ unhealthy.timeouts:判定上游节点为不健康的超时计数阈值。
services:
- name: Nginx Service
routes:
- uris:
- /
name: example-hc-route
upstream:
type: roundrobin
nodes:
- host: nginx1
port: 80
weight: 1
- host: nginx2
port: 80
weight: 1
checks:
active:
// Annotate 1
type: http
// Annotate 2
http_path: /
healthy:
// Annotate 3
interval: 2
// Annotate 4
successes: 1
unhealthy:
// Annotate 5
interval: 1
// Annotate 6
timeouts: 3
❶ type:主动健康检查的类型。
❷ http_path:要主动探测的 HTTP 请求路径。
❸ healthy.interval:定期检查健康节点的时间间隔(以秒为单位)。
❹ healthy.successes:判定上游节点为健康的成功计数阈值。
❺ unhealthy.interval:定期检查不健康节点的时间间隔(以秒为单位)。
❻ unhealthy.timeouts:判定上游节点为不健康的超时计数阈值。
将配置同步到 APISIX:
adc sync -f adc.yaml
- Gateway API
- APISIX CRD
APISIX Ingress Controller 目前不支持使用 Gateway API 配置上游健康检查。
apiVersion: apisix.apache.org/v2
kind: ApisixUpstream
metadata:
namespace: ingress-apisix
name: nginx
spec:
ingressClassName: apisix
externalNodes:
- type: Service
name: nginx1
port: 8080
- type: Service
name: nginx2
port: 8081
healthCheck:
active:
// Annotate 1
type: http
// Annotate 2
httpPath: /
healthy:
// Annotate 3
interval: 2s
// Annotate 4
successes: 1
unhealthy:
// Annotate 5
interval: 1s
// Annotate 6
timeout: 3
---
apiVersion: apisix.apache.org/v2
kind: ApisixRoute
metadata:
namespace: ingress-apisix
name: example-hc-route
spec:
ingressClassName: apisix
http:
- name: nginx-hc
match:
paths:
- /
upstreams:
- name: nginx
❶ type:主动健康检查的类型。
❷ httpPath:要主动探测的 HTTP 请求路径。
❸ healthy.interval:定期检查健康节点的时间间隔(以秒为单位)。
❹ healthy.successes:判定上游节点为健康的成功计数阈值。
❺ unhealthy.interval:定期检查不健康节点的时间 间隔(以秒为单位)。
❻ unhealthy.timeout:判定上游节点为不健康的超时计数阈值。
将配置应用到你的集群:
kubectl apply -f active-health-checks.yaml
验证
你将验证上述配置,以了解 APISIX 上游健康检查在不同场景下的响应:
- 当 所有上游服务都健康时
- 当 只有部分服务健康时
- 当 没有服务健康时
- 当 所有服务都恢复时
- Docker
- Kubernetes
如果你使用 快速入门 在 Docker 中启动 APISIX,Control API 端口 9090 已经映射 (-p 9090:9090)。
如果你使用的是 ingress controller,请启用 Control API 服务并将其端口转发到本地计算机。
首先导出所有值(包括默认值):
helm get values -n ingress-apisix apisix --all > values.yaml
在 values 文件中,更新以下部分值如下:
apisix:
enabled: true
control:
enabled: true
升级发布:
helm upgrade -n ingress-apisix apisix apisix/apisix -f values.yaml
转发 Control API 端口:
kubectl port-forward service/apisix-control 9090:9090 &
验证两个上游服务都健康
向路由发送请求以开始健康检查:
curl "http://127.0.0.1:9080/"
要查看上游健康状态,请向 Control API 中的健康检查端点发送请求:
curl "http://127.0.0.1:9090/v1/healthcheck"
你应该看到类似以下的响应 :
[
{
"name": "/apisix/routes/example-hc-route",
"type": "http",
"nodes": [
{
"port": 80,
"counter": {
"http_failure": 0,
"tcp_failure": 0,
"timeout_failure": 0,
"success": 0
},
"ip": "172.24.0.5",
"status": "healthy"
},
{
"port": 80,
"counter": {
"http_failure": 0,
"tcp_failure": 0,
"timeout_failure": 0,
"success": 0
},
"ip": "172.24.0.4",
"status": "healthy"
}
]
}
]
验证当一个上游服务不可用时
使一个上游服务暂时不可用,以验证 APISIX 是否报告其中一个上游服务不健康:
- Docker
- Kubernetes
docker container stop nginx1
kubectl scale deployment nginx1 -n ingress-apisix --replicas=0
等待几秒钟,然后向健康检查端点发送请求:
curl "http://127.0.0.1:9090/v1/healthcheck"
你应该看到类似以下的响应,显示其中一个上游节点有 3 次超时失败并被标记为不健康:
[
{
"name": "/apisix/routes/example-hc-route",
"type": "http",
"nodes": [
{
"port": 80,
"counter": {
"http_failure": 0,
"tcp_failure": 0,
"timeout_failure": 0,
"success": 0
},
"ip": "172.24.0.5",
"status": "healthy"
},
{
"port": 80,
"counter": {
"http_failure": 0,
"tcp_failure": 0,
"timeout_failure": 3,
"success": 0
},
"ip": "172.24.0.4",
"status": "unhealthy"
}
]
}
]
向路由发送请求,查看 APISIX 是否将请求转发到另一个健康节点:
curl -i "http://127.0.0.1:9080/"
你应该收到 HTTP/1.1 200 OK 响应。
验证两个上游服务都不可用
使另一个上游服务暂时不可用,以验证 APISIX 是否报告两个上游服务都不健康:
- Docker
- Kubernetes
docker container stop nginx2
kubectl scale deployment nginx2 -n ingress-apisix --replicas=0
等待几秒钟,然后向健康检查端点发送请求:
curl "http://127.0.0.1:9090/v1/healthcheck"
你应该看到类似以下的响应,显示两个上游节点都有 3 次超时失败并被标记为不健康:
[
{
"name": "/apisix/routes/example-hc-route",
"type": "http",
"nodes": [
{
"port": 80,
"counter": {
"http_failure": 0,
"tcp_failure": 0,
"timeout_failure": 3,
"success": 0
},
"ip": "172.24.0.5",
"status": "unhealthy"
},
{
"port": 80,
"counter": {
"http_failure": 0,
"tcp_failure": 0,
"timeout_failure": 3,
"success": 0
},
"ip": "172.24.0.4",
"status": "unhealthy"
}
]
}
]
向路由发送请求:
curl -i "http://127.0.0.1:9080/"
你应该收到 HTTP/1.1 502 Bad Gateway 响应。
验证两个上游服务都已恢复
使两个服务再次可用,以验证 APISIX 是否报告两个上游服务都健康:
- Docker
- Kubernetes
docker container start nginx1 nginx2
kubectl scale deployment -n ingress-apisix nginx1 nginx2 --replicas=1
等待几秒钟,然后向健康检查端点发送请求:
curl "http://127.0.0.1:9090/v1/healthcheck"
你应该看到显示两个上游节点都健康的响应,类似于 开始时两个服务都健康的情况。
示例:当状态不健康时转发请求
以下示例演示了即使所有上游健康状态都不健康,APISIX 仍会将客户端请求转发到上游服务。
创建一个指向这两个服务的路由,并配置每 2 秒运行一次的主动健康检查:
- Admin API
- ADC
- Ingress Controller
curl "http://127.0.0.1:9180/apisix/admin/routes" -X PUT -d '
{
"id": "example-hc-route",
"uri":"/",
"upstream": {
"type":"roundrobin",
"nodes": {
"nginx1:80": 1,
"nginx2:80": 1
},
"checks": {
"active": {
// Annotate 1
"type": "http",
// Annotate 2
"http_path": "/404",
"healthy": {
"interval": 2,
"successes": 1
},
"unhealthy": {
"interval": 1,
// Annotate 3
"http_failures": 2
}
}
}
}
}'
❶ type:主动健康检查的类型。
❷ http_path:要主动探测的 HTTP 请求路径。为方便演示,这里设置为 /404,这是一个上游服务中不存在的路径。因此,主动健康检查应始终认为这两个服务不健康。
❸ unhealthy.http_failures:判定上游节点为不健康的 HTTP 失败计数阈值。
services:
- name: Nginx Service
routes:
- uris:
- /
name: example-hc-route
upstream:
type: roundrobin
nodes:
- host: nginx1
port: 80
weight: 1
- host: nginx2
port: 80
weight: 1
checks:
active:
// Annotate 1
type: http
// Annotate 2
http_path: /404
healthy:
interval: 2
successes: 1
unhealthy:
interval: 1
// Annotate 3
http_failures: 3
❶ type:主动健康检查的类型。
❷ http_path:要主动探测的 HTTP 请求路径。为方便演示,这里设置为 /404,这是一个上游服务中不存在的路径。因此,主动健康检查应始终认为这两个服务不健康。
❸ unhealthy.http_failures:判定上游节点为不健康的 HTTP 失败计数阈值。
将配置同步到 APISIX:
adc sync -f adc.yaml
- Gateway API
- APISIX CRD
APISIX Ingress Controller 目前不支持使用 Gateway API 配置上游健康检查。
apiVersion: apisix.apache.org/v2
kind: ApisixUpstream
metadata:
namespace: ingress-apisix
name: nginx
spec:
ingressClassName: apisix
externalNodes:
- type: Service
name: nginx1
port: 8080
- type: Service
name: nginx2
port: 8081
healthCheck:
active:
// Annotate 1
type: http
// Annotate 2
httpPath: /404
healthy:
interval: 2s
successes: 1
unhealthy:
interval: 1s
// Annotate 3
httpFailures: 2
---
apiVersion: apisix.apache.org/v2
kind: ApisixRoute
metadata:
namespace: ingress-apisix
name: example-hc-route
spec:
ingressClassName: apisix
http:
- name: nginx-hc
match:
paths:
- /
upstreams:
- name: nginx
❶ type:主动健康检查的类型。
❷ httpPath:要主动探测的 HTTP 请求路径。为方便演示,这里设置为 /404,这是一个上游服务中不存在的路径。因此,主动健康检查应始终认为这两个服务不健康。
❸ unhealthy.httpFailures:判定上游节点为不健康的 HTTP 失败计数阈值。
将配置应用到你的集群:
kubectl apply -f active-health-checks.yaml
验证
- Docker
- Kubernetes
如果你使用 快速入门 在 Docker 中启动 APISIX,Control API 端口 9090 已经映射 (-p 9090:9090)。
如果你使用的是 ingress controller,请启用 Control API 服务并将其端口转发到本地计算机。
首先导出所有值(包括默认值):
helm get values -n ingress-apisix apisix --all > values.yaml
在 values 文件中,更新以下部分值如下:
apisix:
enabled: true
control:
enabled: true
升级发布:
helm upgrade -n ingress-apisix apisix apisix/apisix -f values.yaml
转发 Control API 端口:
kubectl port-forward service/apisix-control 9090:9090 &
向路由发送请求以开始健康检查:
curl -i "http://127.0.0.1:9080/"
你应该收到 HTTP/1.1 200 OK 响应。
向健康检查端点发送请求:
curl "http://127.0.0.1:9090/v1/healthcheck"
你应该看到类似以下的响应:
[
{
"name": "/apisix/routes/example-hc-route",
"nodes": [
{
"counter": {
"timeout_failure": 0,
"http_failure": 2,
"success": 0,
"tcp_failure": 0
},
"port": 80,
"ip": "172.25.0.5",
"status": "unhealthy"
},
{
"counter": {
"timeout_failure": 0,
"http_failure": 2,
"success": 0,
"tcp_failure": 0
},
"port": 80,
"ip": "172.25.0.4",
"status": "unhealthy"
}
],
"type": "http"
}
]
向路由发送请求以查看 APISIX 是否仍转发请求:
curl -i "http://127.0.0.1:9080/"
你应该收到 HTTP/1.1 200 OK 响应。这验证了即使两个服务都被标记为不健康,APISIX 仍会将客户端请求转发到上游服务。
配置被动健康检查
APISIX 要求将主动健康检查与被动健康检查一起使用。当上游服务变得不健康时,主动健康检查会定期检查上游服务是否已恢复。
目前已知存在一个问题,即通过 Control API 显示的健康检查数据无法准确反映实际健康状态,因此你的测试结果可能与所示示例不同。此问题正在积极解决中。但是,被动健康检查机制本身运行正常,并继续按预期路由请求。
示例:上游服务状态更改
创建指向这两个服务的路由,并配置主动和被动健康检查:
- Admin API
- ADC
- Ingress Controller
curl "http://127.0.0.1:9180/apisix/admin/routes" -X PUT -d '
{
"id": "example-hc-route",
// Annotate 1
"uri": "/404",
"upstream": {
"type": "roundrobin",
"nodes": {
"nginx1:80": 1,
"nginx2:80": 1
},
"checks": {
"active": {
"type": "http",
"http_path": "/",
"healthy": {
// Annotate 2
"interval": 99999,
"successes": 1
},
"unhealthy": {
// Annotate 3
"interval": 30
}
},
"passive": {
"healthy": {
// Annotate 4
"http_statuses": [200,201,202,300,301,302],
"successes": 1
},
"unhealthy": {
// Annotate 5
"http_statuses": [429,404,500,501,502,503,504,505],
// Annotate 6
"http_failures": 3
}
}
}
}
}'
❶ uri:路由匹配的 URI 路径。为方便演示,这里设置为 /404,这是一个上游服务中不存在的路径。因此,当发出请求时,两个上游服务都应响应 404 状态代码。
❷ active.healthy.interval:定期检查健康节点的时间间隔(以秒为单位)。
❸ active.unhealthy.interval:定期检查不健康节点的时间间隔(以秒为单位)。
❹ passive.healthy.http_statuses:被视为健康的响应 HTTP 状态代码。
❺ passive.unhealthy.http_statuses:被视为不健康的响应 HTTP 状态代码。不健康的响应会计入 http_failures。
❻ passive.unhealthy.http_failures:判定上游节点为不健康的 HTTP 失败计数阈值。
services:
- name: Nginx Service
routes:
- uris:
// Annotate 1
- /404
name: example-hc-route
upstream:
type: roundrobin
nodes:
- host: nginx1
port: 80
weight: 1
- host: nginx2
port: 80
weight: 1
checks:
active:
type: http
http_path: /
healthy:
// Annotate 2
interval: 99999
successes: 1
unhealthy:
// Annotate 3
interval: 30
passive:
healthy:
// Annotate 4
http_statuses:
- 200
- 201
- 202
- 300
- 301
- 302
successes: 1
unhealthy:
// Annotate 5
http_statuses:
- 429
- 404
- 500
- 501
- 502
- 503
- 504
- 505
// Annotate 6
http_failures: 3
❶ uris:路由匹配的 URI 路径。为方便演示,这里设置为 /404,这是一个上游服务中不存在的路径。因此,当发出请求时,两个上游服务都应响应 404 状态代码。
❷ active.healthy.interval:定期检查健康节点的时间间隔(以秒为单位)。
❸ active.unhealthy.interval:定期检查不健康节点的时间间隔(以秒为单位)。
❹ passive.healthy.http_statuses:被视为健康的响应 HTTP 状态代码。
❺ passive.unhealthy.http_statuses:被视为不健康的响应 HTTP 状态代码。不健康的响应会计入 http_failures。
❻ passive.unhealthy.http_failures:判定上游节点为不健康的 HTTP 失败计数阈值。
将配置同步到 APISIX:
adc sync -f adc.yaml
- Gateway API
- APISIX CRD
APISIX Ingress Controller 目前不支持使用 Gateway API 配置上游健康检查。
apiVersion: apisix.apache.org/v2
kind: ApisixUpstream
metadata:
namespace: ingress-apisix
name: nginx
spec:
ingressClassName: apisix
externalNodes:
- type: Service
name: nginx1
port: 8080
- type: Service
name: nginx2
port: 8081
healthCheck:
active:
type: http
httpPath: /
healthy:
// Annotate 2
interval: 99999s
successes: 1
unhealthy:
// Annotate 3
interval: 30s
passive:
healthy:
// Annotate 4
httpCodes: [200,201,202,300,301,302]
successes: 1
unhealthy:
// Annotate 5
httpCodes: [429,404,500,501,502,503,504,505]
// Annotate 6
httpFailures: 3
---
apiVersion: apisix.apache.org/v2
kind: ApisixRoute
metadata:
namespace: ingress-apisix
name: example-hc-route
spec:
ingressClassName: apisix
http:
- name: nginx-hc
match:
paths:
// Annotate 1
- /404
upstreams:
- name: nginx
❶ paths:路由匹配的 URI 路径。为方便演示,这里设置为 /404,这是一个上游服务中不存在的路径。因此,当发出请求时,两个上游服务都应响应 404 状态代码。
❷ active.healthy.interval:定期检查健康节点的时间间隔(以秒为单位)。
❸ active.unhealthy.interval:定期检查不健康节点的时间间隔(以秒为单位)。
❹ passive.healthy.httpCodes:被视为健康的响应 HTTP 状态代码。
❺ passive.unhealthy.httpCodes:被视为不健康的响应 HTTP 状态代码。不健康的响应会计入 httpFailures。
❻ passive.unhealthy.httpFailures:判定上游节点为不健康的 HTTP 失败计数阈值。
将配置应用到你的集群:
kubectl apply -f passive-health-checks.yaml
验证
- Docker
- Kubernetes
如果你使用 快速入门 在 Docker 中启动 APISIX,Control API 端口 9090 已经映射 (-p 9090:9090)。
如果你使用的是 ingress controller,请启用 Control API 服务并将其端口转发到本地计算机。
首先导出所有值(包括默认值):
helm get values -n ingress-apisix apisix --all > values.yaml
在 values 文件中,更新以下部分值如下:
apisix:
enabled: true
control:
enabled: true
升级发布:
helm upgrade -n ingress-apisix apisix apisix/apisix -f values.yaml
转发 Control API 端口:
kubectl port-forward service/apisix-control 9090:9090 &
向路由发送请求以开始健康检查 :
curl -i "http://127.0.0.1:9080/404"
你应该看到 HTTP/1.1 404 Not Found 响应。
向健康检查端点发送请求:
curl "http://127.0.0.1:9090/v1/healthcheck"
你应该看到类似以下的响应:
[
{
"name": "/apisix/routes/example-hc-route",
"nodes": [
{
"counter": {
"timeout_failure": 0,
// Annotate 1
"http_failure": 1,
"success": 0,
"tcp_failure": 0
},
"port": 80,
"ip": "172.25.0.5",
// Annotate 2
"status": "mostly_healthy"
},
{
"counter": {
"timeout_failure": 0,
"http_failure": 0,
"success": 0,
"tcp_failure": 0
},
"port": 80,
"ip": "172.25.0.4",
"status": "healthy"
}
],
"type": "http"
}
]
❶ http_failure 的计数为 1,这是由于前一个请求的 404 响应。
❷ mostly_healthy 状态表示当前节点状态健康,但 APISIX 开始在健康检查期间收到不健康的指示。
生成连续请求以调用 404 响应:
resp=$(seq 10 | xargs -I{} curl "http://127.0.0.1:9080/404" -o /dev/null -s -w "%{http_code}\n") && \
count=$(echo "$resp" | grep "404" | wc -l) && \
echo "Invoked $count responses with 404 status code."
向健康检查端点发送请求:
curl "http://127.0.0.1:9090/v1/healthcheck"
你应该看到类似以下的响应:
[
{
"name": "/apisix/routes/example-hc-route",
"nodes": [
{
"counter": {
"timeout_failure": 0,
"http_failure": 3,
"success": 0,
"tcp_failure": 0
},
"port": 80,
"ip": "172.25.0.4",
"status": "unhealthy"
},
{
"counter": {
"timeout_failure": 0,
"http_failure": 4,
"success": 0,
"tcp_failure": 0
},
"port": 80,
"ip": "172.25.0.5",
"status": "unhealthy"
}
],
"type": "http"
}
]
等待至少 30 秒,以便主动检查探测 / 处的上游服务并将其标记为健康。然后,向健康检查端点发送请求:
curl "http://127.0.0.1:9090/v1/healthcheck"
你应该看到类似以下的响应:
[
{
"name": "/apisix/routes/example-hc-route",
"nodes": [
{
"counter": {
"timeout_failure": 0,
"http_failure": 0,
"success": 1,
"tcp_failure": 0
},
"port": 80,
"ip": "172.25.0.4",
"status": "healthy"
},
{
"counter": {
"timeout_failure": 0,
"http_failure": 0,
"success": 1,
"tcp_failure": 0
},
"port": 80,
"ip": "172.25.0.5",
"status": "healthy"
}
],
"type": "http"
}
]
禁用所有健康检查
你可以全局禁用所有上游健康检查。这在紧急维护等场景中很有用,因为健康检查可能会干扰路由或回退行为。
- Docker
- Kubernetes
要禁用所有健康检查,请按如下方式更新你的 配置文件:
apisix:
disable_upstream_healthcheck: true
重新加载 APISIX 以使配置更改生效:
docker exec apisix-quickstart apisix reload
Helm chart 尚未包含此值。作为一种临时解决方法(不建议用于生产),你可以手动更新 APISIX ConfigMap:
kubectl edit cm apisix -n ingress-apisix
更新以下部分值:
apisix:
disable_upstream_healthcheck: true
保存更改后,重新启动 APISIX 部署以应用更改:
kubectl rollout restart deployment apisix -n ingress-apisix