This topic describes how to create a Knative service.
Deploy a Knative service
- Log on to the ACK console.
- In the left-side navigation pane, choose .
- On the Knative Services page, click Create Service in the upper-right corner of the page.
- Configure the Knative service.
Parameter Description Cluster The cluster where the Knative service is deployed. Namespace The namespace to which the Knative service belongs. Service name The name of the Knative 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 domainname/namespace/imagename:tag format. 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.
HTTP and gRPC are supported.
The container port that you want to open. Enter a port number from 1 to 65535.
Internal Access Only
If you select the Internal Access Only check box, the Knative service cannot be accessed over the Internet.
Maximum Concurrent Requests
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.
The minimum number of pods that are kept running when no request is received. If you set the parameter to 0, the number of running pods is reduced to 0 when no access request is received.
The minimum number of pods that are kept running when no request is received.
The maximum amount of CPU and memory resources that can be allocated to the Knative service. This prevents the service from occupying too many resources. CPU usage is measured in cores. Memory usage is measured in bytes or MiB.
LifecycleIncludes the command and arguments. Note the following limits:
- If no command or argument is specified, the default command and arguments of the image are used.
- If you specify only arguments, the default command of the image and the specified arguments are used.
- If you specify both the command and arguments, the default configurations of the image are overwritten.
Set environment variables in key-value pairs.
- Click Create.
Access a Knative service
After the Knative service is created, map 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. Procedure:
- In the left-side navigation pane of the ACK console, choose
, and then click the target service.In the Basic Information section, you can view information about the access gateway and domain.
- Add the following information to the Hosts file on your local host to map the domain
name of the Knative service to the IP address of the gateway.
- After you modify the Hosts file, access the Knative service by using the domain name.