Knative Services are used to deploy applications. This topic describes how to create a Knative Service.
Step 1: Deploy a Knative Service
- Log on to the ACK console.
- On the Clusters page, find the cluster that you want to manage and click the name of the cluster, or click Details in the Actions column. The details page of the cluster appears.
- In the left-side navigation pane of the details page, choose .
- On the Services tab, click Create Service in the upper-right corner.
- Configure the Knative Service.
Parameter Description Cluster Select the cluster where you want to deploy the Service. Namespace Select the namespace to which the Service belongs. Service Name Enter a name for the Service. Image Name
To select an image, click Select Image. In the dialog box that appears, select an image and click OK. You can also enter the address of a private image registry. The registry address must be in the following format: domainname/namespace/imagename:tag. registry.cn-hangzhou.aliyuncs.com/knative-sample/helloworld-go is used in this example.
Click Select Image Version and select an image version. 73fbdd56 is selected in this example.
Both HTTP and gRPC are supported.
The container port that you want to expose. The port number must be in the range of 1 to 65535.
Internal Access Only
If you select Internal Access Only, the Knative Service cannot be accessed over the Internet.
Maximum Concurrent Requests
Set the maximum number of concurrent requests supported by the container. The default value is 0. This indicates that the number of concurrent requests is unlimited.
Set the minimum number of pods that must be kept running 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.
Set the maximum number of pods that are allowed to run.
Set the maximum amount of CPU and memory resources that can be allocated to the Knative Service. This prevents the Service from occupying an excessive amount of resources. CPU usage is measured in cores. Memory usage is measured in bytes or MiB.
LifecycleIncludes the Command and Parameter parameters. Take note of the following limits:
- If Command and Parameter are not set, the default values of Command and Parameter of the image are used.
- If you set only Parameter, the default value of Command of the image and the specified value of Parameter are used.
- If you set both Command and Parameter, the default values of Command and Parameter of the image are overwritten by the specified values.
Set environment variables in key-value pairs.
Volume You can mount local storage volumes and persistent volume claims (PVCs) to the container.
- Add Local Storage: You can select HostPath, ConfigMap, Secret, or EmptyDir. The volume is mounted to a path in the container. For more information, see Volumes.
- Add PVC: supports the cloud storage PVC type.
- Click Create.
Step 2: Access the Knative Service
After the Knative Service is created, point the domain name of the Knative Service to the IP address of the access gateway. Then, you can use the domain name to access the Knative Service. Perform the following steps:
- On the Services tab, click the name of the Service.In the Basic Information section, you can view information about the access gateway and domain name.
- Modify your hosts file to point the domain name of the Knative Service to the IP address
of the gateway. Example:
- After you modify the hosts file, use the domain name to access the Knative Service.