> ## Documentation Index
> Fetch the complete documentation index at: https://docs.siflow.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# 使用 Ingress 暴露集群服务

> 为已有 Service 配置 HTTP 或 HTTPS 路由，确认请求转发关系，并维护 Ingress。

Ingress 用于根据域名和路径，将 HTTP 或 HTTPS 请求转发到已有的 Service。Ingress 不直接关联 Pod；Service 负责选择后端 Pod，Ingress 只负责配置访问路由。

## 操作前确认

* 已创建可访问后端 Pod 的 Service。具体操作请参见 [创建和管理 Service](/gpu-cloud/cluster/create-and-manage-service)。
* 集群已安装处理 Ingress 路由的组件。

## 创建 Ingress

1. 登录 [GPU 云服务控制台](https://console.siflow.cn/gpu-cloud/home)，进入 **集群** 页面。

2. 单击目标集群名称，进入集群工作台。

3. 在左侧导航中单击 **网络**。

4. 切换到 **Ingress** 页签，单击 **创建**。

5. 配置 Ingress。

   | 参数 | 说明 |
   | - | - |
   | **Name** | 设置 Ingress 名称。建议使用能够体现服务或入口用途的名称。 |
   | **Namespace** | 选择 Ingress 所属命名空间。Ingress 需要引用同一命名空间下的 Service。 |
   | **Labels** | 可选。添加用于标识或筛选 Ingress 的标签。 |
   | **Spec (YAML)** | 填写 Ingress 的 Kubernetes spec，只包含 `spec` 下的内容，不需要填写 `apiVersion`、`kind` 或 `metadata`。 |

   <Tabs>
     <Tab title="Ingress Spec 示例">
       将域名、Service 名称和端口替换为业务实际值。

       ```yaml theme={null}
       rules:
         - host: example.com
           http:
             paths:
               - path: /
                 pathType: Prefix
                 backend:
                   service:
                     name: nginx-service
                     port:
                       number: 80
       ```
     </Tab>

     <Tab title="完整 Ingress YAML 参考">
       通过 Kubernetes YAML 准备完整 Ingress manifest 时，可以参考以下结构。

       ```yaml theme={null}
       apiVersion: networking.k8s.io/v1
       kind: Ingress
       metadata:
         name: nginx-ingress
         namespace: default
       spec:
         rules:
           - host: example.com
             http:
               paths:
                 - path: /
                   pathType: Prefix
                   backend:
                     service:
                       name: nginx-service
                       port:
                         number: 80
       ```
     </Tab>
   </Tabs>

   示例中的 `service.name` 和端口必须与已有 Service 一致，并且 Ingress 与目标 Service 应位于同一命名空间。

6. 提交创建，返回 **Ingress** 页签确认 Ingress 已创建，并核对域名、路径和目标 Service 是否符合预期。

## 调整或移除访问入口

<Warning>
  修改 Ingress 路由可能改变请求转发结果；删除 Ingress 会中断依赖该入口的访问。操作前，请确认域名、路径、目标 Service 和业务影响。
</Warning>

1. 在 **Ingress** 页签中，按命名空间筛选或使用搜索框定位目标 Ingress。

2. 按需执行操作：

   * 修改路由：单击 **Edit**，修改后提交。
   * 删除入口：单击 **Delete**，并在确认对话框中核对资源信息。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.