By Yuanyi
Alibaba Cloud Serverless Kubernetes (ASK) is a serverless Kubernetes container service. The underlying layer is based on Elastic Container Instance (ECI) and allows you to create secure and isolated container applications without purchasing ECS nodes. ASK has passed the conformance test of Kubernetes, providing a fully compatible community-based Kubernetes experience.
Knative is an open-source serverless application orchestration framework based on Kubernetes. Its goal is to formulate cloud-native and cross-platform serverless application orchestration standards. Based on ASK, Alibaba Cloud Knative is fully compatible with the community Knaitve. It orchestrates Function Compute (FC) and ECI workloads, supports event-driven and automatic elasticity, and provides a unified serverless application programming model.
Next, we will introduce the architecture through a barrage service demo. The demo includes HomePage, event-driven, and message processing.
HomePage is mainly used to send and receive barrage. Event drivers are used to receive, filter, and forward events. Message processing is used to process barrage messages. HomePage and message processing are deployed to FC and ECI respectively through Knative Serving, and event drivers are deployed to ECI through Knative Eventing.
The main flow of the pop-up service demo is shown in the figure below. The user sends the pop-up message to HomePage through the frontend, and HomePage sends the pop-up message to Kafka. Then, the event driver receives the pop-up message and routes it to message processing for processing. After the pop-up is processed, the pop-up result is sent to the Tablestore, and the frontend obtains the pop-up result and displays it on the page.
Next, we begin to deploy the barrage service demo. The operations include the following:
Deploy message processing, deploy event-driven, deploy HomePage, and perform pop-up service access after deployment is completed.
This service is used to receive pop-up requests sent by the event driver and scale out the request automatically based on the number of requests. After the pop-up message is processed, the results are sent to the Tablestore. Before deployment, confirm there are no workloads to observe the results after deployment.
Then, use Knative to deploy message processing to ECI workloads. Here, we use the yaml method to deploy. The content of yaml is listed below:
Parameter Description:
Then, deploy the service:
apiVersion: sources.knative.dev/v1alpha1
kind: KafkaSource
metadata:
annotations:
k8s.aliyun.com/req-timeout: "60"
k8s.aliyun.com/retry-count: "5"
k8s.aliyun.com/retry-interval: "2"
name: barrage
namespace: default
spec:
bootstrapServers: 192.168.42.205:9092,192.168.42.204:9092,192.168.42.203:9092
consumerGroup: barrage-info-consumer
sink:
ref:
apiVersion: serving.knative.dev/v1
kind: Service
name: test-barrage-process
namespace: default
topics: barrage-info
Parameter Description:
Then, deploy the service:
The message above says the processing and event driver have been deployed. Let's verify it.
On the left-side navigation pane of the cluster management page, choose Workloads > Pods
In the container group, you can see that the message processing and Kafka event source instances are running.
Open the Services and Functions page and confirm there are no pop-up services and functions.
Open the Custom Domain Name page and confirm that no custom domain name is available:
Next, we use Knative to deploy HomePage to FC type workloads. Here, we use yaml to deploy. The content of yaml is listed below:
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: demo-barrage
annotations:
workload.serving.knative.aliyun.com/class: "fc"
spec:
template:
metadata:
annotations:
fc.revision.serving.knative.aliyun.com/code-space: "image"
fc.revision.serving.knative.aliyun.com/role-arm: "acs:ram::xxxx:role/knative-fc"
fc.revision.serving.knative.aliyun.com/domain: '{"domain":"barrage.demo.knative.top","path":"/*"}'
spec:
containers:
- image: registry.cn-shanghai.aliyuncs.com/knative-sample/barrage-main:forrester-yuanyi_4cd77c84-20210618214527
env:
- name: OTS_ENDPOINT
value: https://barrage.cn-hangzhou.ots.aliyuncs.com
- name: TABLE_NAME
value: barrage
- name: OTS_INSTANCENAME
value: barrage
- name: OTS_KEYID
value: xxx
- name: OTS_SECRET
value: xxx
- name: KAFKA_SERVER
value: "106.15.11.179:9093,47.100.131.71:9093,47.102.44.91:9093"
- name: KAFKA_USER
value: "alikafka_pre-cn-xxx"
- name: KAFKA_PWD
value: "xxx"
- name: KAFKA_TOPIC
value: "barrage-info"
- name: TRACING
value: "http://tracing-analysis-dc-sh.aliyuncs.com/adapt_g2it2kg78n@5cf06035aec2eb9_g2it2kg78n@53df7ad2afe8301/api/traces"
- name: TRACE_NAME1
value: "sender"
- name: TRACE_NAME2
value: "receiver"
- name: TRACE_NAME3
value: "result"
- name: PARENT_SPAN
value: "barrage-sender"
- name: SUB_SPAN1
value: "sender"
- name: SUB_SPAN2
value: "result"
Parameter Description:
Then, deploy the service:
After the deployment is complete, let's verify it in the Function Compute console:
Open the Services and Functions page, and you can see that HomePage has been deployed:
On the Custom Domain Name page, you can see that the domain name you have configured is created automatically:
All the services above have been deployed. Now, we can access the services through a custom domain name. http://barrage.demo.knative.top
Next, we will send the barrage. Here, we can customize the message, parallelism, and duration of the barrage to be sent. We use the default configuration to send it.
Set Message, Concurrency, and Duration, and click Send.
We can see that barrage messages are constantly on display.
On top of Serverless Kubernetes, Alibaba Cloud Knative provides a unified programming model for containers and functions, bringing you a unified Serverless application programming model. You are welcome to communicate together.
Serverless Containers and Automatic Scaling Based on Traffic Patterns
162 posts | 29 followers
FollowAlibaba Developer - September 22, 2020
Alibaba Developer - November 8, 2021
Alibaba Cloud Serverless - April 7, 2022
Alibaba Clouder - September 28, 2020
Alibaba Cloud Serverless - February 17, 2023
Aliware - July 27, 2020
162 posts | 29 followers
FollowAlibaba 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 MoreVisualization, O&M-free orchestration, and Coordination of Stateful Application Scenarios
Learn MoreServerless Application Engine (SAE) is the world's first application-oriented serverless PaaS, providing a cost-effective and highly efficient one-stop application hosting solution.
Learn MoreMore Posts by Alibaba Container Service