Use NGINX Ingress

更新时间:
复制 MD 格式

NGINX Ingress is a network traffic management solution for Kubernetes clusters that routes external traffic to in-cluster Services using Ingress API objects. The NGINX Ingress controller component is deployed inside the cluster and provides high performance and customization.ACK Edge cluster integrates the community version with Alibaba Cloud product features to provide a streamlined user experience. This topic describes how to use NGINX Ingress in an 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. For more information, see [Product Announcement] Announcement on discontinuation of maintenance for the NGINX Ingress controller component.

Steps

  1. Deploy the NGINX Ingress controller in the cloud node pool and the edge node pool. For more information, see Deploy the NGINX Ingress controller. After deployment, check the status of the NGINX Ingress controller and its Service exposure.

    1. Run the following command to check the status of the NGINX Ingress controller pods 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. Run the following command to check the status of the NGINX Ingress controller Service 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. Run the following command to check the status of the NGINX Ingress controller pods 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. Run the following command to check the status of the NGINX Ingress controller Service 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. Run the following command to create the cube test application and its Service.

    kubectl apply -f cube.yaml

    Run the following command to verify that the pods are deployed to both the cloud node pool and the edge node pool.

    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 create Ingresses for the cloud and edge Ingress 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

    Run the following command to create the Ingress resources.

    kubectl apply -f ingress.yaml
  5. Run the following command to 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 type Service exposes the NGINX Ingress controller in the cloud node pool. The system automatically populates the ADDRESS field of the Ingress with the load balancer address. Use this load balancer address to access the Service.

    • A NodePort type Service exposes the NGINX Ingress controller in the edge node pool. The system populates the ADDRESS field of the Ingress with the ClusterIP address of the Service. You can access the Service using a node's IP address and the NodePort.

Related documents

ACK Edge cluster extends the capabilities of an ACK managed Pro cluster by adding an edge node pool to connect edge nodes and IDC machines. Therefore, when you use NGINX Ingress in an ACK Edge cluster, it also supports the following capabilities:

Actions

Documentation

ACK Edge differences

How to create an NGINX Ingress

Create and use NGINX Ingress to expose Services

You must configure the traffic topology based on your scenario.

How to deploy the NGINX Ingress controller component

Deploy the NGINX Ingress controller

You can deploy this component only from the Marketplace.

How to upgrade the NGINX Ingress controller component

Upgrade ack-ingress-nginx from the Marketplace

You can upgrade this component only from the Marketplace.

How to deploy the NGINX Ingress controller to support high-load applications

Configure an NGINX Ingress controller for high-load scenarios

None.

How to configure the public and private network types for an Ingress controller CLB

Configure the network type of an NGINX Ingress controller

This feature is available only for Ingress controllers in a cloud node pool.

How to implement canary releases and blue-green deployments using NGINX Ingress

Implement canary releases and blue-green deployments using NGINX Ingress

None.

How to mirror application traffic using an Ingress controller

Mirror application traffic using NGINX Ingress

None.

How to enable tracing for the NGINX Ingress controller component

Enable tracing for an NGINX Ingress controller component

None.

How to deploy and view NGINX Ingress access logs

Collect and analyze NGINX Ingress access logs

This feature can be enabled only from the command line.

How to access gRPC Services using an Ingress controller

Configure gRPC for NGINX Ingress

None.