All Products
Search
Document Center

Container Service for Kubernetes:How to use the NGINX Ingress

Last Updated:Aug 07, 2024

The NGINX Ingress is a network traffic management solution for Container Service for Kubernetes (ACK) clusters that routes external traffic to Services in a Kubernetes cluster through Ingress API objects. The NGINX Ingress controller is deployed within the cluster, offering high performance and customization. The NGINX Ingress controller provided by ACK Edge clusters integrates features of the open source version and Alibaba Cloud services, providing a simplified user experience. This topic describes how to use the NGINX Ingress in ACK Edge clusters.

Procedure

  1. Deploy the NGINX Ingress controller in both the cloud node pool and the edge node pool. For more information, see Install the NGINX Ingress controller. You can check the status of the NGINX Ingress controller and the service exposure after the deployment.

    1. Run the following command to view the status of the NGINX Ingress controller pod 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 view 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 view the status of the NGINX Ingress controller pod 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 view 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 and copy the following content to the file:

    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 test application cube and Service:

    kubectl apply -f cube.yaml

    Run the following command to check whether the application pod is deployed in 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 and copy the following content to the file to create Ingresses for both the cloud Ingress controller and the edge Ingress controller.

    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 query 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
    • The Ingress controller in the cloud node pool uses LoadBalancer Services to provide Internet-facing services. The IP address of the load balancer is automatically filled in the address field of the Ingress. You can use this IP address to access the Service.

    • The Ingress controller in the edge node pool uses NodePort Services to provide Internet-facing services. The IP address of the ClusterIP type Service is filled in the address field of the Ingress. You can use the IP address of the node and the node port to access the Service.

References

ACK Edge clusters extend the functionality of edge node pools based on ACK Pro clusters to connect edge nodes and the data center. Therefore, NGINX Ingresses on ACK Edge clusters support the following feature:

Operation

Reference

ACK edge differences

How to create an NGINX Ingress?

Create an NGINX Ingress

Configure traffic topology based on the actual scenario.

How to deploy the NGINX Ingress controller?

Install the NGINX Ingress controller

Only supports deployment through the application marketplace.

How to update the NGINX Ingress controller?

Update ack-ingress-nginx to ack-ingress-nginx-v1 from the Marketplace page in the ACK console

Only supports upgrades through the application marketplace.

How to deploy the NGINX Ingress controller for high-load applications?

Install the NGINX Ingress controller in high-load scenarios

None.

How to configure the Ingress controller to use Internet-facing and internal-facing CLB instances?

Configure an Internet-facing or internal-facing NGINX Ingress controller

Only supports Ingress Controller deployed in the cloud node pool.

How to implement canary releases and blue-green deployments through the NGINX Ingress?

Use the NGINX Ingress controller to implement canary releases and blue-green deployments

None.

How to mirror network traffic through the Ingress controller?

Use an Ingress controller to mirror network traffic

None.

How to use tracing analysis on the NGINX Ingress controller?

Perform tracing analysis on the NGINX Ingress controller

None.

How to deploy and view NGINX Ingress access logs?

Analyze and monitor the access log of nginx-ingress-controller

Only supports command line enabling.

How to access gRPC Services through the Ingress controller?

Use an Ingress controller to access gRPC services

None.