---
api_metadata:
apiVersion: "networking.k8s.io/v1"
import: "k8s.io/api/networking/v1"
kind: "IngressClass"
content_type: "api_reference"
description: "IngressClass 代表 Ingress 的类,被 Ingress 的规约引用。"
title: "IngressClass"
weight: 5
---
`apiVersion: networking.k8s.io/v1`
`import "k8s.io/api/networking/v1"`
## IngressClass {#IngressClass}
IngressClass 代表 Ingress 的类,被 Ingress 的规约引用。
`ingressclass.kubernetes.io/is-default-class`
注解可以用来标明一个 IngressClass 应该被视为默认的 Ingress 类。
当某个 IngressClass 资源将此注解设置为 true 时,
没有指定类的新 Ingress 资源将被分配到此默认类。
- **apiVersion**: networking.k8s.io/v1
- **kind**: IngressClass
- **metadata** (}}">ObjectMeta)
标准的列表元数据。更多信息:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
- **spec** (}}">IngressClassSpec)
spec 是 IngressClass 的期望状态。更多信息:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
## IngressClassSpec {#IngressClassSpec}
IngressClassSpec 提供有关 Ingress 类的信息。
- **controller** (string)
controller 是指应该处理此类的控制器名称。
这允许由同一控制器控制不同“口味”。例如,对于同一个实现的控制器你可能有不同的参数。
此字段应该指定为长度不超过 250 个字符的域前缀路径,例如 “acme.io/ingress-controller”。
该字段是不可变的。
- **parameters** (IngressClassParametersReference)
parameters 是指向控制器中包含额外配置的自定义资源的链接。
如果控制器不需要额外的属性,这是可选的。
**IngressClassParametersReference 标识一个 API 对象。这可以用来指定一个集群或者命名空间范围的资源**
- **parameters.kind** (string),必需
kind 是被引用资源的类型。
- **parameters.name** (string),必需
name 是被引用资源的名称。
- **parameters.apiGroup** (string)
apiGroup 是被引用资源的组。
如果未指定 apiGroup,则被指定的 kind 必须在核心 API 组中。
对于任何其他第三方类型,apiGroup 是必需的。
- **parameters.namespace** (string)
namespace 是被引用资源的命名空间。
当范围被设置为 “namespace” 时,此字段是必需的;
当范围被设置为 “Cluster” 时,此字段必须不设置。
- **parameters.scope** (string)
scope 表示是否引用集群或者命名空间范围的资源。
这可以设置为“集群”(默认)或者“命名空间”。
## IngressClassList {#IngressClassList}
IngressClassList 是 IngressClasses 的集合。
- **apiVersion**: networking.k8s.io/v1
- **kind**: IngressClassList
- **metadata** (}}">ListMeta)
标准的列表元数据。
- **items** ([]}}">IngressClass),必需
items 是 IngressClasses 的列表。
## 操作 {#Operations}
### `get` 读取指定的 IngressClass
#### HTTP 请求
GET /apis/networking.k8s.io/v1/ingressclasses/{name}
#### 参数
- **name** (**路径参数**):string,必需
IngressClass 的名称
- **pretty** (**查询参数**):string
}}">pretty
#### 响应
200 (}}">IngressClass): OK
401: Unauthorized
### `list` 列出或监视 IngressClass 类型的对象
#### HTTP 请求
GET /apis/networking.k8s.io/v1/ingressclasses
#### 参数
- **allowWatchBookmarks** (**查询参数**):boolean
}}">allowWatchBookmarks
- **continue** (**查询参数**):string
}}">continue
- **fieldSelector** (**查询参数**):string
}}">fieldSelector
- **labelSelector** (**查询参数**):string
}}">labelSelector
- **limit** (**查询参数**):integer
}}">limit
- **pretty** (**查询参数**):string
}}">pretty
- **resourceVersion** (**查询参数**):string
}}">resourceVersion
- **resourceVersionMatch** (**查询参数**):string
}}">resourceVersionMatch
- **sendInitialEvents** (**查询参数**): boolean
}}">sendInitialEvents
- **timeoutSeconds** (**查询参数**):integer
}}">timeoutSeconds
- **watch** (**查询参数**):boolean
}}">watch
#### 响应
200 (}}">IngressClassList): OK
401: Unauthorized
### `create` 创建一个 IngressClass
#### HTTP 请求
POST /apis/networking.k8s.io/v1/ingressclasses
#### 参数
- **body**: }}">IngressClass,必需
- **dryRun** (**查询参数**):string
}}">dryRun
- **fieldManager** (**查询参数**):string
}}">fieldManager
- **fieldValidation** (**查询参数**):string
}}">fieldValidation
- **pretty** (**查询参数**):string
}}">pretty
#### 响应
200 (}}">IngressClass): OK
201 (}}">IngressClass): Created
202 (}}">IngressClass): Accepted
401: Unauthorized
### `update` 替换指定的 IngressClass
#### HTTP 请求
PUT /apis/networking.k8s.io/v1/ingressclasses/{name}
#### 参数
- **name** (**路径参数**):string,必需
IngressClass 的名称
- **body**: }}">IngressClass,必需
- **dryRun** (**查询参数**):string
}}">dryRun
- **fieldManager** (**查询参数**):string
}}">fieldManager
- **fieldValidation** (**查询参数**):string
}}">fieldValidation
- **pretty** (**查询参数**):string
}}">pretty
#### 响应
200 (}}">IngressClass): OK
201 (}}">IngressClass): Created
401: Unauthorized
### `patch` 部分更新指定的 IngressClass
#### HTTP 请求
PATCH /apis/networking.k8s.io/v1/ingressclasses/{name}
#### 参数
- **name** (**路径参数**):string,必需
IngressClass 的名称
- **body**: }}">Patch,必需
- **dryRun** (**查询参数**):string
}}">dryRun
- **fieldManager** (**查询参数**):string
}}">fieldManager
- **fieldValidation** (**查询参数**):string
}}">fieldValidation
- **force** (**查询参数**):boolean
}}">force
- **pretty** (**查询参数**):string
}}">pretty
#### 响应
200 (}}">IngressClass): OK
201 (}}">IngressClass): Created
401: Unauthorized
### `delete` 删除一个 IngressClass
#### HTTP 请求
DELETE /apis/networking.k8s.io/v1/ingressclasses/{name}
#### 参数
- **name** (**路径参数**):string,必需
IngressClass 的名称
- **body**: }}">DeleteOptions
- **dryRun** (**查询参数**):string
}}">dryRun
- **gracePeriodSeconds** (**查询字符串**):integer
}}">gracePeriodSeconds
- **pretty** (**查询参数**):string
}}">pretty
- **propagationPolicy** (**查询参数**):string
}}">propagationPolicy
#### 响应
200 (}}">Status): OK
202 (}}">Status): Accepted
401: Unauthorized
### `deletecollection` 删除 IngressClass 的集合
DELETE /apis/networking.k8s.io/v1/ingressclasses
#### 参数
- **body**: }}">DeleteOptions
- **continue** (**查询参数**):string
}}">continue
- **dryRun** (**查询参数**):string
}}">dryRun
- **fieldSelector** (**查询参数**):string
}}">fieldSelector
- **gracePeriodSeconds** (**查询字符串**):integer
}}">gracePeriodSeconds
- **labelSelector** (**查询参数**):string
}}">labelSelector
- **limit** (**查询参数**):integer
}}">limit
- **pretty** (**查询参数**):string
}}">pretty
- **propagationPolicy** (**查询参数**):string
}}">propagationPolicy
- **resourceVersion** (**查询参数**):string
}}">resourceVersion
- **resourceVersionMatch** (**查询参数**):string
}}">resourceVersionMatch
- **sendInitialEvents** (**查询参数**): boolean
}}">sendInitialEvents
- **timeoutSeconds** (**查询参数**):integer
}}">timeoutSeconds
#### 响应
200 (}}">Status): OK
401: Unauthorized