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
目录
相关文章
|
机器学习/深度学习 人工智能 物联网
智能家居技术的未来:从自动化到智能化的跨越
本文将探讨智能家居技术的发展趋势,从早期的自动化设备到现代的智能系统,分析其背后的技术驱动因素和市场动态。文章将详细讨论物联网(IoT)、人工智能(AI)、机器学习等技术如何推动智能家居的发展,并展望智能家居未来的发展方向。
|
移动开发 前端开发
基于若依的ruoyi-nbcio流程管理系统自定义业务撤回功能的修复
基于若依的ruoyi-nbcio流程管理系统自定义业务撤回功能的修复
309 0
|
供应链 数据可视化 开发者
微信小游戏矩阵化运营模型(试读)
微信小游戏矩阵化运营模型(试读)
662 1
|
缓存 监控 安全
基于Django的电商项目的设计与实现
基于Django的电商项目的设计与实现
1343 0
|
JavaScript 前端开发 Java
使用 SpringBoot+Vue 实现留言版
新建Vue项目和SpringBoot项目
512 0
使用 SpringBoot+Vue 实现留言版
|
移动开发 监控 前端开发
前端如何做好用户体验?
前端如何做好用户体验?
910 0
阿里云商标注册教程:新手自助申请详细步骤
阿里云商标注册图文教程快速上手笔记,本文以阿里云商标智能注册申请为例,商标智能注册申请需要用户手动填写商标类型、商标名称、商标图样、商标说明及商标分类表选择等操作,流程较为复杂,TM83商标网来详细说下阿里云商标注册快速上手笔记
1327 1
阿里云商标注册教程:新手自助申请详细步骤
|
存储 人工智能 API
10 分钟打造基于 ChatGPT 的 Markdown 智能文档
10 分钟打造基于 ChatGPT 的 Markdown 智能文档
589 0
|
存储 网络协议 Unix
408操作系统学习笔记——输入/输出(I/O)管理(上)
408操作系统学习笔记——输入/输出(I/O)管理
503 1
408操作系统学习笔记——输入/输出(I/O)管理(上)
|
数据可视化 数据处理 Python
数据处理不再烦恼,Python 轻松将数据写入 Excel的方法。
数据处理不再烦恼,Python 轻松将数据写入 Excel的方法。