Getting Started with Knative on Alibaba Cloud Container Service Kubernetes

简介: Knative Serving builds on Kubernetes and Istio to support deploying and serving of serverless applications and functions.

Overview

Knative Serving builds on Kubernetes and Istio to support deploying and serving of serverless applications and functions. Serving is easy to get started with and scales to support advanced scenarios.
Let's introduce how to quickly install Knative Serving and scale automatically based on Alibaba Cloud Container Service Kubernetes

Installing Knative Serving

Prepare Kubernetes

Alibaba Cloud Container Service supports the Kubernetes 1.12.6 now, making it easy to create Kubernetes clusters through the Container Service Management Console, see Create a Kubernetes cluster.

Installing Istio

Knative depends on Istio for traffic routing and ingress. Currently, Alibaba Cloud Container Service Kubernetes has provided a quick one-click deployment to install and configure Istio, see the Deploy Istio.
Log on to the Container Service console. Under Kubernetes, click Clusters in the left-side navigation pane. On the right of the target cluster, choose More > Deploy Istio.
image

You can view your deployment results in the following way:

  • In the left-side navigation pane, choose Application > Pods, select the cluster and namespace in which Istio is deployed, and you can see the relevant pods in which Istio is deployed.

image

Installing Istio Ingress gateway

In the left-side navigation pane, choose Store > App Catalog. Click the ack-istio-ingressgateway.
image

Click the Values tab, and then set the parameters. You can set customized parameters, including indicating whether to enable a specific port, or whether to use the intranet SLB or the Internet SLB by setting the serviceAnnotations parameter.
image

In the left-side navigation pane, choose Application > Pod. Select the target cluster and the istio-system namespace to view the pod to which the Istio Ingress gateway has been deployed.
image

Installing Knative CRD

Log on to the Container Service console. In the left-side navigation pane, choose Store > App Catalog. Click the ack-knative-init.
image

In the Deploy area on the right, select the target Cluster from the drop-down list, and then click DEPLOY.
image

Installing Knative Serving

Log on to the Container Service console. In the left-side navigation pane, choose Store > App Catalog. Click the ack-knative-serving.
image

Click the Values tab, then set the parameters. You can set customized values for parameters, or use the default value Istio IngressGateway. And then click DEPLOY.
image

Currently, the all four Helm charts for the Knative serving have been installed. Like this:
image

Getting Started with Knative

Deploy the autoscale sample

Deploy the sample Knative Service, run the following command:

kubectl create -f autoscale.yaml

Example of the autoscale.yaml:

apiVersion: serving.knative.dev/v1alpha1
kind: Service
metadata:
  name: autoscale-go
  namespace: default
spec:
  runLatest:
    configuration:
      revisionTemplate:
        metadata:
          annotations:
            # Target 10 in-flight-requests per pod.
            autoscaling.knative.dev/target: "10"
            autoscaling.knative.dev/class:  kpa.autoscaling.knative.dev
        spec:
          container:
            image: registry.cn-beijing.aliyuncs.com/wangxining/autoscale-go:0.1

Load the autoscale service

Obtain both the hostname and IP address of the istio-ingressgateway service in the istio-system namespace, and then export them into the IP_ADDRESS environment variable.

export IP_ADDRESS=`kubectl get svc istio-ingressgateway --namespace istio-system --output jsonpath="{.status.loadBalancer.ingress[*].ip}"`

Make a request to the autoscale app to see it consume some resources.

curl --header "Host: autoscale-go.default.{domain.name}" "http://${IP_ADDRESS?}?sleep=100&prime=10000&bloat=5"

Note, need to replace the {domain.name} to your domain. The domain name of the sample is aliyun.com.

curl --header "Host: autoscale-go.default.aliyun.com" "http://${IP_ADDRESS?}?sleep=100&prime=10000&bloat=5"
Allocated 5 Mb of memory.
The largest prime less than 10000 is 9973.
Slept for 100.16 milliseconds.

Installing the hey load generator:

go get -u github.com/rakyll/hey

Send 30 seconds of traffic maintaining 50 in-flight requests:

