通过集群插件安装 Ingress-Nginx

WARNING

Ingress-Nginx 集群插件已被废弃。请改用 ingress-nginx-operator

概述

NGINX Ingress Controller 作为集群插件部署在 cpaas-system 命名空间中。本指南涵盖了在 Kubernetes 集群中安装、配置及管理 Ingress NGINX Controller 的最佳实践。

安装

  1. 进入 管理员 -> Marketplace -> 集群插件
  2. 找到 Ingress NGINX 插件并点击 安装 安装 Ingress 插件

配置管理

更新配置

  1. 配置 kubectl 使用 全局 集群上下文
  2. 获取集群对应的 ModuleInfo 名称:
    kubectl get minfo | grep ingress | grep $CLUSTER_NAME
  3. 编辑 ModuleInfo 配置:
    kubectl edit minfo $MINFO
    其中 spec.config 部分对应 Ingress NGINX Helm Chart 的 values。

常见配置场景

通过 LoadBalancer 暴露

使用 LoadBalancer 类型的 Service 暴露 Ingress Controller:

spec:
  config:
    controller:
      service:
        type: LoadBalancer

MetalLB 集成

使用 MetalLB 时指定 LoadBalancer VIP:

spec:
  config:
    controller:
      service:
        annotations:
          metallb.universe.tf/loadBalancerIPs: "192.168.2.2"  # 期望的 VIP
          metallb.universe.tf/address-pool: "pool-name"        # MetalLB 地址池

高级 Controller 部署设置

配置网络模式、副本数、资源限制及节点选择:

spec:
  config:
    controller:
      hostNetwork: false
      replicaCount: 1
      nodeSelector:
        kubernetes.io/os: linux
      resources:
        limits:
          cpu: 200m
          memory: 256Mi
        requests:
          cpu: 200m
          memory: 256Mi

SSL 透传

启用 SSL 透传功能:

spec:
  config:
    controller:
      extraArgs:
        enable-ssl-passthrough: ""

IPv6 单栈支持

配置仅使用 IPv6:

spec:
  config:
    controller:
      service:
        ipFamilies:
          - IPv6

性能调优

资源分配建议

小规模(< 300 QPS)

spec:
  config:
    controller:
      resources:
        limits:
          cpu: 200m
          memory: 256Mi
        requests:
          cpu: 200m
          memory: 256Mi

中等规模(< 10,000 QPS)

spec:
  config:
    controller:
      resources:
        limits:
          cpu: "2"
          memory: 1Gi
        requests:
          cpu: "2"
          memory: 1Gi

大规模(< 20,000 QPS)

spec:
  config:
    controller:
      resources:
        limits:
          cpu: "4"
          memory: 2Gi
        requests:
          cpu: "4"
          memory: 2Gi

高性能(无限制)

最大性能且无 CPU 限制:

spec:
  config:
    controller:
      resources:
        requests:
          cpu: "4"
          memory: 2Gi

重要说明

限制

  • 每个集群仅支持一个 Ingress NGINX Controller 实例

版本兼容性

当前版本对应关系:
ACP Ingress-NGINX 4.1.x 对应官方 Chart 4.12.2(controller v1.12.3)

相关资源

tasks for ingress-nginx
官方 Ingress NGINX Chart
官方 Ingress NGINX 文档