---
title: "创建Ingress"
method: POST
path: "/k8s/cluster/{id}/namespaces/{namespaceName}/ingresses"
tags: ["K8s Ingress管理"]
---

# 创建Ingress

`POST /k8s/cluster/{id}/namespaces/{namespaceName}/ingresses`

在指定命名空间中创建新的Ingress

## Path parameters

- `id` integer, required
- `namespaceName` string, required

## Headers

- `Authorization` string, required

## Request body

- ModelCreateIngressRequest
  - `annotations` object — 注释
  - `class` string — Ingress类
  - `labels` object — 标签
  - `name` string, required — Ingress名称
  - `rules` ModelIngressRuleSpec[], required — 路由规则
    - `host` string, required — 主机名
    - `paths` ModelIngressPathSpec[], required — 路径规则
      - `path` string, required — 路径
      - `pathType` string, required — 路径类型
      - `serviceName` string, required — 服务名称
      - `servicePort` integer, required — 服务端口
  - `tls` ModelIngressTLSSpec[] — TLS配置
    - `hosts` string[], required — 主机列表
    - `secretName` string, required — 证书Secret名称

## Response `200`

OK

- object
  - `code` integer — 状态码
  - `data` object — 返回的数据
    - `class` string — Ingress类/控制器类型
    - `controllerName` string — Controller名称
    - `controllerVersion` string — Controller版本
    - `createdAt` string — 创建时间
    - `endpoints` string[] — 访问端点
    - `labels` object — 标签
    - `loadBalancer` ModelIngressLoadBalancer
      - `ingress` ModelIngressLoadBalancerIngress[] — 入口信息
        - `hostname` string — 主机名
        - `ip` string — IP地址
        - `ports` ModelIngressLoadBalancerPort[] — 端口信息
          - `port` integer — 端口号
          - `protocol` string — 协议
    - `name` string — Ingress名称
    - `namespace` string — 命名空间
    - `rules` ModelIngressRule[] — 路由规则
      - `host` string — 主机名
      - `http` ModelIngressRuleValue
        - `paths` ModelIngressPath[] — 路径规则
          - `backend` ModelIngressBackend
            - `service` ModelIngressServiceBackend
              - …
          - `path` string — 路径
          - `pathType` string — 路径类型 Exact/Prefix/ImplementationSpecific
    - `status` string — 状态
    - `tls` ModelIngressTLS[] — TLS配置
      - `hosts` string[] — 主机列表
      - `secretName` string — 证书Secret名称
    - `type` string — Ingress类型：公网Nginx/内网Nginx等
  - `message` string — 提示信息

## Other responses

- `400` — Bad Request
- `401` — Unauthorized
- `500` — Internal Server Error

---

[API](https://skmtc.net/opsre/apis/devops.md) · [All operations](https://skmtc.net/opsre/apis/devops/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/opsre/devops/revisions/25cac8835c4c/schema)