hey -z 30s -c 50 \
  -host "autoscale-go.default.aliyun.com" \
  "http://${IP_ADDRESS?}?sleep=100&prime=10000&bloat=5" \
  && kubectl get pods

With the traffic request running for 30 seconds, the Knative Serving scale automatically as the requests increasing.

Summary:
  Total:    30.1126 secs
  Slowest:    2.8528 secs
  Fastest:    0.1066 secs
  Average:    0.1216 secs
  Requests/sec:    410.3270

  Total data:    1235134 bytes
  Size/request:    99 bytes

Response time histogram:
  0.107 [1]    |
  0.381 [12305]    |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  0.656 [0]    |
  0.930 [0]    |
  1.205 [0]    |
  1.480 [0]    |
  1.754 [0]    |
  2.029 [0]    |
  2.304 [0]    |
  2.578 [27]    |
  2.853 [23]    |


Latency distribution:
  10% in 0.1089 secs
  25% in 0.1096 secs
  50% in 0.1107 secs
  75% in 0.1122 secs
  90% in 0.1148 secs
  95% in 0.1178 secs
  99% in 0.1318 secs

Details (average, fastest, slowest):
  DNS+dialup:    0.0001 secs, 0.1066 secs, 2.8528 secs
  DNS-lookup:    0.0000 secs, 0.0000 secs, 0.0000 secs
  req write:    0.0000 secs, 0.0000 secs, 0.0023 secs
  resp wait:    0.1214 secs, 0.1065 secs, 2.8356 secs
  resp read:    0.0001 secs, 0.0000 secs, 0.0012 secs

Status code distribution:
  [200]    12356 responses



NAME                                             READY   STATUS        RESTARTS   AGE
autoscale-go-00001-deployment-5fb497488b-2r76v   2/2     Running       0          29s
autoscale-go-00001-deployment-5fb497488b-6bshv   2/2     Running       0          2m
autoscale-go-00001-deployment-5fb497488b-fb2vb   2/2     Running       0          29s
autoscale-go-00001-deployment-5fb497488b-kbmmk   2/2     Running       0          29s
autoscale-go-00001-deployment-5fb497488b-l4j9q   1/2     Terminating   0          4m
autoscale-go-00001-deployment-5fb497488b-xfv8v   2/2     Running       0          29s

Conclusion

Based on the Alibaba Cloud Container Service Kubernetes, we can quickly install Knative Serving and scale automatically. Welcome to use the container service on Alibaba Cloud to install Knative and integrate it into your product.

