Use NGINX Ingress

更新时间:
复制 MD 格式

NGINX Ingress routes external traffic to in-cluster Services through the Ingress API; the NGINX Ingress controller runs in the cluster for high performance and customization. ACK Edge integrates the community controller with Alibaba Cloud capabilities. This topic explains how to deploy NGINX Ingress in an ACK Edge cluster for cloud and edge node pools.ACK Edge cluster and create Ingresses for cloud and edge node pools of the ACK Edge cluster.

Important

The open source Ingress-NGINX project will no longer be maintained after March 2026. Consequently, Container Service for Kubernetes will discontinue maintenance for the NGINX Ingress controller component. Be aware of the risks. See [Product Announcement] Announcement on discontinuation of maintenance for the NGINX Ingress controller component.

Procedure

  1. Deploy the NGINX Ingress controller in the cloud and edge node pools. See Deploy the NGINX Ingress controller. After deployment, check the controller status and Service exposure.

    1. Check the NGINX Ingress controller pod status in the cloud node pool:

      kubectl get po -n ingress-cloud -o wide

      Expected output:

      NAME                                                     READY   STATUS    RESTARTS   AGE     IP           NODE           NOMINATED NODE   READINESS GATES
      ack-ingress-nginx-v1-cloud-controller-7d7b555f8b-5kgqb   1/1     Running   0          20s     10.10.0.1    cloud-node-1   <none>           <none>
      ack-ingress-nginx-v1-cloud-controller-7d7b555f8b-725cl   1/1     Running   0          20s     10.10.0.2    cloud-node-2   <none>           <none>
    2. Check the NGINX Ingress controller Service status in the cloud node pool:

      kubectl get svc -n ingress-cloud

      Expected output:

      NAME                                    TYPE           CLUSTER-IP      EXTERNAL-IP       PORT(S)                      AGE
      ack-ingress-nginx-v1-cloud-controller   LoadBalancer   172.12.0.1     xxx.xxx.xxx.xxx   80:30080/TCP,443:30443/TCP    30S
    3. Check the NGINX Ingress controller pod status in the edge node pool:

      kubectl get po -n ingress-edge -o wide

      Expected output:

      NAME                                                    READY   STATUS    RESTARTS   AGE   IP           NODE          NOMINATED NODE   READINESS GATES
      ack-ingress-nginx-v1-edge-controller-7d57b84c88-4wsm4   1/1     Running   0          17s   10.10.0.1    edge-node-1   <none>           <none>
      ack-ingress-nginx-v1-edge-controller-7d57b84c88-fqvj8   1/1     Running   0          17s   10.10.1.1    edge-node-2   <none>           <none>
    4. Check the NGINX Ingress controller Service status in the edge node pool:

      kubectl get svc -n ingress-edge

      Expected output:

      NAME                                   TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)                      AGE
      ack-ingress-nginx-v1-edge-controller   NodePort   172.12.0.2      <none>        80:32080/TCP,443:32443/TCP   3m51s
  2. Create a file named cube.yaml with the following content.

    apiVersion: v1
    kind: Service
    metadata:
      name: cube-svc
      annotations:
        openyurt.io/topologyKeys: openyurt.io/nodepool
    spec:
      type: ClusterIP
      selector:
        app: cube
      ports:
        - port: 80
          targetPort: 80
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: cube
      labels:
        app: cube
    spec:
      replicas: 4
      selector:
        matchLabels:
          app: cube
      template:
        metadata:
          labels:
            app: cube
        spec:
          containers:
          - name: cube-web
            image: registry.cn-hangzhou.aliyuncs.com/acr-toolkit/ack-cube:1.0
            ports:
            - containerPort: 80
  3. Create the cube test application and its Service:

    kubectl apply -f cube.yaml

    Verify that pods are deployed to both the cloud and edge node pools:

    kubectl get pod  -o wide

    Expected output:

    NAME                    READY   STATUS    RESTARTS   AGE   IP            NODE           
    cube-757558c974-9zfkn   1/1     Running   0          11m   10.10.0.1     cloud-node-1   
    cube-757558c974-cw72m   1/1     Running   0          11m   10.10.0.2     cloud-node-2   
    cube-757558c974-fbvlf   1/1     Running   0          11m   10.10.1.1     edge-node-1    
    cube-757558c974-ngwxt   1/1     Running   0          11m   10.10.1.2     edge-node-2    
  4. Create a file named ingress.yaml with the following content to define Ingresses for the cloud and edge controllers.

    apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
      name: cube-ingress-cloud
      namespace: default
    spec:
      ingressClassName: ack-nginx-cloud               # Create an Ingress for the cloud Ingress controller.
      rules:
      - host: example.cube.com
        http:
          paths:
          - path: /
            backend:
              service:
                name: cube-svc
                port:
                  number: 80
            pathType: ImplementationSpecific
    
    ---
    apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
      name: cube-ingress-edge
      namespace: default
    spec:
      ingressClassName: ack-nginx-edge                 # Create an Ingress for the edge Ingress controller.
      rules:
      - host: example.cube.com
        http:
          paths:
          - path: /
            backend:
              service:
                name: cube-svc
                port:
                  number: 80
            pathType: ImplementationSpecific

    Create the Ingress resources:

    kubectl apply -f ingress.yaml
  5. View the Ingress resources:

    kubectl get ingress

    Expected output:

    NAME                 CLASS             HOSTS              ADDRESS           PORTS   AGE
    cube-ingress-cloud   ack-nginx-cloud   example.cube.com   139.224.xxx.xxx   80      24m
    cube-ingress-edge    ack-nginx-edge    example.cube.com   172.20.xxx.xxx    80      24m
    • A LoadBalancer Service exposes the NGINX Ingress controller in the cloud node pool. The Ingress ADDRESS field is populated with the load balancer address. Use this address to access the Service.

    • A NodePort Service exposes the NGINX Ingress controller in the edge node pool. The Ingress ADDRESS field shows the Service ClusterIP. Access the Service using a node IP address and the NodePort.

References

ACK Edge clusters extend ACK managed Pro clusters with edge node pools for edge nodes and on-premises IDC machines. extends ACK managed Pro cluster with edge node pools. NGINX Ingress in an ACK Edge cluster also supports these capabilities:

Actions

Documentation

ACK Edge differences

Create an NGINX Ingress

Create and use NGINX Ingress to expose Services

Configure the traffic topology for your scenario.

Deploy the NGINX Ingress controller

Deploy the NGINX Ingress controller

Deploy from the Marketplace only.

Upgrade the NGINX Ingress controller

Upgrade ack-ingress-nginx from the Marketplace

Upgrade from the Marketplace only.

Deploy the NGINX Ingress controller for high-load applications

Configure an NGINX Ingress controller for high-load scenarios

None.

Configure public and private network types for an Ingress controller CLB

Configure the network type of an NGINX Ingress controller

Available only for cloud node pool Ingress controllers.

Implement canary releases and blue-green deployments with NGINX Ingress

Implement canary releases and blue-green deployments using NGINX Ingress

None.

Mirror application traffic with an Ingress controller

Mirror application traffic using NGINX Ingress

None.

Enable tracing for the NGINX Ingress controller

Enable tracing for an NGINX Ingress controller component

None.

Deploy and view NGINX Ingress access logs

Collect and analyze NGINX Ingress access logs

Enable from the command line only.

Access gRPC Services with an Ingress controller

Configure gRPC for NGINX Ingress

None.