This topic describes how to use Knative to deploy a serverless application. In this topic, a Hello World application is used as an example.
- Log on to the ACK console.
- In the left-side navigation pane of the ACK console, click Clusters.
- 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 .
- In the upper-right corner of the Services tab, click Create Service.
- Set the Cluster, Namespace, and Service Name parameters. Then, select an image and an image version.
Parameter Description Service Name Enter a name for the Service. In this example, helloworld-go is used. Image Name To select an image, click Select Image. In the Select Image dialog box, select an image and click OK. You can also enter the address of a private image registry. The address must be in the domainname/namespace/imagename:tag format. In this example, registry.cn-hangzhou.aliyuncs.com/knative-sample/helloworld-go is used. Image Version To select an image version, click Select Image Version. If you do not set this parameter, the latest version is used. In this example, the image version is 73fbdd56. Environment Variables Set environment variables in key-value pairs. In this example,
TARGET=Knativeis added as an environment variable.
For more information about how to set other parameters, see Parameter descriptions.
- Click Create.
After the Service is created, it is displayed on the Services tab.
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 URL.
- In the left-side navigation pane of the ACK console, choose Knative Components page. On the Knative Components page, you can view the IP address of the gateway. to go to the
- Add the following information to the hosts file to point the domain name of the Service to the IP address of the gateway:
Gateway IP address + Service domain nameExample:
- After you modify the hosts file, enter http://helloworld-go.default.example.com in the address bar of the browser and press Enter to access the Service.