相关实践学习
使用ACS算力快速搭建生成式会话应用
阿里云容器计算服务 ACS(Container Compute Service)以Kubernetes为使用界面,采用Serverless形态提供弹性的算力资源,使您轻松高效运行容器应用。本文将指导您如何通过ACS控制台及ACS集群证书在ACS集群中快速部署并公开一个容器化生成式AI会话应用,并监控应用的运行情况。
深入解析Docker容器化技术
Docker是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的Linux机器上,也可以实现虚拟化,容器是完全使用沙箱机制,相互之间不会有任何接口。Docker是世界领先的软件容器平台。开发人员利用Docker可以消除协作编码时“在我的机器上可正常工作”的问题。运维人员利用Docker可以在隔离容器中并行运行和管理应用,获得更好的计算密度。企业利用Docker可以构建敏捷的软件交付管道,以更快的速度、更高的安全性和可靠的信誉为Linux和Windows Server应用发布新功能。 在本套课程中,我们将全面的讲解Docker技术栈,从环境安装到容器、镜像操作以及生产环境如何部署开发的微服务应用。本课程由黑马程序员提供。     相关的阿里云产品:容器服务 ACK 容器服务 Kubernetes 版(简称 ACK)提供高性能可伸缩的容器应用管理能力,支持企业级容器化应用的全生命周期管理。整合阿里云虚拟化、存储、网络和安全能力,打造云端最佳容器化应用运行环境。 了解产品详情: https://www.aliyun.com/product/kubernetes
目录
相关文章
|
安全 编译器 Go
Go语言中的int和int32:同一个概念吗?
【2月更文挑战第24天】
1741 3
|
运维 监控 安全
云计算MSP行业调研报告
# 1. 概述 ## 1.1 背景和概念 企业上云是当前的大势所趋,但企业上云并非坦途。随着业务、数据等向云端迁移,企业在上云过程中会各种复杂的问题,比如平台选择、系统迁移、多云管理、应用优化以及成本核算和安全管理等问题。要解决这些问题,就需要专业的团队来指导,因此诞生了云MSP。 云MSP即云管理服务提供商(Cloud Management Service Provider),通常是指对接
5700 0
云计算MSP行业调研报告
|
5月前
|
人工智能 JavaScript Linux
OpenClaw从部署到上手实战指南:阿里云+本地部署、百炼API配置、首次任务实操全攻略
2026年,OpenClaw(Clawdbot)作为开源AI生产力工具的代表,凭借跨平台部署、灵活的任务执行能力,成为普通人提升效率、落地AI应用的核心工具。很多用户历经波折完成安装、解决报错、成功启动系统后,却会对着界面陷入迷茫——不知道下一步该做什么。其实问题的核心从不是“不会用”,而是“没有给工具一个明确的任务”。OpenClaw的价值从不是简单的问答,而是帮你完整完成一件事,而装好后的第一件事,从来不是啃文档、研究配置,而是立刻让它完成一个简单的小任务。
934 1
|
1月前
|
人工智能 安全 数据管理
Gartner:2026年数据与分析顶级趋势
Gartner发布的2026年数据与分析顶级趋势报告显示,AI智能体、语义层进步以及数据与分析平台的融合,将成为引领未来发展的三大核心趋势。对于希望识别关键业务和技术主题的数据与分析(D&A)领导者而言,这些领域是实现高性价比价值、更快成为AI FIRST企业的关键。
|
7月前
|
人工智能 算法 API
算法定义美妆科技:解析Perfect Corp.自研 AI 仿妆技术与实时 AR 渲染架构
Perfect Corp. AI仿妆技术基于自研AI,通过高精度人脸分析、语义分割与多维特征提取(色彩/位置/质地),实现结构化、可控制的妆容迁移。不依赖AIGC随机生成,保留用户五官与肤质特征,支持实时AR试妆及SDK/API快速集成,赋能美妆品牌“即看即试”营销闭环。(239字)
905 0
算法定义美妆科技:解析Perfect Corp.自研 AI 仿妆技术与实时 AR 渲染架构
|
监控 算法 API
用抖音电商 API 实现抖音小店商品标签精准打标
本文介绍如何利用抖音电商 API 实现商品标签精准打标,提升曝光与转化率。内容涵盖打标重要性、API 调用准备、标签自动化更新流程及最佳实践,助力商家高效运营,优化推荐效果。
|
JSON API 数据格式
手把手教你抓取京东商品评论:API 接口解析与 Python 实战
京东商品评论蕴含用户对产品质量、体验和服务的真实反馈,分析这些数据有助于企业优化产品和满足用户需求。由于京东未提供官方API,需通过逆向工程获取评论数据。其主要接口为“商品评论列表接口”,支持按商品ID、评分、排序方式等参数获取评论,返回JSON格式数据,包含评论列表、摘要(如好评率)及热门标签等信息。
1227 7
|
移动开发 小程序 API
uniapp中各种状态的按钮
uniapp中各种状态的按钮
955 0
|
传感器 安全 算法
在物联网项目中使用 MicroPython 时如何确保数据安全
在物联网项目中使用MicroPython时,确保数据安全至关重要。可通过加密通信、安全固件更新、认证机制和定期审计等方法提升安全性,防止数据泄露和设备被恶意操控。
|
人工智能 Kubernetes Cloud Native
阿里云2024 KCD雅加达之旅精彩回顾
2024年11月30日,KCD在印尼雅加达顺利举行。活动涵盖Kubernetes生态的主题演讲与实操,吸引众多开发者与技术达人参与。阿里云作为赞助商,与印尼科技生态链接,4位专家为350余名参会者带来了1场主论坛和3场分论坛的分享。

相关产品

  • 容器服务Kubernetes版