All Products
Search
Document Center

Container Service for Kubernetes:Use elastic container instances in Knative

Last Updated:Nov 06, 2024

If your business traffic spikes unexpectedly, you can use pods deployed on elastic container instances in Knative. This allows you to pay for resources based on the actual usage.

Prerequisites

Procedure

  1. Create a Knative Service, add the alibabacloud.com/eci=true label to the Service, and add the k8s.aliyun.com/eci-use-specs annotation to specify the type of elastic container instance to be used. Then, run the kubectl apply command to deploy the YAML file.

    Sample template:

    apiVersion: serving.knative.dev/v1
    kind: Service
    metadata:
      name: helloworld-go
      namespace: vk
    spec:
      template:
        metadata:
          labels:
            alibabacloud.com/eci: "true" # Add the label.
          annotations:
            k8s.aliyun.com/eci-use-specs: "2-4Gi" # Specify the type of elastic container instance.
        spec:         
          containers:
          - env:
            - name: TARGET
              value: "Knative"
            image: registry.cn-hangzhou.aliyuncs.com/knative-sample/helloworld-go:73fbdd56
  2. After you complete the configuration, run the following command to verify that the configuration is successful:

    kubectl -n vk get pod -o wide

    Expected output:

    NAME                                              READY   STATUS    RESTARTS   AGE   IP             NODE                 NOMINATED NODE   READINESS GATES
    helloworld-go-dqqhv-deployment-6d54c9c8dc-hkjwn   2/2     Running   0          40s   192.XX.0.80   virtual-node-eci-0   <none>           <none>

    The output indicates the two Elastic Container Instance-based pods are created.

References