Skip to content

Commit 3019898

Browse files
authored
feat(apisixupstream): support healthcheck (#2574) (#279)
1 parent 54bcfab commit 3019898

File tree

8 files changed

+293
-26
lines changed

8 files changed

+293
-26
lines changed

api/adc/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ type UpstreamActiveHealthCheck struct {
204204
Host string `json:"host,omitempty" yaml:"host,omitempty"`
205205
Port int32 `json:"port,omitempty" yaml:"port,omitempty"`
206206
HTTPPath string `json:"http_path,omitempty" yaml:"http_path,omitempty"`
207-
HTTPSVerifyCert bool `json:"https_verify_certificate,omitempty" yaml:"https_verify_certificate,omitempty"`
207+
HTTPSVerifyCert bool `json:"https_verify_cert,omitempty" yaml:"https_verify_cert,omitempty"`
208208
HTTPRequestHeaders []string `json:"req_headers,omitempty" yaml:"req_headers,omitempty"`
209209
Healthy UpstreamActiveHealthCheckHealthy `json:"healthy,omitempty" yaml:"healthy,omitempty"`
210210
Unhealthy UpstreamActiveHealthCheckUnhealthy `json:"unhealthy,omitempty" yaml:"unhealthy,omitempty"`

api/v2/apisixupstream_types.go

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ type ApisixUpstreamExternalNode struct {
9191
Weight *int `json:"weight,omitempty" yaml:"weight"`
9292

9393
// Port specifies the port number on which the external node is accepting traffic.
94+
//
9495
// +kubebuilder:validation:Optional
96+
// +kubebuilder:validation:Minimum=1
97+
// +kubebuilder:validation:Maximum=65535
9598
Port *int `json:"port,omitempty" yaml:"port"`
9699
}
97100

@@ -118,7 +121,6 @@ type ApisixUpstreamConfig struct {
118121
Timeout *UpstreamTimeout `json:"timeout,omitempty" yaml:"timeout,omitempty"`
119122

120123
// HealthCheck defines the active and passive health check configuration for the upstream.
121-
// Deprecated: no longer supported in standalone mode.
122124
// +kubebuilder:validation:Optional
123125
HealthCheck *HealthCheck `json:"healthCheck,omitempty" yaml:"healthCheck,omitempty"`
124126

@@ -160,6 +162,8 @@ type PortLevelSettings struct {
160162
ApisixUpstreamConfig `json:",inline" yaml:",inline"`
161163

162164
// Port is a Kubernetes Service port.
165+
// +kubebuilder:validation:Minimum=1
166+
// +kubebuilder:validation:Maximum=65535
163167
Port int32 `json:"port" yaml:"port"`
164168
}
165169

@@ -221,9 +225,11 @@ type Discovery struct {
221225

222226
// ActiveHealthCheck defines the active upstream health check configuration.
223227
type ActiveHealthCheck struct {
228+
// Type is the health check type. Can be `http`, `https`, or `tcp`.
229+
//
224230
// +kubebuilder:validation:Optional
225231
// +kubebuilder:validation:Enum=http;https;tcp;
226-
// Type is the health check type. Can be `http`, `https`, or `tcp`.
232+
// +kubebuilder:default=http
227233
Type string `json:"type,omitempty" yaml:"type,omitempty"`
228234
// Timeout sets health check timeout in seconds.
229235
Timeout time.Duration `json:"timeout,omitempty" yaml:"timeout,omitempty"`
@@ -232,9 +238,10 @@ type ActiveHealthCheck struct {
232238
Concurrency int `json:"concurrency,omitempty" yaml:"concurrency,omitempty"`
233239
// Host sets the upstream host.
234240
Host string `json:"host,omitempty" yaml:"host,omitempty"`
235-
// +kubebuilder:validation:Minimum=0
236-
// +kubebuilder:validation:Maximum=65535
237241
// Port sets the upstream port.
242+
//
243+
// +kubebuilder:validation:Minimum=1
244+
// +kubebuilder:validation:Maximum=65535
238245
Port int32 `json:"port,omitempty" yaml:"port,omitempty"`
239246
// HTTPPath sets the HTTP probe request path.
240247
HTTPPath string `json:"httpPath,omitempty" yaml:"httpPath,omitempty"`
@@ -254,6 +261,10 @@ type ActiveHealthCheck struct {
254261
type PassiveHealthCheck struct {
255262
// Type specifies the type of passive health check.
256263
// Can be `http`, `https`, or `tcp`.
264+
//
265+
// +kubebuilder:validation:Optional
266+
// +kubebuilder:validation:Enum=http;https;tcp;
267+
// +kubebuilder:default=http
257268
Type string `json:"type,omitempty" yaml:"type,omitempty"`
258269
// Healthy defines the conditions under which an upstream node is considered healthy.
259270
Healthy *PassiveHealthCheckHealthy `json:"healthy,omitempty" yaml:"healthy,omitempty"`
@@ -304,6 +315,10 @@ type PassiveHealthCheckUnhealthy struct {
304315
// TCPFailures define the number of TCP failures to define an unhealthy target.
305316
TCPFailures int `json:"tcpFailures,omitempty" yaml:"tcpFailures,omitempty"`
306317
// Timeout sets health check timeout in seconds.
318+
// https://github.com/apache/apisix/blob/0151d9e35bba63d7c316187272d88e19db0be634/apisix/schema_def.lua#L196
319+
//
320+
// +kubebuilder:validation:Minimum=1
321+
// +kubebuilder:validation:Maximum=254
307322
Timeouts int `json:"timeout,omitempty" yaml:"timeout,omitempty"`
308323
}
309324

config/crd/bases/apisix.apache.org_apisixupstreams.yaml

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ spec:
8181
port:
8282
description: Port specifies the port number on which the external
8383
node is accepting traffic.
84+
maximum: 65535
85+
minimum: 1
8486
type: integer
8587
type:
8688
description: Type indicates the kind of external node. Can be
@@ -95,9 +97,8 @@ spec:
9597
minItems: 1
9698
type: array
9799
healthCheck:
98-
description: |-
99-
HealthCheck defines the active and passive health check configuration for the upstream.
100-
Deprecated: no longer supported in standalone mode.
100+
description: HealthCheck defines the active and passive health check
101+
configuration for the upstream.
101102
properties:
102103
active:
103104
description: Active health checks proactively send requests to
@@ -140,7 +141,7 @@ spec:
140141
description: Port sets the upstream port.
141142
format: int32
142143
maximum: 65535
143-
minimum: 0
144+
minimum: 1
144145
type: integer
145146
requestHeaders:
146147
description: RequestHeaders sets the request headers.
@@ -155,6 +156,7 @@ spec:
155156
format: int64
156157
type: integer
157158
type:
159+
default: http
158160
description: Type is the health check type. Can be `http`,
159161
`https`, or `tcp`.
160162
enum:
@@ -190,7 +192,11 @@ spec:
190192
minimum: 0
191193
type: integer
192194
timeout:
193-
description: Timeout sets health check timeout in seconds.
195+
description: |-
196+
Timeout sets health check timeout in seconds.
197+
https://github.com/apache/apisix/blob/0151d9e35bba63d7c316187272d88e19db0be634/apisix/schema_def.lua#L196
198+
maximum: 254
199+
minimum: 1
194200
type: integer
195201
type: object
196202
type: object
@@ -217,9 +223,14 @@ spec:
217223
type: integer
218224
type: object
219225
type:
226+
default: http
220227
description: |-
221228
Type specifies the type of passive health check.
222229
Can be `http`, `https`, or `tcp`.
230+
enum:
231+
- http
232+
- https
233+
- tcp
223234
type: string
224235
unhealthy:
225236
description: Unhealthy defines the conditions under which
@@ -245,7 +256,11 @@ spec:
245256
minimum: 0
246257
type: integer
247258
timeout:
248-
description: Timeout sets health check timeout in seconds.
259+
description: |-
260+
Timeout sets health check timeout in seconds.
261+
https://github.com/apache/apisix/blob/0151d9e35bba63d7c316187272d88e19db0be634/apisix/schema_def.lua#L196
262+
maximum: 254
263+
minimum: 1
249264
type: integer
250265
type: object
251266
type: object
@@ -344,9 +359,8 @@ spec:
344359
- type
345360
type: object
346361
healthCheck:
347-
description: |-
348-
HealthCheck defines the active and passive health check configuration for the upstream.
349-
Deprecated: no longer supported in standalone mode.
362+
description: HealthCheck defines the active and passive health
363+
check configuration for the upstream.
350364
properties:
351365
active:
352366
description: Active health checks proactively send requests
@@ -389,7 +403,7 @@ spec:
389403
description: Port sets the upstream port.
390404
format: int32
391405
maximum: 65535
392-
minimum: 0
406+
minimum: 1
393407
type: integer
394408
requestHeaders:
395409
description: RequestHeaders sets the request headers.
@@ -404,6 +418,7 @@ spec:
404418
format: int64
405419
type: integer
406420
type:
421+
default: http
407422
description: Type is the health check type. Can be `http`,
408423
`https`, or `tcp`.
409424
enum:
@@ -439,8 +454,11 @@ spec:
439454
minimum: 0
440455
type: integer
441456
timeout:
442-
description: Timeout sets health check timeout in
443-
seconds.
457+
description: |-
458+
Timeout sets health check timeout in seconds.
459+
https://github.com/apache/apisix/blob/0151d9e35bba63d7c316187272d88e19db0be634/apisix/schema_def.lua#L196
460+
maximum: 254
461+
minimum: 1
444462
type: integer
445463
type: object
446464
type: object
@@ -467,9 +485,14 @@ spec:
467485
type: integer
468486
type: object
469487
type:
488+
default: http
470489
description: |-
471490
Type specifies the type of passive health check.
472491
Can be `http`, `https`, or `tcp`.
492+
enum:
493+
- http
494+
- https
495+
- tcp
473496
type: string
474497
unhealthy:
475498
description: Unhealthy defines the conditions under
@@ -495,8 +518,11 @@ spec:
495518
minimum: 0
496519
type: integer
497520
timeout:
498-
description: Timeout sets health check timeout in
499-
seconds.
521+
description: |-
522+
Timeout sets health check timeout in seconds.
523+
https://github.com/apache/apisix/blob/0151d9e35bba63d7c316187272d88e19db0be634/apisix/schema_def.lua#L196
524+
maximum: 254
525+
minimum: 1
500526
type: integer
501527
type: object
502528
type: object
@@ -559,6 +585,8 @@ spec:
559585
port:
560586
description: Port is a Kubernetes Service port.
561587
format: int32
588+
maximum: 65535
589+
minimum: 1
562590
type: integer
563591
retries:
564592
description: |-

docs/en/latest/reference/api-reference.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ UpstreamActiveHealthCheckHealthy defines the conditions used to actively determi
661661
| `httpCodes` _integer array_ | HTTPCodes define a list of HTTP status codes that are considered unhealthy. |
662662
| `httpFailures` _integer_ | HTTPFailures define the number of HTTP failures to define an unhealthy target. |
663663
| `tcpFailures` _integer_ | TCPFailures define the number of TCP failures to define an unhealthy target. |
664-
| `timeout` _integer_ | Timeout sets health check timeout in seconds. |
664+
| `timeout` _integer_ | Timeout sets health check timeout in seconds. https://github.com/apache/apisix/blob/0151d9e35bba63d7c316187272d88e19db0be634/apisix/schema_def.lua#L196 |
665665
| `interval` _[Duration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#duration-v1-meta)_ | Interval defines the time interval for checking targets, in seconds. |
666666

667667

@@ -1320,7 +1320,7 @@ ApisixUpstreamConfig defines configuration for upstream services.
13201320
| `scheme` _string_ | Scheme is the protocol used to communicate with the upstream. Default is `http`. Can be `http`, `https`, `grpc`, or `grpcs`. |
13211321
| `retries` _integer_ | Retries defines the number of retry attempts APISIX should make when a failure occurs. Failures include timeouts, network errors, or 5xx status codes. |
13221322
| `timeout` _[UpstreamTimeout](#upstreamtimeout)_ | Timeout specifies the connection, send, and read timeouts for upstream requests. |
1323-
| `healthCheck` _[HealthCheck](#healthcheck)_ | HealthCheck defines the active and passive health check configuration for the upstream. Deprecated: no longer supported in standalone mode. |
1323+
| `healthCheck` _[HealthCheck](#healthcheck)_ | HealthCheck defines the active and passive health check configuration for the upstream. |
13241324
| `tlsSecret` _[ApisixSecret](#apisixsecret)_ | TLSSecret references a Kubernetes Secret that contains the client certificate and key for mutual TLS when connecting to the upstream. |
13251325
| `subsets` _[ApisixUpstreamSubset](#apisixupstreamsubset) array_ | Subsets defines labeled subsets of service endpoints, typically used for service versioning or canary deployments. |
13261326
| `passHost` _string_ | PassHost configures how the host header should be determined when a request is forwarded to the upstream. Default is `pass`. Can be `pass`, `node` or `rewrite`:<br /> • `pass`: preserve the original Host header<br /> • `node`: use the upstream node’s host<br /> • `rewrite`: set to a custom host via upstreamHost |
@@ -1380,7 +1380,7 @@ definitions and custom configuration.
13801380
| `scheme` _string_ | Scheme is the protocol used to communicate with the upstream. Default is `http`. Can be `http`, `https`, `grpc`, or `grpcs`. |
13811381
| `retries` _integer_ | Retries defines the number of retry attempts APISIX should make when a failure occurs. Failures include timeouts, network errors, or 5xx status codes. |
13821382
| `timeout` _[UpstreamTimeout](#upstreamtimeout)_ | Timeout specifies the connection, send, and read timeouts for upstream requests. |
1383-
| `healthCheck` _[HealthCheck](#healthcheck)_ | HealthCheck defines the active and passive health check configuration for the upstream. Deprecated: no longer supported in standalone mode. |
1383+
| `healthCheck` _[HealthCheck](#healthcheck)_ | HealthCheck defines the active and passive health check configuration for the upstream. |
13841384
| `tlsSecret` _[ApisixSecret](#apisixsecret)_ | TLSSecret references a Kubernetes Secret that contains the client certificate and key for mutual TLS when connecting to the upstream. |
13851385
| `subsets` _[ApisixUpstreamSubset](#apisixupstreamsubset) array_ | Subsets defines labeled subsets of service endpoints, typically used for service versioning or canary deployments. |
13861386
| `passHost` _string_ | PassHost configures how the host header should be determined when a request is forwarded to the upstream. Default is `pass`. Can be `pass`, `node` or `rewrite`:<br /> • `pass`: preserve the original Host header<br /> • `node`: use the upstream node’s host<br /> • `rewrite`: set to a custom host via upstreamHost |
@@ -1528,7 +1528,7 @@ UpstreamPassiveHealthCheckUnhealthy defines the conditions used to passively det
15281528
| `httpCodes` _integer array_ | HTTPCodes define a list of HTTP status codes that are considered unhealthy. |
15291529
| `httpFailures` _integer_ | HTTPFailures define the number of HTTP failures to define an unhealthy target. |
15301530
| `tcpFailures` _integer_ | TCPFailures define the number of TCP failures to define an unhealthy target. |
1531-
| `timeout` _integer_ | Timeout sets health check timeout in seconds. |
1531+
| `timeout` _integer_ | Timeout sets health check timeout in seconds. https://github.com/apache/apisix/blob/0151d9e35bba63d7c316187272d88e19db0be634/apisix/schema_def.lua#L196 |
15321532

15331533

15341534
_Appears in:_
@@ -1550,7 +1550,7 @@ them if they are set on the port level.
15501550
| `scheme` _string_ | Scheme is the protocol used to communicate with the upstream. Default is `http`. Can be `http`, `https`, `grpc`, or `grpcs`. |
15511551
| `retries` _integer_ | Retries defines the number of retry attempts APISIX should make when a failure occurs. Failures include timeouts, network errors, or 5xx status codes. |
15521552
| `timeout` _[UpstreamTimeout](#upstreamtimeout)_ | Timeout specifies the connection, send, and read timeouts for upstream requests. |
1553-
| `healthCheck` _[HealthCheck](#healthcheck)_ | HealthCheck defines the active and passive health check configuration for the upstream. Deprecated: no longer supported in standalone mode. |
1553+
| `healthCheck` _[HealthCheck](#healthcheck)_ | HealthCheck defines the active and passive health check configuration for the upstream. |
15541554
| `tlsSecret` _[ApisixSecret](#apisixsecret)_ | TLSSecret references a Kubernetes Secret that contains the client certificate and key for mutual TLS when connecting to the upstream. |
15551555
| `subsets` _[ApisixUpstreamSubset](#apisixupstreamsubset) array_ | Subsets defines labeled subsets of service endpoints, typically used for service versioning or canary deployments. |
15561556
| `passHost` _string_ | PassHost configures how the host header should be determined when a request is forwarded to the upstream. Default is `pass`. Can be `pass`, `node` or `rewrite`:<br /> • `pass`: preserve the original Host header<br /> • `node`: use the upstream node’s host<br /> • `rewrite`: set to a custom host via upstreamHost |

docs/en/latest/upgrade-guide.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ spec:
143143
Due to current limitations in the [ADC](https://github.com/api7/adc) component, the following fields are not yet supported:
144144

145145
* `spec.discovery`: Service Discovery
146-
* `spec.healthCheck`: Health Checking
147146

148147
More details: [ADC Backend Differences](https://github.com/api7/adc/blob/2449ca81e3c61169f8c1e59efb4c1173a766bce2/libs/backend-apisix-standalone/README.md#differences-in-upstream)
149148

0 commit comments

Comments
 (0)