# 自定义资源定义 API 参考

本文档提供了 Ingress Controller 自定义资源定义（CRD）的 API 资源描述。

产品可用性

此参考文档同时包含 API7 Ingress Controller 2.2.1 和 APISIX Ingress Controller 2.2.0 发布的 CRD。v1alpha1 `ControlPlaneProvider.caCert` 和 `Plugin.secretRef` 字段仅在 API7 Ingress Controller 2.2.1 中可用，当前发布的 APISIX Ingress Controller 2.2.0 不支持。其余 Schema 由两个已发布 Controller 共用。

## 包[​](#包 "包的直接链接")

* [apisix.apache.org/v1alpha1](#apisixapacheorgv1alpha1)
* [apisix.apache.org/v2](#apisixapacheorgv2)

## apisix.apache.org/v1alpha1[​](#apisixapacheorgv1alpha1 "apisix.apache.org/v1alpha1的直接链接")

包 v1alpha1 包含 apisix.apache.org v1alpha1 API 组的 API Schema 定义。

* [BackendTrafficPolicy](#backendtrafficpolicy)
* [Consumer](#consumer)
* [GatewayProxy](#gatewayproxy)
* [HTTPRoutePolicy](#httproutepolicy)
* [L4RoutePolicy](#l4routepolicy)
* [PluginConfig](#pluginconfig)

### BackendTrafficPolicy[​](#backendtrafficpolicy "BackendTrafficPolicy的直接链接")

BackendTrafficPolicy 定义了应用于后端服务的流量处理策略配置。

| 字段                                                                                                               | 描述                                                                                                    |
| ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------- |
| `apiVersion` *string*                                                                                              | `apisix.apache.org/v1alpha1`                                                                            |
| `kind` *string*                                                                                                    | `BackendTrafficPolicy`                                                                                  |
| `metadata` *[ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#objectmeta-v1-meta)* | 有关 `metadata` 字段的详细信息，请参阅 Kubernetes API 文档。                                            |
| `spec` *[BackendTrafficPolicySpec](#backendtrafficpolicyspec)*                                                     | BackendTrafficPolicySpec 定义了应用于后端服务的流量处理策略，例如负载均衡策略、连接设置和故障转移行为。 |

### Consumer[​](#consumer "Consumer的直接链接")

Consumer 定义了消费者的配置。

| 字段                                                                                                               | 描述                                                                  |
| ------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------- |
| `apiVersion` *string*                                                                                              | `apisix.apache.org/v1alpha1`                                          |
| `kind` *string*                                                                                                    | `Consumer`                                                            |
| `metadata` *[ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#objectmeta-v1-meta)* | 有关 `metadata` 字段的详细信息，请参阅 Kubernetes API 文档。          |
| `spec` *[ConsumerSpec](#consumerspec)*                                                                             | ConsumerSpec 定义了消费者的配置，包括消费者名称、认证凭证和插件设置。 |

### GatewayProxy[​](#gatewayproxy "GatewayProxy的直接链接")

GatewayProxy 定义了用于将流量路由到服务的网关代理实例的配置。

| 字段                                                                                                               | 描述                                                                            |
| ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------- |
| `apiVersion` *string*                                                                                              | `apisix.apache.org/v1alpha1`                                                    |
| `kind` *string*                                                                                                    | `GatewayProxy`                                                                  |
| `metadata` *[ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#objectmeta-v1-meta)* | 有关 `metadata` 字段的详细信息，请参阅 Kubernetes API 文档。                    |
| `spec` *[GatewayProxySpec](#gatewayproxyspec)*                                                                     | GatewayProxySpec 定义了网关代理实例的配置，包括网络设置、全局插件和插件元数据。 |

### HTTPRoutePolicy[​](#httproutepolicy "HTTPRoutePolicy的直接链接")

HTTPRoutePolicy 定义了流量策略的配置。

| 字段                                                                                                               | 描述                                                                              |
| ------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------- |
| `apiVersion` *string*                                                                                              | `apisix.apache.org/v1alpha1`                                                      |
| `kind` *string*                                                                                                    | `HTTPRoutePolicy`                                                                 |
| `metadata` *[ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#objectmeta-v1-meta)* | 有关 `metadata` 字段的详细信息，请参阅 Kubernetes API 文档。                      |
| `spec` *[HTTPRoutePolicySpec](#httproutepolicyspec)*                                                               | HTTPRoutePolicySpec 定义了 HTTPRoutePolicy 的配置，包括路由优先级和请求匹配条件。 |

### L4RoutePolicy[​](#l4routepolicy "L4RoutePolicy的直接链接")

L4RoutePolicy 为 Gateway API L4 路由（TCPRoute、UDPRoute、TLSRoute）定义插件配置。它遵循 Gateway API Policy Attachment 模式，将 APISIX stream 插件挂载到目标 L4 路由资源。

| 字段                                                                                                               | 描述                                                         |
| ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------ |
| `apiVersion` *string*                                                                                              | `apisix.apache.org/v1alpha1`                                 |
| `kind` *string*                                                                                                    | `L4RoutePolicy`                                              |
| `metadata` *[ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#objectmeta-v1-meta)* | 有关 `metadata` 字段的详细信息，请参阅 Kubernetes API 文档。 |
| `spec` *[L4RoutePolicySpec](#l4routepolicyspec)*                                                                   | Spec 定义 L4RoutePolicy 的期望状态。                         |

### PluginConfig[​](#pluginconfig "PluginConfig的直接链接")

PluginConfig 定义了插件配置。

| 字段                                                                                                               | 描述                                                                      |
| ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------- |
| `apiVersion` *string*                                                                                              | `apisix.apache.org/v1alpha1`                                              |
| `kind` *string*                                                                                                    | `PluginConfig`                                                            |
| `metadata` *[ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#objectmeta-v1-meta)* | 有关 `metadata` 字段的详细信息，请参阅 Kubernetes API 文档。              |
| `spec` *[PluginConfigSpec](#pluginconfigspec)*                                                                     | PluginConfigSpec 定义了 PluginConfig 的期望状态，其中指定了插件及其配置。 |

### 类型[​](#类型 "类型的直接链接")

本节描述 CRD 使用的类型。

#### ActiveHealthCheck[​](#activehealthcheck "ActiveHealthCheck的直接链接")

ActiveHealthCheck 定义了主动上游健康检查配置。

| 字段                                                                                                          | 描述                                                   |
| ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------ |
| `type` *string*                                                                                               | Type 是健康检查类型。可以是 `http`、`https` 或 `tcp`。 |
| `timeout` *[Duration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#duration-v1-meta)* | Timeout 设置健康检查超时时间。                         |
| `concurrency` *integer*                                                                                       | Concurrency 设置同时检查的目标数量。                   |
| `host` *string*                                                                                               | Host 设置健康检查请求中使用的上游主机。                |
| `port` *integer*                                                                                              | Port 设置要探测的上游节点端口。                        |
| `httpPath` *string*                                                                                           | HTTPPath 设置 HTTP 探测请求路径。                      |
| `strictTLS` *boolean*                                                                                         | StrictTLS 控制是否强制校验 TLS 证书。                  |
| `requestHeaders` *string 数组*                                                                                | RequestHeaders 设置探测请求附加的 HTTP 请求头。        |
| `healthy` *[ActiveHealthCheckHealthy](#activehealthcheckhealthy)*                                             | Healthy 配置将节点标记为健康的阈值。                   |
| `unhealthy` *[ActiveHealthCheckUnhealthy](#activehealthcheckunhealthy)*                                       | Unhealthy 配置将节点标记为不健康的阈值。               |

*出现在：*

* [HealthCheck](#healthcheck)

#### ActiveHealthCheckHealthy[​](#activehealthcheckhealthy "ActiveHealthCheckHealthy的直接链接")

ActiveHealthCheckHealthy 定义了主动将上游节点标记为健康的阈值。

| 字段                                                                                                           | 描述                                                   |
| -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------ |
| `httpCodes` *integer 数组*                                                                                     | HTTPCodes 是被视为健康的 HTTP 状态码列表。             |
| `successes` *integer*                                                                                          | Successes 是将节点标记为健康所需的连续成功响应次数。   |
| `interval` *[Duration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#duration-v1-meta)* | Interval 定义健康检查探测之间的时间间隔，最小值为 1s。 |

*出现在：*

* [ActiveHealthCheck](#activehealthcheck)

#### ActiveHealthCheckUnhealthy[​](#activehealthcheckunhealthy "ActiveHealthCheckUnhealthy的直接链接")

ActiveHealthCheckUnhealthy 定义了主动将上游节点标记为不健康的阈值。

| 字段                                                                                                           | 描述                                                    |
| -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- |
| `httpCodes` *integer 数组*                                                                                     | HTTPCodes 是被视为不健康的 HTTP 状态码列表。            |
| `httpFailures` *integer*                                                                                       | HTTPFailures 是将节点标记为不健康所需的 HTTP 失败次数。 |
| `tcpFailures` *integer*                                                                                        | TCPFailures 是将节点标记为不健康所需的 TCP 失败次数。   |
| `timeouts` *integer*                                                                                           | Timeouts 是将节点标记为不健康所需的超时次数。           |
| `interval` *[Duration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#duration-v1-meta)* | Interval 定义健康检查探测之间的时间间隔，最小值为 1s。  |

*出现在：*

* [ActiveHealthCheck](#activehealthcheck)

#### AdminKeyAuth[​](#adminkeyauth "AdminKeyAuth的直接链接")

AdminKeyAuth 定义了管理员密钥认证配置。

| 字段                                                  | 描述                                               |
| ----------------------------------------------------- | -------------------------------------------------- |
| `value` *string*                                      | Value 显式设置管理员密钥值（不建议用于生产环境）。 |
| `valueFrom` *[AdminKeyValueFrom](#adminkeyvaluefrom)* | ValueFrom 指定管理员密钥的来源。                   |

*出现在：*

* [ControlPlaneAuth](#controlplaneauth)

#### AdminKeyValueFrom[​](#adminkeyvaluefrom "AdminKeyValueFrom的直接链接")

AdminKeyValueFrom 定义了管理员密钥的来源。

| 字段                                                     | 描述                                  |
| -------------------------------------------------------- | ------------------------------------- |
| `secretKeyRef` *[SecretKeySelector](#secretkeyselector)* | SecretKeyRef 引用 Secret 中的一个键。 |

*出现在：*

* [AdminKeyAuth](#adminkeyauth)

#### AuthType[​](#authtype "AuthType的直接链接")

*基础类型：* `string`

AuthType 定义了认证的类型。

*出现在：*

* [ControlPlaneAuth](#controlplaneauth)

#### BackendPolicyTargetReferenceWithSectionName[​](#backendpolicytargetreferencewithsectionname "BackendPolicyTargetReferenceWithSectionName的直接链接")

*基础类型：* `LocalPolicyTargetReferenceWithSectionName`

| 字段                                                                                                 | 描述                                                                                                                                                                                                                                                                                                                                                                   |
| ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `group` *[Group](https://pkg.go.dev/sigs.k8s.io/gateway-api@v1.6.0/apis/v1#Group)*                   | Group 是目标资源的 API 组。                                                                                                                                                                                                                                                                                                                                            |
| `kind` *[Kind](https://pkg.go.dev/sigs.k8s.io/gateway-api@v1.6.0/apis/v1#Kind)*                      | Kind 是目标资源的种类。                                                                                                                                                                                                                                                                                                                                                |
| `name` *[ObjectName](https://pkg.go.dev/sigs.k8s.io/gateway-api@v1.6.0/apis/v1#ObjectName)*          | Name 是目标资源的名称。                                                                                                                                                                                                                                                                                                                                                |
| `sectionName` *[SectionName](https://pkg.go.dev/sigs.k8s.io/gateway-api@v1.6.0/apis/v1#SectionName)* | SectionName 是目标资源内某一部分的名称。如果未指定，此 targetRef 将针对整个资源。在以下资源中，SectionName 按如下方式解释：<br /><br />• Gateway：监听器名称<br />• HTTPRoute：HTTPRouteRule 名称<br />• Service：端口名称<br /><br />如果指定了 SectionName，但在目标对象上不存在，则策略必须附加失败，并且策略实现应在策略的状态中记录 `ResolvedRefs` 或类似的条件。 |

*出现在：*

* [BackendTrafficPolicySpec](#backendtrafficpolicyspec)

#### BackendTrafficPolicySpec[​](#backendtrafficpolicyspec "BackendTrafficPolicySpec的直接链接")

| 字段                                                                                                            | 描述                                                                                                                                                                                                                                      |
| --------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `targetRefs` *[BackendPolicyTargetReferenceWithSectionName](#backendpolicytargetreferencewithsectionname) 数组* | TargetRef 标识要应用策略的 API 对象。目前，后端（即 Service、ServiceImport 或任何特定实现的 backendRef）是唯一有效的 API 目标引用。                                                                                                       |
| `loadbalancer` *[LoadBalancer](#loadbalancer)*                                                                  | LoadBalancer 表示 Kubernetes Service 的负载均衡器配置。默认策略是轮询。                                                                                                                                                                   |
| `scheme` *string*                                                                                               | Scheme 是与上游通信时使用的协议，默认值为 `http`。L7 代理可使用 `http`、`https`、`grpc` 或 `grpcs`；L4 代理可使用 `tcp`、`tls` 或 `udp`。L4 值仅适用于四层流式路由；在 HTTP 路由上使用会使上游不可达。                                    |
| `retries` *integer*                                                                                             | Retries 指定当发生超时或 502 错误等情况时，网关应重试发送请求的次数。                                                                                                                                                                     |
| `timeout` *[Timeout](#timeout)*                                                                                 | Timeout 设置到上游的读取、发送和连接超时。                                                                                                                                                                                                |
| `passHost` *string*                                                                                             | PassHost 配置当请求转发到上游时，主机标头应如何确定。默认值为 `pass`。可选值为 `pass`、`node` 或 `rewrite`：<br />• `pass`：保留原始 Host 标头<br />• `node`：使用上游节点的主机名<br />• `rewrite`：通过 `upstreamHost` 设置为自定义主机 |
| `upstreamHost` *[Hostname](#hostname)*                                                                          | UpstreamHost 指定上游请求的主机。仅在 passHost 设置为 `rewrite` 时使用。                                                                                                                                                                  |
| `healthCheck` *[HealthCheck](#healthcheck)*                                                                     | HealthCheck 定义上游后端的主动和被动健康检查配置。配置后，APISIX 会主动探测后端，或基于实时流量进行被动监控，以检测并绕过不健康节点。                                                                                                     |

*出现在：*

* [BackendTrafficPolicy](#backendtrafficpolicy)

#### ConsumerSpec[​](#consumerspec "ConsumerSpec的直接链接")

| 字段                                           | 描述                                   |
| ---------------------------------------------- | -------------------------------------- |
| `gatewayRef` *[GatewayRef](#gatewayref)*       | GatewayRef 指定网关详细信息。          |
| `credentials` *[Credential](#credential) 数组* | Credentials 指定消费者的凭证详细信息。 |
| `plugins` *[Plugin](#plugin) 数组*             | Plugins 定义与消费者关联的插件。       |

*出现在：*

* [Consumer](#consumer)

#### ControlPlaneAuth[​](#controlplaneauth "ControlPlaneAuth的直接链接")

ControlPlaneAuth 定义了控制面的认证配置。

| 字段                                       | 描述                                     |
| ------------------------------------------ | ---------------------------------------- |
| `type` *[AuthType](#authtype)*             | Type 指定认证的类型。只能是 `AdminKey`。 |
| `adminKey` *[AdminKeyAuth](#adminkeyauth)* | AdminKey 指定管理员密钥认证配置。        |

*出现在：*

* [ControlPlaneProvider](#controlplaneprovider)

#### ControlPlaneCaCert[​](#controlplanecacert "ControlPlaneCaCert的直接链接")

ControlPlaneCaCert 定义用于验证控制面的 CA 证书。<br /><br />目前仅支持内联值。将来可以在不破坏现有资源的情况下添加 `valueFrom` 来源。

| 字段             | 描述                                        |
| ---------------- | ------------------------------------------- |
| `value` *string* | Value 显式设置 PEM 编码的 CA 证书或证书包。 |

*出现在：*

* [ControlPlaneProvider](#controlplaneprovider)

#### ControlPlaneProvider[​](#controlplaneprovider "ControlPlaneProvider的直接链接")

ControlPlaneProvider 定义了控制面提供者的配置。

| 字段                                                 | 描述                                                                                                                                            |
| ---------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| `mode` *string*                                      | Mode 指定控制面提供者的模式。可以是 `apisix` 或 `apisix-standalone`。                                                                           |
| `endpoints` *string 数组*                            | Endpoints 指定控制面端点的列表。                                                                                                                |
| `service` *[ProviderService](#providerservice)*      |                                                                                                                                                 |
| `tlsVerify` *boolean*                                | TlsVerify 指定是否验证控制面的 TLS 证书。                                                                                                       |
| `caCert` *[ControlPlaneCaCert](#controlplanecacert)* | CaCert 指定用于验证控制面 TLS 证书的 CA 证书，并替代系统信任存储。控制面使用自签名或私有 CA 证书时设置此字段；`tlsVerify` 为 `false` 时不生效。 |
| `auth` *[ControlPlaneAuth](#controlplaneauth)*       | Auth 指定认证配置。                                                                                                                             |

*出现在：*

* [GatewayProxyProvider](#gatewayproxyprovider)

#### Credential[​](#credential "Credential的直接链接")

| 字段                                                                                                                 | 描述                                                                                            |
| -------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
| `type` *string*                                                                                                      | Type 指定要为其配置凭证的认证类型。可以是 `jwt-auth`、`basic-auth`、`key-auth` 或 `hmac-auth`。 |
| `config` *[JSON](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#json-v1-apiextensions-k8s-io)* | Config 指定认证的凭证详细信息。                                                                 |
| `secretRef` *[SecretReference](#secretreference)*                                                                    | SecretRef 引用包含凭证的 Secret。                                                               |
| `name` *string*                                                                                                      | Name 是凭证的名称。                                                                             |

*出现在：*

* [ConsumerSpec](#consumerspec)

#### GatewayProxyPlugin[​](#gatewayproxyplugin "GatewayProxyPlugin的直接链接")

GatewayProxyPlugin 包含插件配置。

| 字段                                                                                                                 | 描述                            |
| -------------------------------------------------------------------------------------------------------------------- | ------------------------------- |
| `name` *string*                                                                                                      | Name 是插件的名称。             |
| `enabled` *boolean*                                                                                                  | Enabled 定义插件是否启用。      |
| `config` *[JSON](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#json-v1-apiextensions-k8s-io)* | Config 定义插件的配置详细信息。 |

*出现在：*

* [GatewayProxySpec](#gatewayproxyspec)

#### GatewayProxyProvider[​](#gatewayproxyprovider "GatewayProxyProvider的直接链接")

GatewayProxyProvider 定义了 GatewayProxy 的提供者配置。

| 字段                                                           | 描述                                           |
| -------------------------------------------------------------- | ---------------------------------------------- |
| `type` *[ProviderType](#providertype)*                         | Type 指定提供者的类型。只能是 `ControlPlane`。 |
| `controlPlane` *[ControlPlaneProvider](#controlplaneprovider)* | ControlPlane 指定控制面提供者的配置。          |

*出现在：*

* [GatewayProxySpec](#gatewayproxyspec)

#### GatewayProxySpec[​](#gatewayproxyspec "GatewayProxySpec的直接链接")

GatewayProxySpec 定义了 GatewayProxy 的期望状态。

| 字段                                                                                                                                                                      | 描述                                                                                                |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| `publishService` *string*                                                                                                                                                 | PublishService 指定 LoadBalancer 类型的 Service，控制器使用其外部地址来更新 Ingress 资源的状态。    |
| `statusAddress` *string 数组*                                                                                                                                             | StatusAddress 指定控制器用于填充 GatewayProxy 或 Ingress 资源状态字段以供开发者访问的外部 IP 地址。 |
| `provider` *[GatewayProxyProvider](#gatewayproxyprovider)*                                                                                                                | Provider 配置提供者的详细信息。                                                                     |
| `plugins` *[GatewayProxyPlugin](#gatewayproxyplugin) 数组*                                                                                                                | Plugins 配置全局插件。                                                                              |
| `pluginMetadata` *object (keys<!-- -->:string<!-- -->, values:[JSON](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#json-v1-apiextensions-k8s-io))* | PluginMetadata 配置由同一名称的所有插件实例共享的通用配置。                                         |

*出现在：*

* [GatewayProxy](#gatewayproxy)

#### GatewayRef[​](#gatewayref "GatewayRef的直接链接")

| 字段                 | 描述                                                              |
| -------------------- | ----------------------------------------------------------------- |
| `name` *string*      | Name 是网关的名称。                                               |
| `kind` *string*      | Kind 是 Kubernetes 对象的类型。默认值为 `Gateway`。               |
| `group` *string*     | Group 是资源所属的 API 组。默认值为 `gateway.networking.k8s.io`。 |
| `namespace` *string* | Namespace 是资源的命名空间。                                      |

*出现在：*

* [ConsumerSpec](#consumerspec)

#### HTTPRoutePolicySpec[​](#httproutepolicyspec "HTTPRoutePolicySpec的直接链接")

HTTPRoutePolicySpec 定义了 HTTPRoutePolicy 的期望状态。

| 字段                                                                                                                    | 描述                                                                                                 |
| ----------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
| `targetRefs` *LocalPolicyTargetReferenceWithSectionName 数组*                                                           | TargetRef 标识要应用 HTTPRoutePolicy 的 API 对象（例如 HTTPRoute、Ingress）。                        |
| `priority` *integer*                                                                                                    | Priority 设置路由的优先级。当多个路由具有相同的 URI 路径时，较高的值会在路由匹配中设置更高的优先级。 |
| `vars` *[JSON](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#json-v1-apiextensions-k8s-io) 数组* | Vars 设置请求匹配条件。                                                                              |

*出现在：*

* [HTTPRoutePolicy](#httproutepolicy)

#### HealthCheck[​](#healthcheck "HealthCheck的直接链接")

HealthCheck 定义了上游节点的主动和被动健康检查配置。

| 字段                                                  | 描述                                                             |
| ----------------------------------------------------- | ---------------------------------------------------------------- |
| `active` *[ActiveHealthCheck](#activehealthcheck)*    | 主动健康检查会主动向上游节点发送请求以确定其可用性。             |
| `passive` *[PassiveHealthCheck](#passivehealthcheck)* | 被动健康检查根据观察到的流量（例如超时和错误）评估上游健康状况。 |

*出现在：*

* [BackendTrafficPolicySpec](#backendtrafficpolicyspec)

#### Hostname[​](#hostname "Hostname的直接链接")

*基础类型：* `string`

*出现在：*

* [BackendTrafficPolicySpec](#backendtrafficpolicyspec)

#### L4RoutePolicySpec[​](#l4routepolicyspec "L4RoutePolicySpec的直接链接")

L4RoutePolicySpec 定义 L4RoutePolicy 的期望状态。

| 字段                                                          | 描述                                                                                                                                    |
| ------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| `targetRefs` *LocalPolicyTargetReferenceWithSectionName 数组* | TargetRefs 指定要应用策略的 L4 路由资源（TCPRoute、UDPRoute 或 TLSRoute），仅支持同命名空间目标。                                       |
| `plugins` *[Plugin](#plugin) 数组*                            | Plugins 是要挂载到目标 L4 路由的 APISIX stream 插件列表。插件名称应为有效的 APISIX stream 插件名，例如 `limit-conn`、`ip-restriction`。 |

*出现在：*

* [L4RoutePolicy](#l4routepolicy)

#### LoadBalancer[​](#loadbalancer "LoadBalancer的直接链接")

LoadBalancer 描述了负载均衡参数。

| 字段              | 描述                                                                                                                                                                                                                                                                                                                                             |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `type` *string*   | Type 指定将流量路由到后端的负载均衡算法。默认值为 `roundrobin`。可选值为 `roundrobin`、`chash`、`ewma` 或 `least_conn`。                                                                                                                                                                                                                         |
| `hashOn` *string* | HashOn 指定用于哈希的字段类型，当 type 为 `chash` 时必需。默认值为 `vars`。可选值为 `vars`、`header`、`cookie`、`consumer` 或 `vars_combinations`。                                                                                                                                                                                              |
| `key` *string*    | Key 与 HashOn 一起使用，当 type 为 `chash` 时通常必需。当 HashOn 为 `header` 或 `cookie` 时，指定标头或 cookie 的名称。当 HashOn 为 `consumer` 时，key 不是必需的，因为会自动使用消费者名称。当 HashOn 为 `vars` 或 `vars_combinations` 时，key 指一个或多个[内置变量](https://docs.apiseven.com/apisix/reference/built-in-variables.md)的组合。 |

*出现在：*

* [BackendTrafficPolicySpec](#backendtrafficpolicyspec)

#### PassiveHealthCheck[​](#passivehealthcheck "PassiveHealthCheck的直接链接")

PassiveHealthCheck 定义了基于实际流量观察的被动健康检查配置。

| 字段                                                                      | 描述                                                       |
| ------------------------------------------------------------------------- | ---------------------------------------------------------- |
| `type` *string*                                                           | Type 是被动健康检查类型。可以是 `http`、`https` 或 `tcp`。 |
| `healthy` *[PassiveHealthCheckHealthy](#passivehealthcheckhealthy)*       | Healthy 定义节点被视为健康的条件。                         |
| `unhealthy` *[PassiveHealthCheckUnhealthy](#passivehealthcheckunhealthy)* | Unhealthy 定义节点被视为不健康的条件。                     |

*出现在：*

* [HealthCheck](#healthcheck)

#### PassiveHealthCheckHealthy[​](#passivehealthcheckhealthy "PassiveHealthCheckHealthy的直接链接")

PassiveHealthCheckHealthy 定义了被动将节点标记为健康的条件。

| 字段                       | 描述                                                 |
| -------------------------- | ---------------------------------------------------- |
| `httpCodes` *integer 数组* | HTTPCodes 是被视为健康的 HTTP 状态码列表。           |
| `successes` *integer*      | Successes 是将节点标记为健康所需的连续成功响应次数。 |

*出现在：*

* [ActiveHealthCheckHealthy](#activehealthcheckhealthy)
* [PassiveHealthCheck](#passivehealthcheck)

#### PassiveHealthCheckUnhealthy[​](#passivehealthcheckunhealthy "PassiveHealthCheckUnhealthy的直接链接")

PassiveHealthCheckUnhealthy 定义了被动将节点标记为不健康的条件。

| 字段                       | 描述                                                    |
| -------------------------- | ------------------------------------------------------- |
| `httpCodes` *integer 数组* | HTTPCodes 是被视为不健康的 HTTP 状态码列表。            |
| `httpFailures` *integer*   | HTTPFailures 是将节点标记为不健康所需的 HTTP 失败次数。 |
| `tcpFailures` *integer*    | TCPFailures 是将节点标记为不健康所需的 TCP 失败次数。   |
| `timeouts` *integer*       | Timeouts 是将节点标记为不健康所需的超时次数。           |

*出现在：*

* [ActiveHealthCheckUnhealthy](#activehealthcheckunhealthy)
* [PassiveHealthCheck](#passivehealthcheck)

#### Plugin[​](#plugin "Plugin的直接链接")

| 字段                                                                                                                                    | 描述                                                                                                                                                                                                                                                          |
| --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `name` *string*                                                                                                                         | Name 是插件的名称。                                                                                                                                                                                                                                           |
| `config` *[JSON](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#json-v1-apiextensions-k8s-io)*                    | Config 是插件的配置详细信息。                                                                                                                                                                                                                                 |
| `secretRef` *[LocalObjectReference](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#localobjectreference-v1-core)* | SecretRef 引用同一命名空间中保存插件配置敏感部分的 Secret，因此无需将这些内容写入 `config`。每个 Secret Key 都是指向配置的点分隔路径，例如 Key `session.secret` 会设置 `session` 对象的 `secret` 字段。值以字符串形式合并，并优先于 `config` 中相同路径的值。 |

*出现在：*

* [ConsumerSpec](#consumerspec)
* [L4RoutePolicySpec](#l4routepolicyspec)
* [PluginConfigSpec](#pluginconfigspec)

#### PluginConfigSpec[​](#pluginconfigspec "PluginConfigSpec的直接链接")

PluginConfigSpec 定义了 PluginConfig 的期望状态。

| 字段                               | 描述                                         |
| ---------------------------------- | -------------------------------------------- |
| `plugins` *[Plugin](#plugin) 数组* | Plugins 是一个插件及其配置的数组，将被应用。 |

*出现在：*

* [PluginConfig](#pluginconfig)

#### ProviderService[​](#providerservice "ProviderService的直接链接")

| 字段             | 描述                  |
| ---------------- | --------------------- |
| `name` *string*  | Name 是提供者的名称。 |
| `port` *integer* | Port 是提供者的端口。 |

*出现在：*

* [ControlPlaneProvider](#controlplaneprovider)

#### ProviderType[​](#providertype "ProviderType的直接链接")

*基础类型：* `string`

ProviderType 定义了提供者的类型。

*出现在：*

* [GatewayProxyProvider](#gatewayproxyprovider)

#### SecretKeySelector[​](#secretkeyselector "SecretKeySelector的直接链接")

SecretKeySelector 定义了对 Secret 中特定键的引用。

| 字段            | 描述                           |
| --------------- | ------------------------------ |
| `name` *string* | Name 是 Secret 的名称。        |
| `key` *string*  | Key 是要从 Secret 中读取的键。 |

*出现在：*

* [AdminKeyValueFrom](#adminkeyvaluefrom)

#### SecretReference[​](#secretreference "SecretReference的直接链接")

| 字段                 | 描述                             |
| -------------------- | -------------------------------- |
| `name` *string*      | Name 是 Secret 的名称。          |
| `namespace` *string* | Namespace 是 Secret 的命名空间。 |

*出现在：*

* [Credential](#credential)

#### Status[​](#status "Status的直接链接")

| 字段                                                                                                                    | 描述 |
| ----------------------------------------------------------------------------------------------------------------------- | ---- |
| `conditions` *[Condition](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#condition-v1-meta) 数组* |      |

#### Timeout[​](#timeout "Timeout的直接链接")

| 字段                                                                                                          | 描述                       |
| ------------------------------------------------------------------------------------------------------------- | -------------------------- |
| `connect` *[Duration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#duration-v1-meta)* | 连接超时。默认值为 `60s`。 |
| `send` *[Duration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#duration-v1-meta)*    | 发送超时。默认值为 `60s`。 |
| `read` *[Duration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#duration-v1-meta)*    | 读取超时。默认值为 `60s`。 |

*出现在：*

* [BackendTrafficPolicySpec](#backendtrafficpolicyspec)

## apisix.apache.org/v2[​](#apisixapacheorgv2 "apisix.apache.org/v2的直接链接")

包 v2 包含 apisix.apache.org v2 API 组的 API Schema 定义。

* [ApisixConsumer](#apisixconsumer)
* [ApisixGlobalRule](#apisixglobalrule)
* [ApisixPluginConfig](#apisixpluginconfig)
* [ApisixRoute](#apisixroute)
* [ApisixTls](#apisixtls)
* [ApisixUpstream](#apisixupstream)

### ApisixConsumer[​](#apisixconsumer "ApisixConsumer的直接链接")

ApisixConsumer 定义了消费者及其认证详细信息的配置。

| 字段                                                                                                               | 描述                                                         |
| ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------ |
| `apiVersion` *string*                                                                                              | `apisix.apache.org/v2`                                       |
| `kind` *string*                                                                                                    | `ApisixConsumer`                                             |
| `metadata` *[ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#objectmeta-v1-meta)* | 有关 `metadata` 字段的详细信息，请参阅 Kubernetes API 文档。 |
| `spec` *[ApisixConsumerSpec](#apisixconsumerspec)*                                                                 | ApisixConsumerSpec 定义了消费者认证配置。                    |

### ApisixGlobalRule[​](#apisixglobalrule "ApisixGlobalRule的直接链接")

ApisixGlobalRule 定义了全局插件的配置。

| 字段                                                                                                               | 描述                                                         |
| ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------ |
| `apiVersion` *string*                                                                                              | `apisix.apache.org/v2`                                       |
| `kind` *string*                                                                                                    | `ApisixGlobalRule`                                           |
| `metadata` *[ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#objectmeta-v1-meta)* | 有关 `metadata` 字段的详细信息，请参阅 Kubernetes API 文档。 |
| `spec` *[ApisixGlobalRuleSpec](#apisixglobalrulespec)*                                                             | ApisixGlobalRuleSpec 定义了全局插件配置。                    |

### ApisixPluginConfig[​](#apisixpluginconfig "ApisixPluginConfig的直接链接")

ApisixPluginConfig 定义了一组可重用的插件配置，可供路由引用。

| 字段                                                                                                               | 描述                                                         |
| ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------ |
| `apiVersion` *string*                                                                                              | `apisix.apache.org/v2`                                       |
| `kind` *string*                                                                                                    | `ApisixPluginConfig`                                         |
| `metadata` *[ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#objectmeta-v1-meta)* | 有关 `metadata` 字段的详细信息，请参阅 Kubernetes API 文档。 |
| `spec` *[ApisixPluginConfigSpec](#apisixpluginconfigspec)*                                                         | ApisixPluginConfigSpec 定义了插件配置。                      |

### ApisixRoute[​](#apisixroute "ApisixRoute的直接链接")

ApisixRoute 定义了 HTTP 和流式路由的配置。

| 字段                                                                                                               | 描述                                                         |
| ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------ |
| `apiVersion` *string*                                                                                              | `apisix.apache.org/v2`                                       |
| `kind` *string*                                                                                                    | `ApisixRoute`                                                |
| `metadata` *[ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#objectmeta-v1-meta)* | 有关 `metadata` 字段的详细信息，请参阅 Kubernetes API 文档。 |
| `spec` *[ApisixRouteSpec](#apisixroutespec)*                                                                       | ApisixRouteSpec 定义了 HTTP 和流式路由配置。                 |

### ApisixTls[​](#apisixtls "ApisixTls的直接链接")

ApisixTls 定义了 TLS 和双向 TLS (mTLS) 的配置。

| 字段                                                                                                               | 描述                                                         |
| ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------ |
| `apiVersion` *string*                                                                                              | `apisix.apache.org/v2`                                       |
| `kind` *string*                                                                                                    | `ApisixTls`                                                  |
| `metadata` *[ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#objectmeta-v1-meta)* | 有关 `metadata` 字段的详细信息，请参阅 Kubernetes API 文档。 |
| `spec` *[ApisixTlsSpec](#apisixtlsspec)*                                                                           | ApisixTlsSpec 定义了 TLS 配置。                              |

### ApisixUpstream[​](#apisixupstream "ApisixUpstream的直接链接")

ApisixUpstream 定义了上游服务的配置。

| 字段                                                                                                               | 描述                                                         |
| ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------ |
| `apiVersion` *string*                                                                                              | `apisix.apache.org/v2`                                       |
| `kind` *string*                                                                                                    | `ApisixUpstream`                                             |
| `metadata` *[ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#objectmeta-v1-meta)* | 有关 `metadata` 字段的详细信息，请参阅 Kubernetes API 文档。 |
| `spec` *[ApisixUpstreamSpec](#apisixupstreamspec)*                                                                 | ApisixUpstreamSpec 定义了上游配置。                          |

### 类型[​](#类型-1 "类型的直接链接")

本节描述 CRD 使用的类型。

#### ActiveHealthCheck[​](#activehealthcheck-1 "ActiveHealthCheck的直接链接")

ActiveHealthCheck 定义了主动上游健康检查配置。

| 字段                                                                    | 描述                                                   |
| ----------------------------------------------------------------------- | ------------------------------------------------------ |
| `type` *string*                                                         | Type 是健康检查类型。可以是 `http`、`https` 或 `tcp`。 |
| `timeout` *[Duration](https://pkg.go.dev/time#Duration)*                | Timeout 设置健康检查超时时间（秒）。                   |
| `concurrency` *integer*                                                 | Concurrency 设置同时检查的目标数量。                   |
| `host` *string*                                                         | Host 设置上游主机。                                    |
| `port` *integer*                                                        | Port 设置上游端口。                                    |
| `httpPath` *string*                                                     | HTTPPath 设置 HTTP 探测请求路径。                      |
| `strictTLS` *boolean*                                                   | StrictTLS 设置是否强制执行 TLS。                       |
| `requestHeaders` *string 数组*                                          | RequestHeaders 设置请求标头。                          |
| `healthy` *[ActiveHealthCheckHealthy](#activehealthcheckhealthy)*       | Healthy 配置定义上游节点为健康的条件。                 |
| `unhealthy` *[ActiveHealthCheckUnhealthy](#activehealthcheckunhealthy)* | Unhealthy 配置定义上游节点为不健康的条件。             |

*出现在：*

* [HealthCheck](#healthcheck)

#### ActiveHealthCheckHealthy[​](#activehealthcheckhealthy-1 "ActiveHealthCheckHealthy的直接链接")

UpstreamActiveHealthCheckHealthy 定义了用于主动确定上游节点是否健康的条件。

| 字段                                                                                                           | 描述                                               |
| -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------- |
| `httpCodes` *integer 数组*                                                                                     | HTTPCodes 定义被视为健康的 HTTP 状态码列表。       |
| `successes` *integer*                                                                                          | Successes 定义将目标定义为健康所需的成功探测次数。 |
| `interval` *[Duration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#duration-v1-meta)* | Interval 定义检查目标的时间间隔（秒）。            |

*出现在：*

* [ActiveHealthCheck](#activehealthcheck)

#### ActiveHealthCheckUnhealthy[​](#activehealthcheckunhealthy-1 "ActiveHealthCheckUnhealthy的直接链接")

UpstreamActiveHealthCheckHealthy 定义了用于主动确定上游节点是否不健康的条件。

| 字段                                                                                                           | 描述                                                      |
| -------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
| `httpCodes` *integer 数组*                                                                                     | HTTPCodes 定义被视为不健康的 HTTP 状态码列表。            |
| `httpFailures` *integer*                                                                                       | HTTPFailures 定义将目标定义为不健康所需的 HTTP 失败次数。 |
| `tcpFailures` *integer*                                                                                        | TCPFailures 定义将目标定义为不健康所需的 TCP 失败次数。   |
| `timeout` *integer*                                                                                            | Timeout 设置将目标定义为不健康所需的超时次数。            |
| `interval` *[Duration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#duration-v1-meta)* | Interval 定义检查目标的时间间隔（秒）。                   |

*出现在：*

* [ActiveHealthCheck](#activehealthcheck)

#### ApisixConsumerAuthParameter[​](#apisixconsumerauthparameter "ApisixConsumerAuthParameter的直接链接")

| 字段                                                              | 描述                                   |
| ----------------------------------------------------------------- | -------------------------------------- |
| `basicAuth` *[ApisixConsumerBasicAuth](#apisixconsumerbasicauth)* | BasicAuth 配置基本认证详细信息。       |
| `keyAuth` *[ApisixConsumerKeyAuth](#apisixconsumerkeyauth)*       | KeyAuth 配置密钥认证详细信息。         |
| `wolfRBAC` *[ApisixConsumerWolfRBAC](#apisixconsumerwolfrbac)*    | WolfRBAC 配置 Wolf RBAC 认证详细信息。 |
| `jwtAuth` *[ApisixConsumerJwtAuth](#apisixconsumerjwtauth)*       | JwtAuth 配置 JWT 认证详细信息。        |
| `hmacAuth` *[ApisixConsumerHMACAuth](#apisixconsumerhmacauth)*    | HMACAuth 配置 HMAC 认证详细信息。      |
| `ldapAuth` *[ApisixConsumerLDAPAuth](#apisixconsumerldapauth)*    | LDAPAuth 配置 LDAP 认证详细信息。      |

*出现在：*

* [ApisixConsumerSpec](#apisixconsumerspec)

#### ApisixConsumerBasicAuth[​](#apisixconsumerbasicauth "ApisixConsumerBasicAuth的直接链接")

ApisixConsumerBasicAuth 定义了基本认证的配置。

| 字段                                                                                                                                    | 描述                                                 |
| --------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- |
| `secretRef` *[LocalObjectReference](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#localobjectreference-v1-core)* | SecretRef 引用包含基本认证凭证的 Kubernetes Secret。 |
| `value` *[ApisixConsumerBasicAuthValue](#apisixconsumerbasicauthvalue)*                                                                 | Value 指定基本认证凭证。                             |

*出现在：*

* [ApisixConsumerAuthParameter](#apisixconsumerauthparameter)

#### ApisixConsumerBasicAuthValue[​](#apisixconsumerbasicauthvalue "ApisixConsumerBasicAuthValue的直接链接")

ApisixConsumerBasicAuthValue 定义了基本认证的用户名和密码配置。

| 字段                | 描述                        |
| ------------------- | --------------------------- |
| `username` *string* | Username 是基本认证用户名。 |
| `password` *string* | Password 是基本认证密码。   |

*出现在：*

* [ApisixConsumerBasicAuth](#apisixconsumerbasicauth)

#### ApisixConsumerHMACAuth[​](#apisixconsumerhmacauth "ApisixConsumerHMACAuth的直接链接")

ApisixConsumerHMACAuth 定义了 HMAC 认证的配置。

| 字段                                                                                                                                    | 描述                                                                                                                                                              |
| --------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `secretRef` *[LocalObjectReference](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#localobjectreference-v1-core)* | SecretRef 引用包含 HMAC 凭证的 Kubernetes Secret。与 Value 不同，Secret 把 `signed_headers` 存为一个字符串，其中请求头名称以逗号或空格分隔，例如 `X-Date, Host`。 |
| `value` *[ApisixConsumerHMACAuthValue](#apisixconsumerhmacauthvalue)*                                                                   | Value 指定 HMAC 认证凭证。                                                                                                                                        |

*出现在：*

* [ApisixConsumerAuthParameter](#apisixconsumerauthparameter)

#### ApisixConsumerHMACAuthValue[​](#apisixconsumerhmacauthvalue "ApisixConsumerHMACAuthValue的直接链接")

ApisixConsumerHMACAuthValue 定义了 HMAC 认证的配置。

| 字段                              | 描述                                                                               |
| --------------------------------- | ---------------------------------------------------------------------------------- |
| `key_id` *string*                 | KeyID 是用于查找 HMAC 密钥的标识符。                                               |
| `secret_key` *string*             | SecretKey 是用于签署请求的 HMAC 密钥。                                             |
| `access_key` *string*             | AccessKey 是用于查找 HMAC 密钥的标识符。已从消费者配置中弃用                       |
| `algorithm` *string*              | Algorithm 指定哈希算法（例如 "hmac-sha256"）。已从消费者配置中弃用                 |
| `clock_skew` *integer*            | ClockSkew 是客户端和服务器时钟之间允许的时间差（以秒为单位）。已从消费者配置中弃用 |
| `signed_headers` *string 数组*    | SignedHeaders 列出必须包含在签名中的标头。已从消费者配置中弃用                     |
| `keep_headers` *boolean*          | KeepHeaders 确定 HMAC 签名标头在验证后是否保留。已从消费者配置中弃用               |
| `encode_uri_params` *boolean*     | EncodeURIParams 指示在计算签名时是否对 URI 参数进行编码。已从消费者配置中弃用      |
| `validate_request_body` *boolean* | ValidateRequestBody 启用请求体的 HMAC 验证。已从消费者配置中弃用                   |
| `max_req_body` *integer*          | MaxReqBody 设置可以验证的请求体的最大大小（以字节为单位）。已从消费者配置中弃用    |

*出现在：*

* [ApisixConsumerHMACAuth](#apisixconsumerhmacauth)

#### ApisixConsumerJwtAuth[​](#apisixconsumerjwtauth "ApisixConsumerJwtAuth的直接链接")

ApisixConsumerJwtAuth 定义了 JWT 认证的配置。

| 字段                                                                                                                                    | 描述                                                  |
| --------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- |
| `secretRef` *[LocalObjectReference](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#localobjectreference-v1-core)* | SecretRef 引用包含 JWT 认证凭证的 Kubernetes Secret。 |
| `value` *[ApisixConsumerJwtAuthValue](#apisixconsumerjwtauthvalue)*                                                                     | Value 指定 JWT 认证凭证。                             |

*出现在：*

* [ApisixConsumerAuthParameter](#apisixconsumerauthparameter)

#### ApisixConsumerJwtAuthValue[​](#apisixconsumerjwtauthvalue "ApisixConsumerJwtAuthValue的直接链接")

ApisixConsumerJwtAuthValue 定义了 JWT 认证的配置。对于非对称算法（RS\*、ES\*、PS\*、EdDSA），必须至少提供 `public_key` 或 `private_key` 之一；对称算法（HS256、HS384、HS512）以及未设置算法时不要求任何 key 字段。

| 字段                              | 描述                                                                                                                                                   |
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `key` *string*                    | Key 是 JWT 凭证的唯一标识符。                                                                                                                          |
| `secret` *string*                 | Secret 是用于签名 JWT 的共享密钥（用于对称算法）。                                                                                                     |
| `public_key` *string*             | PublicKey 是用于验证 JWT 签名的公钥（用于非对称算法）。                                                                                                |
| `private_key` *string*            | PrivateKey 是用于签名 JWT 的私钥（用于非对称算法）。                                                                                                   |
| `algorithm` *string*              | Algorithm 指定签名算法。可以是 `HS256`、`HS384`、`HS512`、`RS256`、`RS384`、`RS512`、`ES256`、`ES384`、`ES512`、`PS256`、`PS384`、`PS512` 或 `EdDSA`。 |
| `exp` *integer*                   | Exp 是 Token 过期时间（秒）。                                                                                                                          |
| `base64_secret` *boolean*         | Base64Secret 指示密钥是否经过 base64 编码。                                                                                                            |
| `lifetime_grace_period` *integer* | LifetimeGracePeriod 是 Token 过期允许的时钟偏差（秒）。                                                                                                |

*出现在：*

* [ApisixConsumerJwtAuth](#apisixconsumerjwtauth)

#### ApisixConsumerKeyAuth[​](#apisixconsumerkeyauth "ApisixConsumerKeyAuth的直接链接")

ApisixConsumerKeyAuth 定义了密钥认证的配置。

| 字段                                                                                                                                    | 描述                                                 |
| --------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- |
| `secretRef` *[LocalObjectReference](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#localobjectreference-v1-core)* | SecretRef 引用包含密钥认证凭证的 Kubernetes Secret。 |
| `value` *[ApisixConsumerKeyAuthValue](#apisixconsumerkeyauthvalue)*                                                                     | Value 指定密钥认证凭证。                             |

*出现在：*

* [ApisixConsumerAuthParameter](#apisixconsumerauthparameter)

#### ApisixConsumerKeyAuthValue[​](#apisixconsumerkeyauthvalue "ApisixConsumerKeyAuthValue的直接链接")

ApisixConsumerKeyAuthValue 定义了密钥认证的配置。

| 字段           | 描述                       |
| -------------- | -------------------------- |
| `key` *string* | Key 是用于密钥认证的凭证。 |

*出现在：*

* [ApisixConsumerKeyAuth](#apisixconsumerkeyauth)

#### ApisixConsumerLDAPAuth[​](#apisixconsumerldapauth "ApisixConsumerLDAPAuth的直接链接")

ApisixConsumerLDAPAuth 定义了 LDAP 认证的配置。

| 字段                                                                                                                                    | 描述                                               |
| --------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------- |
| `secretRef` *[LocalObjectReference](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#localobjectreference-v1-core)* | SecretRef 引用包含 LDAP 凭证的 Kubernetes Secret。 |
| `value` *[ApisixConsumerLDAPAuthValue](#apisixconsumerldapauthvalue)*                                                                   | Value 指定 LDAP 认证凭证。                         |

*出现在：*

* [ApisixConsumerAuthParameter](#apisixconsumerauthparameter)

#### ApisixConsumerLDAPAuthValue[​](#apisixconsumerldapauthvalue "ApisixConsumerLDAPAuthValue的直接链接")

ApisixConsumerLDAPAuthValue 定义了 LDAP 认证的配置。

| 字段               | 描述                                 |
| ------------------ | ------------------------------------ |
| `user_dn` *string* | UserDN 是 LDAP 用户的专有名称 (DN)。 |

*出现在：*

* [ApisixConsumerLDAPAuth](#apisixconsumerldapauth)

#### ApisixConsumerSpec[​](#apisixconsumerspec "ApisixConsumerSpec的直接链接")

ApisixConsumerSpec 定义了 ApisixConsumer 的期望状态。

| 字段                                                                          | 描述                                                                                                                                                |
| ----------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ingressClassName` *string*                                                   | IngressClassName 是 IngressClass 集群资源的名称。控制器使用此字段来决定是否应管理该资源。                                                           |
| `authParameter` *[ApisixConsumerAuthParameter](#apisixconsumerauthparameter)* | AuthParameter 定义此消费者的认证凭证和配置。                                                                                                        |
| `plugins` *[ApisixRoutePlugin](#apisixrouteplugin) 数组*                      | Plugins 列出要挂载到该消费者的额外消费者级插件。这些插件会与从 AuthParameter 派生的认证插件一起生效；若启用的插件与派生认证插件同名，则该插件优先。 |

*出现在：*

* [ApisixConsumer](#apisixconsumer)

#### ApisixConsumerWolfRBAC[​](#apisixconsumerwolfrbac "ApisixConsumerWolfRBAC的直接链接")

ApisixConsumerWolfRBAC 定义了 Wolf RBAC 认证的配置。

| 字段                                                                                                                                    | 描述                                                      |
| --------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
| `secretRef` *[LocalObjectReference](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#localobjectreference-v1-core)* | SecretRef 引用包含 Wolf RBAC Token 的 Kubernetes Secret。 |
| `value` *[ApisixConsumerWolfRBACValue](#apisixconsumerwolfrbacvalue)*                                                                   | Value 指定 Wolf RBAC Token。                              |

*出现在：*

* [ApisixConsumerAuthParameter](#apisixconsumerauthparameter)

#### ApisixConsumerWolfRBACValue[​](#apisixconsumerwolfrbacvalue "ApisixConsumerWolfRBACValue的直接链接")

ApisixConsumerWolfRBACValue 定义了 Wolf RBAC 认证的配置。

| 字段                     | 描述                                                    |
| ------------------------ | ------------------------------------------------------- |
| `server` *string*        | Server 是 Wolf RBAC 服务器的 URL。                      |
| `appid` *string*         | Appid 是与 Wolf RBAC 服务器通信时使用的应用程序标识符。 |
| `header_prefix` *string* | HeaderPrefix 是添加到请求标头以进行 RBAC 执行的前缀。   |

*出现在：*

* [ApisixConsumerWolfRBAC](#apisixconsumerwolfrbac)

#### ApisixGlobalRuleSpec[​](#apisixglobalrulespec "ApisixGlobalRuleSpec的直接链接")

ApisixGlobalRuleSpec 定义了全局插件的配置。

| 字段                                                     | 描述                                                                                      |
| -------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| `ingressClassName` *string*                              | IngressClassName 是 IngressClass 集群资源的名称。控制器使用此字段来决定是否应管理该资源。 |
| `plugins` *[ApisixRoutePlugin](#apisixrouteplugin) 数组* | Plugins 包含全局插件列表。                                                                |

*出现在：*

* [ApisixGlobalRule](#apisixglobalrule)

#### ApisixMutualTlsClientConfig[​](#apisixmutualtlsclientconfig "ApisixMutualTlsClientConfig的直接链接")

ApisixMutualTlsClientConfig 描述了双向 TLS CA 和验证设置。

| 字段                                       | 描述                                                              |
| ------------------------------------------ | ----------------------------------------------------------------- |
| `caSecret` *[ApisixSecret](#apisixsecret)* | CASecret 引用包含用于客户端证书验证的 CA 证书的 Secret。          |
| `depth` *integer*                          | Depth 指定客户端证书链的最大验证深度。                            |
| `skip_mtls_uri_regex` *string 数组*        | SkipMTLSUriRegex 包含用于跳过双向 TLS 验证的 URI 正则表达式模式。 |

*出现在：*

* [ApisixTlsSpec](#apisixtlsspec)

#### ApisixPluginConfigSpec[​](#apisixpluginconfigspec "ApisixPluginConfigSpec的直接链接")

ApisixPluginConfigSpec 定义了 ApisixPluginConfigSpec 的期望状态。

| 字段                                                     | 描述                                                                                      |
| -------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| `ingressClassName` *string*                              | IngressClassName 是 IngressClass 集群资源的名称。控制器使用此字段来决定是否应管理该资源。 |
| `plugins` *[ApisixRoutePlugin](#apisixrouteplugin) 数组* | Plugins 包含插件列表。                                                                    |

*出现在：*

* [ApisixPluginConfig](#apisixpluginconfig)

#### ApisixRouteAuthentication[​](#apisixrouteauthentication "ApisixRouteAuthentication的直接链接")

ApisixRouteAuthentication 表示 ApisixRoute 中与认证相关的配置。

| 字段                                                                                 | 描述                            |
| ------------------------------------------------------------------------------------ | ------------------------------- |
| `enable` *boolean*                                                                   | Enable 打开或关闭认证。         |
| `type` *string*                                                                      | Type 指定认证类型。             |
| `keyAuth` *[ApisixRouteAuthenticationKeyAuth](#apisixrouteauthenticationkeyauth)*    | KeyAuth 定义密钥认证的配置。    |
| `jwtAuth` *[ApisixRouteAuthenticationJwtAuth](#apisixrouteauthenticationjwtauth)*    | JwtAuth 定义 JWT 认证的配置。   |
| `ldapAuth` *[ApisixRouteAuthenticationLDAPAuth](#apisixrouteauthenticationldapauth)* | LDAPAuth 定义 LDAP 认证的配置。 |

*出现在：*

* [ApisixRouteHTTP](#apisixroutehttp)

#### ApisixRouteAuthenticationJwtAuth[​](#apisixrouteauthenticationjwtauth "ApisixRouteAuthenticationJwtAuth的直接链接")

ApisixRouteAuthenticationJwtAuth 定义了 ApisixRouteAuthentication 中的 JWT 认证配置。

| 字段              | 描述                                         |
| ----------------- | -------------------------------------------- |
| `header` *string* | Header 指定用于查找 JWT 的 HTTP 标头名称。   |
| `query` *string*  | Query 指定用于查找 JWT 的 URL 查询参数名称。 |
| `cookie` *string* | Cookie 指定用于查找 JWT 的 Cookie 名称。     |

*出现在：*

* [ApisixRouteAuthentication](#apisixrouteauthentication)

#### ApisixRouteAuthenticationKeyAuth[​](#apisixrouteauthenticationkeyauth "ApisixRouteAuthenticationKeyAuth的直接链接")

ApisixRouteAuthenticationKeyAuth 定义了 ApisixRouteAuthentication 中的密钥认证配置。

| 字段              | 描述                                                 |
| ----------------- | ---------------------------------------------------- |
| `header` *string* | Header 指定用于查找密钥认证 Token 的 HTTP 标头名称。 |

*出现在：*

* [ApisixRouteAuthentication](#apisixrouteauthentication)

#### ApisixRouteAuthenticationLDAPAuth[​](#apisixrouteauthenticationldapauth "ApisixRouteAuthenticationLDAPAuth的直接链接")

ApisixRouteAuthenticationLDAPAuth 定义了 ApisixRouteAuthentication 中的 LDAP 认证配置。

| 字段                | 描述                                     |
| ------------------- | ---------------------------------------- |
| `base_dn` *string*  | BaseDN 是 LDAP 搜索的基础专有名称 (DN)。 |
| `ldap_uri` *string* | LDAPURI 是 LDAP 服务器的 URI。           |
| `use_tls` *boolean* | UseTLS 指示是否对 LDAP 连接使用 TLS。    |
| `uid` *string*      | UID 是 LDAP 中的用户标识属性。           |

*出现在：*

* [ApisixRouteAuthentication](#apisixrouteauthentication)

#### ApisixRouteHTTP[​](#apisixroutehttp "ApisixRouteHTTP的直接链接")

ApisixRouteHTTP 表示单个 HTTP 路由配置。

| 字段                                                                             | 描述                                                                                                           |
| -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| `name` *string*                                                                  | Name 是唯一的规则名称，不能为空。                                                                              |
| `priority` *integer*                                                             | Priority 定义当多个路由共享相同 URI 路径时的路由优先级。数值越高，路由匹配优先级越高。                         |
| `timeout` *[UpstreamTimeout](#upstreamtimeout)*                                  | Timeout 指定上游超时设置。                                                                                     |
| `match` *[ApisixRouteHTTPMatch](#apisixroutehttpmatch)*                          | Match 定义 HTTP 请求匹配条件。                                                                                 |
| `backends` *[ApisixRouteHTTPBackend](#apisixroutehttpbackend) 数组*              | Backends 列出要代理请求到的潜在后端服务。如果指定了多个后端，则使用 `traffic-split` 插件根据后端权重分配流量。 |
| `upstreams` *[ApisixRouteUpstreamReference](#apisixrouteupstreamreference) 数组* | Upstreams 引用 ApisixUpstream CRD。                                                                            |
| `websocket` *boolean*                                                            | Websocket 为此路由启用或禁用 WebSocket 支持。                                                                  |
| `plugin_config_name` *string*                                                    | PluginConfigName 指定要应用的插件配置的名称。                                                                  |
| `plugin_config_namespace` *string*                                               | PluginConfigNamespace 指定插件配置的命名空间。如果未设置，默认为 ApisixRoute 的命名空间。                      |
| `plugins` *[ApisixRoutePlugin](#apisixrouteplugin) 数组*                         | Plugins 列出应用于此路由的其他插件。                                                                           |
| `authentication` *[ApisixRouteAuthentication](#apisixrouteauthentication)*       | Authentication 包含此路由的认证相关配置。                                                                      |

*出现在：*

* [ApisixRouteSpec](#apisixroutespec)

#### ApisixRouteHTTPBackend[​](#apisixroutehttpbackend "ApisixRouteHTTPBackend的直接链接")

ApisixRouteHTTPBackend 表示一个 HTTP 后端（Kubernetes Service）。

| 字段                                                                                                                        | 描述                                                                                                                                                                                       |
| --------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `serviceName` *string*                                                                                                      | ServiceName 是 Kubernetes Service 的名称。不支持跨命名空间引用 — 确保 ApisixRoute 和 Service 位于同一命名空间中。                                                                          |
| `servicePort` *[IntOrString](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#intorstring-intstr-util)* | ServicePort 是 Kubernetes Service 的端口。可以是端口名称或端口号。                                                                                                                         |
| `resolveGranularity` *string*                                                                                               | ResolveGranularity 确定后端服务的解析方式。有效值为 `endpoint` 和 `service`。设置为 `endpoint` 时，将使用单个 Pod IP；否则，使用 Service 的 ClusterIP 或 ExternalIP。默认值为 `endpoint`。 |
| `weight` *integer*                                                                                                          | Weight 指定此后端的相对流量权重。                                                                                                                                                          |
| `subset` *string*                                                                                                           | Subset 指定目标 Service 的命名子集。该子集必须在相应的 ApisixUpstream 资源中预先定义。                                                                                                     |

*出现在：*

* [ApisixRouteHTTP](#apisixroutehttp)

#### ApisixRouteHTTPMatch[​](#apisixroutehttpmatch "ApisixRouteHTTPMatch的直接链接")

ApisixRouteHTTPMatch 定义了用于匹配传入 HTTP 请求的条件。

| 字段                                                              | 描述                                                                                                                                       |
| ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `paths` *string 数组*                                             | Paths 是要匹配的 URI 路径模式列表。必须至少指定一个路径。支持精确匹配和前缀匹配。对于前缀匹配，在路径后附加 `*`，例如 `/foo*`。            |
| `methods` *string 数组*                                           | Methods 指定要匹配的 HTTP 方法。                                                                                                           |
| `hosts` *string 数组*                                             | Hosts 指定要匹配的 Host 标头值。支持精确匹配和通配符域名。只允许一级通配符（例如 `*.example.com` 有效，但 `*.*.example.com` 无效）。       |
| `remoteAddrs` *string 数组*                                       | RemoteAddrs 是要匹配的源 IP 地址或 CIDR 范围列表。支持 IPv4 和 IPv6 格式。                                                                 |
| `exprs` *[ApisixRouteHTTPMatchExprs](#apisixroutehttpmatchexprs)* | NginxVars 定义基于 Nginx 变量的匹配条件。                                                                                                  |
| `filter_func` *string*                                            | FilterFunc 是用于高级请求过滤的用户定义函数。该函数可以通过 `vars` 参数使用 Nginx 变量。此字段在 APISIX 中支持，但在 API7 企业版中不支持。 |

*出现在：*

* [ApisixRouteHTTP](#apisixroutehttp)

#### ApisixRouteHTTPMatchExpr[​](#apisixroutehttpmatchexpr "ApisixRouteHTTPMatchExpr的直接链接")

ApisixRouteHTTPMatchExpr 表示用于基于 Nginx 变量匹配请求的二元表达式。

| 字段                                                                            | 描述                                                                                                                                                                                                                                   |
| ------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `subject` *[ApisixRouteHTTPMatchExprSubject](#apisixroutehttpmatchexprsubject)* | Subject 定义表达式的左侧。可以是任何[内置变量](https://docs.apiseven.com/apisix/reference/built-in-variables.md)或字符串字面量。                                                                                                       |
| `op` *string*                                                                   | Op 指定表达式中使用的运算符。可以是 `Equal`、`NotEqual`、`GreaterThan`、`GreaterThanEqual`、`LessThan`、`LessThanEqual`、`RegexMatch`、`RegexNotMatch`、`RegexMatchCaseInsensitive`、`RegexNotMatchCaseInsensitive`、`In` 或 `NotIn`。 |
| `set` *string 数组*                                                             | Set 提供表达式的可接受值列表。当 Op 为 `In` 或 `NotIn` 时应使用此字段。                                                                                                                                                                |
| `value` *string*                                                                | Value 定义要与 subject 进行比较的单个值。当 Op 不是 `In` 或 `NotIn` 时应使用此字段。Set 和 Value 是互斥的 — 一次只能设置其中一个。                                                                                                     |

*出现在：*

* [ApisixRouteHTTPMatchExprs](#apisixroutehttpmatchexprs)

#### ApisixRouteHTTPMatchExprSubject[​](#apisixroutehttpmatchexprsubject "ApisixRouteHTTPMatchExprSubject的直接链接")

ApisixRouteHTTPMatchExprSubject 描述了路由匹配表达式的主体。

| 字段             | 描述                                                                                                                                                                                                                                                                                                                                             |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `scope` *string* | Scope 指定主体范围，可选值为 `Header`、`Query`、`Path`、`Cookie`、`Variable`、`Body`。Scope 为 `Path` 时忽略 Name；为 `Body` 时，Name 支持点号表示法 JSON 路径（例如 `model.version`、`messages[*].role`），并映射到 APISIX 的 `post_arg.<name>` 变量，适用于 `application/json`、`application/x-www-form-urlencoded` 和 `multipart/form-data`。 |
| `name` *string*  | Name 是给定 scope 中的主体名称：请求头、查询参数、Cookie、Nginx 变量或请求体字段名（Body scope 支持点号表示法 JSON 路径）。Scope 为 Path 时可选。                                                                                                                                                                                                |

*出现在：*

* [ApisixRouteHTTPMatchExpr](#apisixroutehttpmatchexpr)

#### ApisixRouteHTTPMatchExprs[​](#apisixroutehttpmatchexprs "ApisixRouteHTTPMatchExprs的直接链接")

*基础类型：* [ApisixRouteHTTPMatchExpr](#apisixroutehttpmatchexpr)

| 字段                                                                            | 描述                                                                                                                                                                                                                                   |
| ------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `subject` *[ApisixRouteHTTPMatchExprSubject](#apisixroutehttpmatchexprsubject)* | Subject 定义表达式的左侧。可以是任何[内置变量](https://docs.apiseven.com/apisix/reference/built-in-variables.md)或字符串字面量。                                                                                                       |
| `op` *string*                                                                   | Op 指定表达式中使用的运算符。可以是 `Equal`、`NotEqual`、`GreaterThan`、`GreaterThanEqual`、`LessThan`、`LessThanEqual`、`RegexMatch`、`RegexNotMatch`、`RegexMatchCaseInsensitive`、`RegexNotMatchCaseInsensitive`、`In` 或 `NotIn`。 |
| `set` *string 数组*                                                             | Set 提供表达式的可接受值列表。当 Op 为 `In` 或 `NotIn` 时应使用此字段。                                                                                                                                                                |
| `value` *string*                                                                | Value 定义要与 subject 进行比较的单个值。当 Op 不是 `In` 或 `NotIn` 时应使用此字段。Set 和 Value 是互斥的 — 一次只能设置其中一个。                                                                                                     |

*出现在：*

* [ApisixRouteHTTPMatch](#apisixroutehttpmatch)

#### ApisixRoutePlugin[​](#apisixrouteplugin "ApisixRoutePlugin的直接链接")

ApisixRoutePlugin 表示一个 APISIX 插件。

| 字段                                                                                                                 | 描述                              |
| -------------------------------------------------------------------------------------------------------------------- | --------------------------------- |
| `name` *string*                                                                                                      | 插件名称。                        |
| `enable` *boolean*                                                                                                   | 此插件是否正在使用，默认为 true。 |
| `config` *[JSON](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#json-v1-apiextensions-k8s-io)* | 插件配置。                        |
| `secretRef` *string*                                                                                                 | 插件配置 secretRef。              |

*出现在：*

* [ApisixConsumerSpec](#apisixconsumerspec)
* [ApisixGlobalRuleSpec](#apisixglobalrulespec)
* [ApisixPluginConfigSpec](#apisixpluginconfigspec)
* [ApisixRouteHTTP](#apisixroutehttp)
* [ApisixRouteStream](#apisixroutestream)

#### ApisixRouteSpec[​](#apisixroutespec "ApisixRouteSpec的直接链接")

ApisixRouteSpec 是 ApisixRoute 的 spec 定义。 它定义了 HTTP 和流式流量的路由规则。

| 字段                                                    | 描述                                                                                        |
| ------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
| `ingressClassName` *string*                             | IngressClassName 是此路由所属的 IngressClass 的名称。它允许多个控制器监视和协调不同的路由。 |
| `http` *[ApisixRouteHTTP](#apisixroutehttp) 数组*       | HTTP 定义 HTTP 路由规则列表。每个规则指定匹配 HTTP 请求的条件以及如何转发它们。             |
| `stream` *[ApisixRouteStream](#apisixroutestream) 数组* | Stream 定义流式路由规则列表。每个规则指定匹配 TCP/UDP 流量的条件以及如何转发它们。          |

*出现在：*

* [ApisixRoute](#apisixroute)

#### ApisixRouteStream[​](#apisixroutestream "ApisixRouteStream的直接链接")

ApisixRouteStream 定义了第 4 层（TCP/UDP）路由的配置。

| 字段                                                              | 描述                                                   |
| ----------------------------------------------------------------- | ------------------------------------------------------ |
| `name` *string*                                                   | Name 是路由的唯一标识符。此字段不能为空。              |
| `protocol` *string*                                               | Protocol 指定要匹配的 L4 协议。可以是 `TCP` 或 `UDP`。 |
| `match` *[ApisixRouteStreamMatch](#apisixroutestreammatch)*       | Match 定义用于匹配传入 TCP 或 UDP 连接的条件。         |
| `backend` *[ApisixRouteStreamBackend](#apisixroutestreambackend)* | Backend 指定应将流量转发到的目标服务。                 |
| `plugins` *[ApisixRoutePlugin](#apisixrouteplugin) 数组*          | Plugins 定义要应用于此路由的插件列表。                 |

*出现在：*

* [ApisixRouteSpec](#apisixroutespec)

#### ApisixRouteStreamBackend[​](#apisixroutestreambackend "ApisixRouteStreamBackend的直接链接")

ApisixRouteStreamBackend 表示 TCP 或 UDP 流式路由的后端服务。

| 字段                                                                                                                        | 描述                                                                                                                                                                                       |
| --------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `serviceName` *string*                                                                                                      | ServiceName 是 Kubernetes Service 的名称。不支持跨命名空间引用 — 确保 ApisixRoute 和 Service 位于同一命名空间中。                                                                          |
| `servicePort` *[IntOrString](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#intorstring-intstr-util)* | ServicePort 是 Kubernetes Service 的端口。可以是端口名称或端口号。                                                                                                                         |
| `resolveGranularity` *string*                                                                                               | ResolveGranularity 确定后端服务的解析方式。有效值为 `endpoint` 和 `service`。设置为 `endpoint` 时，将使用单个 Pod IP；否则，使用 Service 的 ClusterIP 或 ExternalIP。默认值为 `endpoint`。 |
| `subset` *string*                                                                                                           | Subset 指定目标 Service 的命名子集。该子集必须在相应的 ApisixUpstream 资源中预先定义。                                                                                                     |

*出现在：*

* [ApisixRouteStream](#apisixroutestream)

#### ApisixRouteStreamMatch[​](#apisixroutestreammatch "ApisixRouteStreamMatch的直接链接")

ApisixRouteStreamMatch 表示流式路由的匹配条件。

| 字段                    | 描述                                                                                                         |
| ----------------------- | ------------------------------------------------------------------------------------------------------------ |
| `ingressPort` *integer* | IngressPort 是 APISIX Ingress 代理服务器监听的端口。这必须是静态配置的端口，因为 APISIX 不支持动态端口绑定。 |
| `host` *string*         | Host 是用于匹配传入 TCP/UDP 流量的目标主机地址。                                                             |

*出现在：*

* [ApisixRouteStream](#apisixroutestream)

#### ApisixRouteUpstreamReference[​](#apisixrouteupstreamreference "ApisixRouteUpstreamReference的直接链接")

ApisixRouteUpstreamReference 引用一个 ApisixUpstream CRD 作为后端。 可用于流量拆分场景或选择特定的上游配置。

| 字段               | 描述                                |
| ------------------ | ----------------------------------- |
| `name` *string*    | Name 是 ApisixUpstream 资源的名称。 |
| `weight` *integer* | Weight 是分配给此上游的权重。       |

*出现在：*

* [ApisixRouteHTTP](#apisixroutehttp)

#### ApisixSecret[​](#apisixsecret "ApisixSecret的直接链接")

ApisixSecret 描述对 Kubernetes Secret 的引用，包括其名称和命名空间。 这用于定位 Secret，例如插件或 TLS 配置的证书或凭证。

| 字段                 | 描述                                            |
| -------------------- | ----------------------------------------------- |
| `name` *string*      | Name 是 Kubernetes Secret 的名称。              |
| `namespace` *string* | Namespace 是 Kubernetes Secret 所在的命名空间。 |

*出现在：*

* [ApisixMutualTlsClientConfig](#apisixmutualtlsclientconfig)
* [ApisixTlsSpec](#apisixtlsspec)
* [ApisixUpstreamConfig](#apisixupstreamconfig)
* [ApisixUpstreamSpec](#apisixupstreamspec)
* [PortLevelSettings](#portlevelsettings)

#### ApisixTlsSpec[​](#apisixtlsspec "ApisixTlsSpec的直接链接")

ApisixTlsSpec 定义了 TLS 和双向 TLS 的配置。

| 字段                                                                   | 描述                                                                                                             |
| ---------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| `ingressClassName` *string*                                            | IngressClassName 指定此资源关联的 IngressClass。仅当该类与控制器自身的类匹配时，APISIX 控制器才会处理此资源。    |
| `hosts` *[HostType](#hosttype) 数组*                                   | Hosts 列出此 TLS 配置适用的 SNI（服务器名称指示）主机名。必须至少包含一个主机。                                  |
| `secret` *[ApisixSecret](#apisixsecret)*                               | Secret 引用包含证书和私钥的 Kubernetes TLS Secret。此 Secret 必须存在于指定的命名空间中，并包含有效的 TLS 数据。 |
| `client` *[ApisixMutualTlsClientConfig](#apisixmutualtlsclientconfig)* | Client 定义双向 TLS (mTLS) 设置，例如 CA 证书和验证深度。                                                        |

*出现在：*

* [ApisixTls](#apisixtls)

#### ApisixUpstreamConfig[​](#apisixupstreamconfig "ApisixUpstreamConfig的直接链接")

ApisixUpstreamConfig 定义了上游服务的配置。

| 字段                                                           | 描述                                                                                                                                                                                                                                      |
| -------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `loadbalancer` *[LoadBalancer](#loadbalancer)*                 | LoadBalancer 指定 Kubernetes Service 的负载均衡器配置。                                                                                                                                                                                   |
| `scheme` *string*                                              | Scheme 是与上游通信时使用的协议，默认值为 `http`。L7 代理可使用 `http`、`https`、`grpc` 或 `grpcs`；L4 代理可使用 `tcp`、`tls` 或 `udp`。L4 值仅适用于四层流式路由；在 HTTP 路由上使用会使上游不可达。                                    |
| `retries` *integer*                                            | Retries 定义发生故障时 APISIX 应进行的重试尝试次数。故障包括超时、网络错误或 5xx 状态码。                                                                                                                                                 |
| `timeout` *[UpstreamTimeout](#upstreamtimeout)*                | Timeout 指定上游请求的连接、发送和读取超时。                                                                                                                                                                                              |
| `healthCheck` *[HealthCheck](#healthcheck)*                    | HealthCheck 定义上游的主动和被动健康检查配置。                                                                                                                                                                                            |
| `tlsSecret` *[ApisixSecret](#apisixsecret)*                    | TLSSecret 引用一个 Kubernetes Secret，其中包含连接到上游时用于双向 TLS 的客户端证书和密钥。                                                                                                                                               |
| `subsets` *[ApisixUpstreamSubset](#apisixupstreamsubset) 数组* | Subsets 定义服务端点的带标签子集，通常用于服务版本控制或灰度部署。                                                                                                                                                                        |
| `passHost` *string*                                            | PassHost 配置当请求转发到上游时，主机标头应如何确定。默认值为 `pass`。可选值为 `pass`、`node` 或 `rewrite`：<br />• `pass`：保留原始 Host 标头<br />• `node`：使用上游节点的主机名<br />• `rewrite`：通过 `upstreamHost` 设置为自定义主机 |
| `upstreamHost` *string*                                        | UpstreamHost 在 passHost 设置为 `rewrite` 时设置自定义 Host 标头。                                                                                                                                                                        |
| `discovery` *[Discovery](#discovery)*                          | Discovery 为上游配置服务发现。                                                                                                                                                                                                            |

*出现在：*

* [ApisixUpstreamSpec](#apisixupstreamspec)
* [PortLevelSettings](#portlevelsettings)

#### ApisixUpstreamExternalNode[​](#apisixupstreamexternalnode "ApisixUpstreamExternalNode的直接链接")

ApisixUpstreamExternalNode 定义了外部上游节点的配置。 这允许引用集群外部的服务。

| 字段                                                               | 描述                                                                  |
| ------------------------------------------------------------------ | --------------------------------------------------------------------- |
| `name` *string*                                                    | Name 是外部节点的主机名或 IP 地址。                                   |
| `type` *[ApisixUpstreamExternalType](#apisixupstreamexternaltype)* | Type 指示外部节点的类型。可以是 `Domain` 或 `Service`。               |
| `weight` *integer*                                                 | Weight 定义此节点的负载均衡权重。值越高，发送到此节点的流量份额越大。 |
| `port` *integer*                                                   | Port 指定外部节点接受流量的端口号。                                   |

*出现在：*

* [ApisixUpstreamSpec](#apisixupstreamspec)

#### ApisixUpstreamExternalType[​](#apisixupstreamexternaltype "ApisixUpstreamExternalType的直接链接")

*基础类型：* `string`

ApisixUpstreamExternalType 是外部服务类型

*出现在：*

* [ApisixUpstreamExternalNode](#apisixupstreamexternalnode)

#### ApisixUpstreamSpec[​](#apisixupstreamspec "ApisixUpstreamSpec的直接链接")

ApisixUpstreamSpec 描述了 ApisixUpstream 资源的期望配置。 它定义了流量应如何路由到后端服务，包括上游节点定义和自定义配置。

| 字段                                                                             | 描述                                                                                                                                                                                                                                      |
| -------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ingressClassName` *string*                                                      | IngressClassName 是 IngressClass 集群资源的名称。控制器实现使用此字段来决定是否应处理此 ApisixUpstream 资源。                                                                                                                             |
| `externalNodes` *[ApisixUpstreamExternalNode](#apisixupstreamexternalnode) 数组* | ExternalNodes 定义静态后端节点列表。这些可以是集群外部的宿主，或由其 DNS 名称指定的集群内部 Service。设置此字段后，上游将直接将流量路由到这些节点，而无需 DNS 解析或服务发现。                                                            |
| `loadbalancer` *[LoadBalancer](#loadbalancer)*                                   | LoadBalancer 指定 Kubernetes Service 的负载均衡器配置。                                                                                                                                                                                   |
| `scheme` *string*                                                                | Scheme 是与上游通信时使用的协议，默认值为 `http`。L7 代理可使用 `http`、`https`、`grpc` 或 `grpcs`；L4 代理可使用 `tcp`、`tls` 或 `udp`。L4 值仅适用于四层流式路由；在 HTTP 路由上使用会使上游不可达。                                    |
| `retries` *integer*                                                              | Retries 定义发生故障时 APISIX 应进行的重试尝试次数。故障包括超时、网络错误或 5xx 状态码。                                                                                                                                                 |
| `timeout` *[UpstreamTimeout](#upstreamtimeout)*                                  | Timeout 指定上游请求的连接、发送和读取超时。                                                                                                                                                                                              |
| `healthCheck` *[HealthCheck](#healthcheck)*                                      | HealthCheck 定义上游的主动和被动健康检查配置。                                                                                                                                                                                            |
| `tlsSecret` *[ApisixSecret](#apisixsecret)*                                      | TLSSecret 引用一个 Kubernetes Secret，其中包含连接到上游时用于双向 TLS 的客户端证书和密钥。                                                                                                                                               |
| `subsets` *[ApisixUpstreamSubset](#apisixupstreamsubset) 数组*                   | Subsets 定义服务端点的带标签子集，通常用于服务版本控制或灰度部署。                                                                                                                                                                        |
| `passHost` *string*                                                              | PassHost 配置当请求转发到上游时，主机标头应如何确定。默认值为 `pass`。可选值为 `pass`、`node` 或 `rewrite`：<br />• `pass`：保留原始 Host 标头<br />• `node`：使用上游节点的主机名<br />• `rewrite`：通过 `upstreamHost` 设置为自定义主机 |
| `upstreamHost` *string*                                                          | UpstreamHost 在 passHost 设置为 `rewrite` 时设置自定义 Host 标头。                                                                                                                                                                        |
| `discovery` *[Discovery](#discovery)*                                            | Discovery 为上游配置服务发现。                                                                                                                                                                                                            |
| `portLevelSettings` *[PortLevelSettings](#portlevelsettings) 数组*               | PortLevelSettings 允许针对特定端口进行精细的上游配置，当后端服务公开具有不同行为或协议的多个端口时非常有用。                                                                                                                              |

*出现在：*

* [ApisixUpstream](#apisixupstream)

#### ApisixUpstreamSubset[​](#apisixupstreamsubset "ApisixUpstreamSubset的直接链接")

ApisixUpstreamSubset 定义一个 Service 的单个端点组。

| 字段                                                                           | 描述                      |
| ------------------------------------------------------------------------------ | ------------------------- |
| `name` *string*                                                                | Name 是子集的名称。       |
| `labels` *object (keys<!-- -->:string<!-- -->, values<!-- -->:string<!-- -->)* | Labels 是此子集的标签集。 |

*出现在：*

* [ApisixUpstreamConfig](#apisixupstreamconfig)
* [ApisixUpstreamSpec](#apisixupstreamspec)
* [PortLevelSettings](#portlevelsettings)

#### Discovery[​](#discovery "Discovery的直接链接")

Discovery 定义了用于动态解析上游节点的服务发现配置。 当 APISIX 与诸如 Nacos、Consul 或 Eureka 等服务注册中心集成时使用。

| 字段                                                                         | 描述                                                            |
| ---------------------------------------------------------------------------- | --------------------------------------------------------------- |
| `serviceName` *string*                                                       | ServiceName 是要发现的服务名称。                                |
| `type` *string*                                                              | Type 是服务发现提供者的名称。                                   |
| `args` *object (keys<!-- -->:string<!-- -->, values<!-- -->:string<!-- -->)* | Args 包含发现提供者所需的附加配置参数。这些参数作为键值对传递。 |

*出现在：*

* [ApisixUpstreamConfig](#apisixupstreamconfig)
* [ApisixUpstreamSpec](#apisixupstreamspec)
* [PortLevelSettings](#portlevelsettings)

#### HealthCheck[​](#healthcheck-1 "HealthCheck的直接链接")

HealthCheck 定义了上游节点的健康检查配置。 它包括主动检查（主动探测节点）和可选的被动检查（基于流量的监控）。

| 字段                                                  | 描述                                                             |
| ----------------------------------------------------- | ---------------------------------------------------------------- |
| `active` *[ActiveHealthCheck](#activehealthcheck)*    | 主动健康检查会主动向上游节点发送请求以确定其可用性。             |
| `passive` *[PassiveHealthCheck](#passivehealthcheck)* | 被动健康检查根据观察到的流量（例如超时或错误）评估上游健康状况。 |

*出现在：*

* [ApisixUpstreamConfig](#apisixupstreamconfig)
* [ApisixUpstreamSpec](#apisixupstreamspec)
* [PortLevelSettings](#portlevelsettings)

#### HostType[​](#hosttype "HostType的直接链接")

*基础类型：* `string`

*出现在：*

* [ApisixTlsSpec](#apisixtlsspec)

#### LoadBalancer[​](#loadbalancer-1 "LoadBalancer的直接链接")

LoadBalancer 定义了跨上游节点分配流量的负载均衡策略。

| 字段              | 描述                                                                                                                                                                                                                                                                                                                                             |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `type` *string*   | Type 指定将流量路由到后端的负载均衡算法。默认值为 `roundrobin`。可选值为 `roundrobin`、`chash`、`ewma` 或 `least_conn`。                                                                                                                                                                                                                         |
| `hashOn` *string* | HashOn 指定用于哈希的字段类型，当 type 为 `chash` 时必需。默认值为 `vars`。可选值为 `vars`、`header`、`cookie`、`consumer` 或 `vars_combinations`。                                                                                                                                                                                              |
| `key` *string*    | Key 与 HashOn 一起使用，当 type 为 `chash` 时通常必需。当 HashOn 为 `header` 或 `cookie` 时，指定标头或 cookie 的名称。当 HashOn 为 `consumer` 时，key 不是必需的，因为会自动使用消费者名称。当 HashOn 为 `vars` 或 `vars_combinations` 时，key 指一个或多个[内置变量](https://docs.apiseven.com/apisix/reference/built-in-variables.md)的组合。 |

*出现在：*

* [ApisixUpstreamConfig](#apisixupstreamconfig)
* [ApisixUpstreamSpec](#apisixupstreamspec)
* [PortLevelSettings](#portlevelsettings)

#### PassiveHealthCheck[​](#passivehealthcheck-1 "PassiveHealthCheck的直接链接")

PassiveHealthCheck 定义了基于被动观察来确定上游节点健康或不健康的条件。 被动健康检查依赖于实际流量响应，而不是主动探测。

| 字段                                                                      | 描述                                                           |
| ------------------------------------------------------------------------- | -------------------------------------------------------------- |
| `type` *string*                                                           | Type 指定被动健康检查的类型。可以是 `http`、`https` 或 `tcp`。 |
| `healthy` *[PassiveHealthCheckHealthy](#passivehealthcheckhealthy)*       | Healthy 定义上游节点被视为健康的条件。                         |
| `unhealthy` *[PassiveHealthCheckUnhealthy](#passivehealthcheckunhealthy)* | Unhealthy 定义上游节点被视为不健康的条件。                     |

*出现在：*

* [HealthCheck](#healthcheck)

#### PassiveHealthCheckHealthy[​](#passivehealthcheckhealthy-1 "PassiveHealthCheckHealthy的直接链接")

PassiveHealthCheckHealthy 定义了用于被动确定上游节点是否健康的条件。

| 字段                       | 描述                                               |
| -------------------------- | -------------------------------------------------- |
| `httpCodes` *integer 数组* | HTTPCodes 定义被视为健康的 HTTP 状态码列表。       |
| `successes` *integer*      | Successes 定义将目标定义为健康所需的成功探测次数。 |

*出现在：*

* [ActiveHealthCheckHealthy](#activehealthcheckhealthy)
* [PassiveHealthCheck](#passivehealthcheck)

#### PassiveHealthCheckUnhealthy[​](#passivehealthcheckunhealthy-1 "PassiveHealthCheckUnhealthy的直接链接")

UpstreamPassiveHealthCheckUnhealthy 定义了用于被动确定上游节点是否不健康的条件。

| 字段                       | 描述                                                      |
| -------------------------- | --------------------------------------------------------- |
| `httpCodes` *integer 数组* | HTTPCodes 定义被视为不健康的 HTTP 状态码列表。            |
| `httpFailures` *integer*   | HTTPFailures 定义将目标定义为不健康所需的 HTTP 失败次数。 |
| `tcpFailures` *integer*    | TCPFailures 定义将目标定义为不健康所需的 TCP 失败次数。   |
| `timeout` *integer*        | Timeout 设置将目标定义为不健康所需的超时次数。            |

*出现在：*

* [ActiveHealthCheckUnhealthy](#activehealthcheckunhealthy)
* [PassiveHealthCheck](#passivehealthcheck)

#### PortLevelSettings[​](#portlevelsettings "PortLevelSettings的直接链接")

PortLevelSettings 为每个单独的端口配置 ApisixUpstreamConfig。它继承自外层（整个 Kubernetes Service）的配置，并在端口级别设置了某些配置时覆盖它们。

| 字段                                                           | 描述                                                                                                                                                                                                                                      |
| -------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `loadbalancer` *[LoadBalancer](#loadbalancer)*                 | LoadBalancer 指定 Kubernetes Service 的负载均衡器配置。                                                                                                                                                                                   |
| `scheme` *string*                                              | Scheme 是与上游通信时使用的协议，默认值为 `http`。L7 代理可使用 `http`、`https`、`grpc` 或 `grpcs`；L4 代理可使用 `tcp`、`tls` 或 `udp`。L4 值仅适用于四层流式路由；在 HTTP 路由上使用会使上游不可达。                                    |
| `retries` *integer*                                            | Retries 定义发生故障时 APISIX 应进行的重试尝试次数。故障包括超时、网络错误或 5xx 状态码。                                                                                                                                                 |
| `timeout` *[UpstreamTimeout](#upstreamtimeout)*                | Timeout 指定上游请求的连接、发送和读取超时。                                                                                                                                                                                              |
| `healthCheck` *[HealthCheck](#healthcheck)*                    | HealthCheck 定义上游的主动和被动健康检查配置。                                                                                                                                                                                            |
| `tlsSecret` *[ApisixSecret](#apisixsecret)*                    | TLSSecret 引用一个 Kubernetes Secret，其中包含连接到上游时用于双向 TLS 的客户端证书和密钥。                                                                                                                                               |
| `subsets` *[ApisixUpstreamSubset](#apisixupstreamsubset) 数组* | Subsets 定义服务端点的带标签子集，通常用于服务版本控制或灰度部署。                                                                                                                                                                        |
| `passHost` *string*                                            | PassHost 配置当请求转发到上游时，主机标头应如何确定。默认值为 `pass`。可选值为 `pass`、`node` 或 `rewrite`：<br />• `pass`：保留原始 Host 标头<br />• `node`：使用上游节点的主机名<br />• `rewrite`：通过 `upstreamHost` 设置为自定义主机 |
| `upstreamHost` *string*                                        | UpstreamHost 在 passHost 设置为 `rewrite` 时设置自定义 Host 标头。                                                                                                                                                                        |
| `discovery` *[Discovery](#discovery)*                          | Discovery 为上游配置服务发现。                                                                                                                                                                                                            |
| `port` *integer*                                               | Port 是 Kubernetes Service 端口。                                                                                                                                                                                                         |

*出现在：*

* [ApisixUpstreamSpec](#apisixupstreamspec)

#### UpstreamTimeout[​](#upstreamtimeout "UpstreamTimeout的直接链接")

UpstreamTimeout 定义了连接到上游、向上游发送数据以及从上游读取数据的超时设置。

| 字段                                                                                                          | 描述                       |
| ------------------------------------------------------------------------------------------------------------- | -------------------------- |
| `connect` *[Duration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#duration-v1-meta)* | 与上游建立连接的连接超时。 |
| `send` *[Duration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#duration-v1-meta)*    | 向上游发送数据的发送超时。 |
| `read` *[Duration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#duration-v1-meta)*    | 从上游读取数据的读取超时。 |

*出现在：*

* [ApisixRouteHTTP](#apisixroutehttp)
* [ApisixUpstreamConfig](#apisixupstreamconfig)
* [ApisixUpstreamSpec](#apisixupstreamspec)
* [PortLevelSettings](#portlevelsettings)
