Getting Started with Knative on Alibaba Cloud Container Service Kubernetes

本文涉及的产品
容器镜像服务 ACR,镜像仓库100个 不限时长
简介: 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.

相关实践学习
Docker镜像管理快速入门
本教程将介绍如何使用Docker构建镜像,并通过阿里云镜像服务分发到ECS服务器,运行该镜像。
容器应用与集群管理
欢迎来到《容器应用与集群管理》课程,本课程是“云原生容器Clouder认证“系列中的第二阶段。课程将向您介绍与容器集群相关的概念和技术,这些概念和技术可以帮助您了解阿里云容器服务ACK/ACK Serverless的使用。同时,本课程也会向您介绍可以采取的工具、方法和可操作步骤,以帮助您了解如何基于容器服务ACK Serverless构建和管理企业级应用。 学习完本课程后,您将能够: 掌握容器集群、容器编排的基本概念 掌握Kubernetes的基础概念及核心思想 掌握阿里云容器服务ACK/ACK Serverless概念及使用方法 基于容器服务ACK Serverless搭建和管理企业级网站应用
目录
相关文章
|
4月前
|
Kubernetes 调度 容器
ACK(Alibaba Cloud Kubernetes Engine
ACK(Alibaba Cloud Kubernetes Engine)是阿里巴巴云推出的一款基于Kubernetes的容器编排平台。在ACK中,Capacity Scheduling是一种调度策略,用于在集群中分配资源,以确保高可用性和资源利用率。
50 2
|
7月前
|
Kubernetes 容器
在Cloud Toolkit中,如果你无法选择Kubernetes的配置文件,
在Cloud Toolkit中,如果你无法选择Kubernetes的配置文件,
67 1
|
9月前
|
开发框架 缓存 Kubernetes
Dubbo、Spring Cloud和kubernetes该如何选型?
做技术选型。如果缺乏足够的经验,对so a啊,微服架构原理以及整个行业服务化演进的历史缺乏了解。
155 1
|
10月前
|
Kubernetes 负载均衡 安全
Spring Cloud Kubernetes使用全解(二)—官方原版
Spring Cloud Kubernetes使用全解(二)—官方原版
337 0
|
10月前
|
Kubernetes 负载均衡 Cloud Native
Spring Cloud Kubernetes使用全解(一)—官方原版
Spring Cloud Kubernetes使用全解(一)—官方原版
11543 2
|
存储 Kubernetes 数据可视化
Kubernetes + Spring Cloud 集成链路追踪 SkyWalking
分布式系统的应用程序性能监视工具,专为微服务、云原生架构和基于容器(Docker、K8s、Mesos)架构而设计。 提供分布式追踪、服务网格遥测分析、度量聚合和可视化一体化解决方案。
856 1
Kubernetes + Spring Cloud 集成链路追踪 SkyWalking
|
监控 Kubernetes 安全
Spring Cloud Kubernetes之实战网关Gateway
微服务Spring-cloud-kubernetes的网关设计
|
Kubernetes 前端开发 NoSQL
Spring Cloud Kubernetes之实战一配置管理
云原生基础下,微服务的配置化该如何管理,k8s来一套。
|
Kubernetes 负载均衡 监控
Spring Cloud 与 K8s 在微服务层面的不同
微服务Springcloud已经被广泛使用了,但作为云原生的技术基础K8s,存在着与Spring cloud 组件功能类似的组件,此时可以借助于容器化手段使用K8s来解决服务的注册与发现,属性配置动态化等。
|
Kubernetes 负载均衡 Cloud Native
Spring Cloud Kubernetes之实战服务注册与发现
本文主讲利用 k8s 来实现服务的注册与发现,甚至负载均衡,这在云原生时代又是一新型技术发展。

相关产品

  • 容器服务Kubernetes版