Cloud Native 9 min read

How to Deploy Production-Ready Knative Services on Alibaba Cloud Container Service

This guide walks you through deploying a Knative Service on Alibaba Cloud Container Service, configuring logging and monitoring with Log Service, setting up alerting, and enabling distributed tracing, providing step‑by‑step commands, YAML examples, and console screenshots for a production‑grade serverless setup.

Alibaba Cloud Native
Alibaba Cloud Native
Alibaba Cloud Native
How to Deploy Production-Ready Knative Services on Alibaba Cloud Container Service

Knative Service Deployment

Apply the Knative Service definition with kubectl apply -f helloworld-go.yaml. The manifest defines a Service named helloworld-go in the default namespace, using the Go hello‑world image and setting the environment variable TARGET=\"Knative\".

apiVersion: serving.knative.dev/v1alpha1
kind: Service
metadata:
  name: helloworld-go
  namespace: default
spec:
  template:
    spec:
      containers:
      - image: registry.cn-hangzhou.aliyuncs.com/knative-sample/helloworld-go:160e4db7
        env:
        - name: TARGET
          value: "Knative"

Obtain the external IP of the Istio ingress gateway (the LoadBalancer address) to reach the service from outside the cluster:

kubectl -n istio-system get svc istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}'

Retrieve the Knative Service URL (for reference):

kubectl get ksvc helloworld-go -o jsonpath='{.status.url}'

Test the service by sending an HTTP request with the required Host header. Replace <EXTERNAL_IP> with the IP obtained above:

curl -H "Host: helloworld-go.default.example.com" http://<EXTERNAL_IP>

The expected response is Hello Knative!.

Logging and Monitoring with Alibaba Cloud Log Service

Create a Logstore (e.g., helloworld ) in Alibaba Cloud Log Service. Configure a data source to collect Docker container standard output and add a processor to extract the fields time, level, and msg from each log line.

{
  "inputs": [
    {
      "detail": {
        "IncludeEnv": {"K_SERVICE": "helloworld-go"},
        "IncludeLabel": {},
        "ExcludeLabel": {}
      },
      "type": "service_docker_stdout"
    }
  ],
  "processors": [
    {
      "detail": {
        "KeepSource": false,
        "NoMatchError": true,
        "Keys": ["time", "level", "msg"],
        "NoKeyError": true,
        "Regex": "(\\d+-\\d+-\\d+\\s+\\d+:\\d+:\\d+)\\s+(\\w+)\\s+(.*)",
        "SourceKey": "content"
      },
      "type": "processor_regex"
    }
  ]
}

In the Log Service console, create a query to display the three columns and count occurrences of ERROR logs:

* | select 'ERROR', count(1) as total group by 'ERROR'

Save the query as an alarm, set the evaluation period to 1 minute, and trigger the alarm when total > 3. Notification channels (e.g., email or DingTalk) can be configured in the alarm settings.

Distributed Tracing with Alibaba Cloud Tracing Analysis

Enable automatic Istio sidecar injection for the namespace so that each pod receives an Envoy proxy that reports trace data:

kubectl label namespace default istio-injection=enabled

After labeling, redeploy or restart the Knative Service to ensure the sidecar is injected. Access the service (using the curl command above) to generate trace spans.

Open the Alibaba Cloud Tracing Analysis console, select the application list, and view tracing details such as average response time, request volume, and call‑graph topology for the helloworld-go service.

Summary of Steps

Create helloworld-go.yaml and apply it with kubectl.

Get the external IP of istio-ingressgateway and test the service via curl with the proper Host header.

Set up Alibaba Cloud Log Service Logstore, data source, and processor to collect and parse container logs.

Define a Log Service query to count ERROR logs and configure an alarm with a 1‑minute evaluation period and threshold total > 3.

Label the namespace for Istio sidecar injection, redeploy the service, and generate trace data by invoking the endpoint.

Use the Tracing Analysis console to inspect distributed tracing metrics for the service.

References (URLs kept as plain text for completeness):

Knative deployment guide on Alibaba Cloud: https://help.aliyun.com/document_detail/121509.html

Log Service Docker stdout integration: https://help.aliyun.com/document_detail/66658.html

Log Service query and analysis: https://help.aliyun.com/document_detail/53608.html

Log Service console: https://sls.console.aliyun.com/

Alarm condition syntax: https://help.aliyun.com/document_detail/98379.html

Tracing Analysis console: https://tracing-analysis.console.aliyun.com/

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.

ServerlessloggingtracingAlibaba CloudKnativeContainer Service
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.