All Products
Search
Document Center

Container Service for Kubernetes:Deploy a web application using NGINX

Last Updated:Nov 24, 2025

You do not need to create or manage nodes in an ACK Serverless cluster. This frees you from operations and maintenance (O&M) tasks, such as node security maintenance, and lets you focus on applications instead of the underlying infrastructure. This topic describes how to use an ACK Serverless cluster to quickly deploy an online web application that is based on the official NGINX image.

Important

The resources that you create incur about USD 0.05 for 30 minutes. After you complete the steps in this topic, you can release the resources that you created.

Prerequisites

Step 1: Deploy an NGINX application

Deploy using the console

Step 1: Create an NGINX application and expose the application using a Service

  1. Log on to the ACK console. In the left navigation pane, click Clusters.

  2. On the Clusters page, find the cluster you want to manage and click its name. In the left navigation pane, choose Workloads > Deployments.

  3. On the Deployments page, click Create from Image in the upper-right corner.

  4. On the Basic Information page, set the parameters and click Next.

    Use the default values for other parameters.

    Parameter

    Example

    Application Name

    nginx-deploy

    Replicas

    1

  5. On the Container page, set the parameters and click Next.

    Use the default values for other parameters.

    Parameter

    Example

    Image Name

    anolis-registry.cn-zhangjiakou.cr.aliyuncs.com/openanolis/nginx:1.14.1-8.6

    Required Resources

    • CPU: 1 Core

    • Memory: 2 GB

    Port

    • Name: example-port

    • Container Port: 80

    • Protocol: TCP

  6. On the Advanced page, click Create next to Service. In the panel that appears, set the parameters and click OK.

    Use the default values for other parameters.

    Parameter

    Example

    Name

    nginx-deploy-svc-test

    Service Type

    SLB

    • SLB Type: NLB

    • Select Resource: Create Resource

    Port Mapping

    • Name: example-map

    • Service Port: 80

    • Container Port: 80

    • Protocol: TCP

  7. Click Create, and then click View Details.

  8. On the details page of the Deployment, click the Pods tab and wait until the status of the pod changes to Running. Then, click the Access Method tab and copy the public IP address or URL from the External Endpoint field.

Use kubectl

Note

You can use kubectl on your on-premises machine or in Cloud Shell to perform the following operations. If you use kubectl in Cloud Shell, you do not need to configure the config file.

Step 1: Create an NGINX application and expose the application using a Service

  1. Connect to the ACK Serverless cluster using kubectl. For more information, see Connect to a Kubernetes cluster using kubectl.

  2. Create an nginx.yaml file with the following code block:

    apiVersion: v1
    kind: Service
    metadata:
      name: nginx-deploy-svc
    spec:
      ports:
      - port: 80
        protocol: TCP
      selector:
        app: nginx
      type: LoadBalancer
    ---
    apiVersion: apps/v1  # Use the API version that corresponds to your Kubernetes version.
    kind: Deployment
    metadata:
      name: nginx-deploy
      labels:
        app: nginx
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: nginx
      template:
        metadata:
          labels:
            app: nginx
        spec:
          containers:
          - name: nginx
            image: anolis-registry.cn-zhangjiakou.cr.aliyuncs.com/openanolis/nginx:1.14.1-8.6
            ports:
            - containerPort: 80
            resources:
              requests:
                cpu: "1"
                memory: "2Gi"
  3. Run the following command to deploy an application using the nginx.yaml file in the cluster:

    kubectl apply -f nginx.yaml

    Expected output:

    service/nginx-service created
    deployment.apps/nginx-deploy created
  4. Run the following command to view the details of the application:

    kubectl get deploy

    Expected output:

    NAME           READY   UP-TO-DATE   AVAILABLE   AGE
    nginx-deploy   1/1     1            1           9m32s
  5. Run the following command to view the details of the Service and record the public IP address (EXTERNAL-IP) of the nginx-service Service:

    kubectl get svc

    Expected output:

    NAME            TYPE           CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE
    kubernetes      ClusterIP      172.XX.X.X     <none>        443/TCP        10d
    nginx-service   LoadBalancer   172.19.X.XXX   47.57.XX.XX   80:32278/TCP   39s

Step 2: Test access to the NGINX application

In a browser, enter the public IP address or URL of the Service and press Enter.

If the NGINX welcome page appears as shown in the following figure, the application and Service are working as expected.

nginx

What to do next

Configure auto scaling policies for the application. For more information, see Configure auto scaling policies for a cluster.

If you do not want to configure auto scaling, you can perform the following steps to release the resources that you created:

Delete the created application and service

  1. On the Clusters page of the Container Service for Kubernetes (ACK) console, click the name of the target cluster.

  2. In the navigation pane on the left, choose Workloads > Deployments. Select the NGINX application that you created, click Batch Delete, and then follow the on-screen instructions to confirm the deletion.

Delete a cluster

ACK Serverless clusters are in public preview and offer a free trial. However, you must pay for other Alibaba Cloud services used by your ACK Serverless clusters based on the billing rules of the services. Fees are charged by these Alibaba Cloud services separately. After you complete the configuration, you can manage the cluster in one of the following ways:

  • If you no longer need the cluster, log on to the ACK console. On the Clusters page, choose More > Delete in the Actions column of the cluster to delete the cluster. In the Delete Cluster dialog box, select Delete ALB Instances Created by the Cluster, Delete Alibaba Cloud DNS PrivateZone instances Created by the Cluster, and I understand the above information and want to delete the specified cluster, and then click OK. For more information about how to delete an ACK Serverless cluster, see Delete an ACK Serverless cluster.

  • If you want to continue to use the cluster, recharge your Alibaba Cloud account at least 1 hour before the trial period ends and ensure that your account has a balance of at least CNY 100. For more information about the billing of Alibaba Cloud services used by ACK Serverless Pro clusters, see Cloud service fee.