All Products
Search
Document Center

Container Service for Kubernetes:Quickly deploy a Knative application

Last Updated:Jul 08, 2025

In scenarios such as Web application hosting, serverless application deployment, AI tasks, and event-driven applications, we recommend that you deploy workloads as Knative Services. This approach allows you to allocate resources based on demands and focus more on developing business logic. You can also benefit from Knative features, such as request-based auto scaling and simplified version management. By using these feature, Knative can automatically reduce the number of pods to zero when no requests are received from applications, and can automatically scale out pods when requests are received.

Prerequisites

Knative is deployed in your cluster. For more information, see Deploy and manage Knative.

Step 1: Deploy a Knative Service

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

  2. On the Clusters page, find the cluster you want and click its name. In the left-side navigation pane, choose Applications > Knative.

  3. Click the Services tab. Select the namespace to which the Service belongs in the top navigation bar on the Services tab. Then, deploy a Knative Service.

    You can deploy a Knative Service by using the wizard or the YAML editor.

    Use the console

    On the Services tab, click Create Service, and finish the configuration as prompted.

    Parameter

    Description

    Service Name

    Enter a name for the Service.

    Image Name

    Click Select Image. In the dialog box that appears, select your target image.

    You can also enter private images and tags in the format domainname/namespace/imagename:tag.

    Alternatively, follow on-screen prompts to directly use ACK-provided demo images. In this example, registry-vpc.cn-hangzhou.aliyuncs.com/knative-sample/helloworld-go:73fbdd56 is used (Replace cn-hangzhou with your actual region).

    Access Protocol

    HTTP and gRPC are supported.

    Container Port

    The container port that you want to expose. The port number must be in the range of 1 to 65535.

    Advanced

    Click Advanced to configure the advanced settings.

    View advanced settings

    • Internal Access Only: If you select Internal Access Only, the Knative Service cannot be accessed over the Internet.

    • Maximum Concurrent Requests: the maximum number of concurrent requests allowed by the container. The default value is 0. This indicates that the number of concurrent requests is unlimited.

    • Minimum Pods: the minimum number of running pods that must be guaranteed when no request is received. If you set this parameter to 0, the number of running pods is reduced to zero when no request is received.

    • Maximum Pods: the maximum number of pods that are allowed.

    • Resource Limit: the upper limit of resources that can be used by the application, including CPU, memory, and GPU resources. This prevents the application from occupying excessive amounts of resources. CPU usage is measured in cores. Memory usage is measured in bytes or mebibytes.

    • Lifecycle: Specify Command and Parameter.

      • If Command and Parameter are not set, the default values of Command and Parameter in the image configurations are used.

      • If you set only Parameter, the default value of Command in the image configurations and the specified value of Parameter are used.

      • If you set both Command and Parameter, the default values of Command and Parameter in the image configurations are overwritten by the specified values.

    • Environment Variables: environment variables in the format of key-value pairs.

    • Volume: Add local storage and persistent volume claims (PVCs).

      • Add Local Storage: You can select HostPath, ConfigMap, Secret, or EmptyDir. The specified volume is mounted to a path in the container. For more information, see Volumes.

      • Add PVC: Select Cloud Storage.

    Use the YAML editor

    1. In the upper-right part of the Services tab, click Create from YAML.

    2. Enter the YAML content of the Service into the YAML editor and click Create.

      For example, copy the following YAML content to the editor to create a Service named helloworld-go.

      apiVersion: serving.knative.dev/v1
      kind: Service
      metadata:
        name: helloworld-go
      spec:
        template:
          spec:
            containers:
            - image: registry-vpc.cn-hangzhou.aliyuncs.com/knative-sample/helloworld-go:73fbdd56  # Replace the region with your actual one.
              env:
              - name: TARGET
                value: "Knative"

    After the Service is created, you can view, modify, or delete the Service on the Services tab.

Step 2: Access the Knative Service

After the Knative Service is deployed, you can point its domain name to the IP address of a gateway to associate the Service with the gateway. This allows you to access the Knative Service by using its domain name. To do this, perform the following operations:

  1. On the Services tab, click the name of the Service.

    In the Basic Information section, you can view information about the gateway and domain name.新服务

  2. Add the following information to the hosts file to point the domain name of the Service to the IP address of the gateway.

    Example:

    121.xx.xxx.xx helloworld-go.default.example.com
  3. After you modify the hosts file, you can use the domain name to access the Knative Service.访问服务

References