By Xining Wang
Use ASM to Manage Knative Services (1): An Overview of Knative on ASM
Use ASM to Manage Knative Services (2): Use Knative on ASM to Deploy Serverless Applications
Use ASM to Manage Knative Services (3): Use Custom Domain in Knative on ASM
Use ASM to Manage Knative Services (4): Use ASM Gateway to Access Knative Services over HTTPS
Use ASM to Manage Knative Services (6): Auto Scaling Based on the Number of Traffic Requests
Deploy Knative Serving components:
ASM Gateway provides Knative with Knative Revisions traffic distribution and supports functions, including gRPC services, timeout and retry, TLS certificates, and external authentication and authorization. Please visit this link for more information.
Log on to the ASM console. On the left-side navigation pane, choose Service Mesh > Mesh Management. On the Mesh Management page, click the name of the instance you want to manage. Then, on the left-side navigation pane, choose Ecological Integration > Knative on ASM. On the page that appears on the right, click Enable. It can be opened later after the update is completed.
You can use the Container Service management console or YAML configuration file to deploy Knative services. You can choose whichever is right for you.
Parameter | Description |
Namespace | Select the namespace to which the Service belongs |
Service Name | Enter a name for the Service |
ImageName | Click Select Image to select an 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. In this example, registry.cn-hangzhou.aliyuncs.com/knative-sample/helloworld-go is used. |
Image Version | Click Select Image Version to select an image version. In this example, the image version is 73fbdd56. |
Access Protocol | HTTP and gRPC are supported. |
Container Port | Set the container port 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 Number of 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. |
Minimum Number of Instances to be Scaled in | Set the minimum number of instances that must be kept running when no request is received. If you set this parameter to 0, it means the number of running instances is reduced to zero when no request is received. |
Maximum Number of Instances to be Scaled out | Set the maximum number of instances that are allowed to be scaled out |
Limits on Resources | Set the maximum amount of CPU, memory, and GPU 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 mebibytes. |
Lifecycle Management | The lifecycle contains Command and Args and the configuration instructions are listed below: If you do not configure the Command and Args, the default command and Args of the image are used. If you only configure Args, the default command of the image and the newly configured Args are used. If you configure both of them, the default image configurations will be overwritten by the new ones. |
Environment Variables | Set environment variables in key-value pairs |
Volumes | You can mount local storage volumes and persistent volume claims (PVCs) to the container. Local Storage: You can select HostPath, ConfigMap, Secret, or EmptyDir. The specified volume is mounted to a path in the container. Please see Volumes for more information. PVC: Support Cloud Storage. |
Note: After the Service is created, you can view, modify, or delete the Service on the Services tab.
1. Save the following content as hello.yaml:
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: helloworld-go
annotations:
knative.k8s.alibabacloud/tls: "false"
spec:
template:
spec:
containers:
- image: registry.cn-hangzhou.aliyuncs.com/acs/helloworld-go:160e4dc8
ports:
- containerPort: 8080
env:
- name: TARGET
value: "Knative"
2. Use kubectl to connect to the cluster and run the following command to create a Knative Service:
kubectl apply -f hello.yaml
3. Wait for a while and execute the following command to view the list of Knative services:
kubectl get ksvc
Expected output:
NAME URL LATESTCREATED LATESTREADY READY REASON
helloworld-go http://helloworld-go.default.example.com helloworld-go-00001 helloworld-go-00001 True
After the Knative service is created, you can access the service address by binding the Host domain name with the access gateway. Perform the following steps to access the service address:
1. On the Services tab, click the Service Name or click Details in the Action Bar to go to the Knative service details page. In the Basic Information section, you can view information about the access gateway and domain name.
2. Add the following information to the host file to point the domain name of the Service to the IP address of the gateway. The binding sample is listed below (replace xx.xx.xxx.xx with your gateway IP):
xx.xx.xxx.xx helloworld-go.default.example.com
3. After Host is bound, you can use the domain name to access the Knative Service:
curl http://helloworld-go.default.example.com
Hello Knative!
Use ASM to Manage Knative Services (1): An Overview of Knative on ASM
Use ASM to Manage Knative Services (3): Use Custom Domain in Knative on ASM
56 posts | 8 followers
FollowXi Ning Wang(王夕宁) - August 7, 2023
Xi Ning Wang(王夕宁) - August 7, 2023
Xi Ning Wang(王夕宁) - August 7, 2023
Xi Ning Wang(王夕宁) - August 7, 2023
Xi Ning Wang(王夕宁) - August 7, 2023
Alibaba Container Service - August 30, 2024
56 posts | 8 followers
FollowAlibaba Cloud Service Mesh (ASM) is a fully managed service mesh platform that is compatible with Istio.
Learn MoreAlibaba Cloud Function Compute is a fully-managed event-driven compute service. It allows you to focus on writing and uploading code without the need to manage infrastructure such as servers.
Learn MoreAlibaba Cloud Container Service for Kubernetes is a fully managed cloud container management service that supports native Kubernetes and integrates with other Alibaba Cloud products.
Learn MoreA convenient and secure cloud-based Desktop-as-a-Service (DaaS) solution
Learn MoreMore Posts by Xi Ning Wang(王夕宁)