Cloud Native 19 min read

Deploy Knative on Alibaba Cloud and Test Serverless Scaling with Hello World

This guide walks you through creating a Kubernetes cluster on Alibaba Cloud, installing Istio and Knative components, deploying a Go Hello World service, and using scripts and load‑testing tools to observe Knative’s zero‑scale‑to‑one and automatic scaling behavior.

Alibaba Cloud Native
Alibaba Cloud Native
Alibaba Cloud Native
Deploy Knative on Alibaba Cloud and Test Serverless Scaling with Hello World

Overview

This guide demonstrates how to provision a Knative environment on Alibaba Cloud Container Service, deploy a simple Go Hello World service, and verify Knative’s zero‑scale‑to‑one and automatic scaling behavior using kubectl, curl, and the load‑testing tool hey.

Prerequisites

A Kubernetes cluster created in Alibaba Cloud Container Service (managed clusters are recommended). kubectl configured to access the cluster.

Install Istio

Deploy the ack‑istio‑ingressgateway component from the Alibaba Cloud console application catalog. After a few seconds the Istio control plane is ready.

Retrieve the external IP of the Istio IngressGateway:

# kubectl get svc istio-ingressgateway \
    --namespace istio-system \
    --output jsonpath="{.status.loadBalancer.ingress[*].ip}"
39.97.31.219

Deploy Knative CRDs

From the console application catalog select ack‑knative‑init and click Create to install the Knative Custom Resource Definitions.

Deploy Knative Serving

Install ack‑knative‑serving from the catalog. The default parameters configure the component to use the Istio IngressGateway.

Hello World Go Example

Create a Knative Service manifest ( helloworld-go.yaml) that references a pre‑built image:

apiVersion: serving.knative.dev/v1alpha1
kind: Service
metadata:
  name: helloworld-go
  namespace: default
spec:
  template:
    metadata:
      labels:
        app: helloworld-go
      annotations:
        autoscaling.knative.dev/target: "10"
    spec:
      containers:
        - image: registry.cn-hangzhou.aliyuncs.com/knative-sample/simple-app:07
          env:
            - name: SIMPLE_MSG
              value: "helloworld-go-07"

Deploy the service:

# kubectl apply -f helloworld-go.yaml
service.serving.knative.dev/helloworld-go created

Verify that a pod is created:

# kubectl get pod
NAME                                            READY   STATUS    RESTARTS   AGE
helloworld-go-lq6ns-deployment-869cbcc75d-qrln7   2/2     Running   0          6s

Obtain the service domain name:

# kubectl get route helloworld-go \
    --output jsonpath="{.status.domain}"
helloworld-go.default.example.com

Send a request (replace the IP with the one obtained above):

# curl -H "Host: helloworld-go.default.example.com" "http://39.97.31.219"
helloworld-go-07-v3

Testing Scaling with a Helper Script

A convenience script run-test.sh automates the IP and domain lookup and performs a curl request. Sample output shows a total request time of ~2.8 s, confirming that Knative scaled the pod from zero to one.

#!/bin/bash
SVC_NAME="helloworld-go"
export INGRESSGATEWAY=istio-ingressgateway
export IP_ADDRESS=$(kubectl get svc $INGRESSGATEWAY \
    --namespace istio-system \
    --output jsonpath="{.status.loadBalancer.ingress[*]['ip']}")
echo "IP_ADDRESS: $IP_ADDRESS"
export DOMAIN_NAME=$(kubectl get route $SVC_NAME \
    --output jsonpath="{.status.domain}")
# curl request and timing
time curl -H "Host: $DOMAIN_NAME" "http://$IP_ADDRESS" -v

Autoscale Go Example

Deploy a service that sleeps for a configurable time to illustrate scaling under load:

apiVersion: serving.knative.dev/v1alpha1
kind: Service
metadata:
  name: autoscale-go
  namespace: default
spec:
  template:
    metadata:
      labels:
        app: autoscale-go
      annotations:
        autoscaling.knative.dev/target: "10"
    spec:
      containers:
        - image: registry.cn-hangzhou.aliyuncs.com/knative-sample/autoscale-go:0.1
# kubectl apply -f autoscale-go.yaml
service.serving.knative.dev/autoscale-go created

Run the same run-test.sh script (set SVC_NAME=autoscale-go) and then stress the service with hey:

# hey -z 30s -c 50 "http://autoscale-go.default.example.com?sleep=100&prime=10000&bloat=5" && kubectl get pods
NAME                                            READY   STATUS    RESTARTS   AGE
autoscale-go-zqcm2-deployment-6cf67b4545-2f2ck   2/2     Running   0          28s
... (four more pods) ...

The test demonstrates that Knative creates the expected number of pods (target 10 concurrent requests per pod, 50 requests total → 5 pods) when request latency is high.

Key Takeaways

Alibaba Cloud Container Service provides a one‑click method to provision a Kubernetes cluster and install Istio and Knative.

Knative can serve a simple Go Hello World application and scale the pod count from zero to one on the first request.

The annotation autoscaling.knative.dev/target controls the desired concurrency per pod; Knative scales out only when needed.

Load‑testing tools such as hey reveal the relationship between request latency, concurrency, and pod scaling.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

ServerlessKubernetesAlibaba CloudscalingKnativeHello World
Alibaba Cloud Native
Written by

Alibaba Cloud Native

We publish cloud-native tech news, curate in-depth content, host regular events and live streams, and share Alibaba product and user case studies. Join us to explore and share the cloud-native insights you need.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.