Using Service in Serverless Cluster
This document explains how to utilize services in a serverless cluster. Depending on the cluster service mode chosen during cluster creation—be it kube-proxy or BLB—there are two available methods:
BLB
In this mode, services are bound to a BLB, and the ClusterIP of the service is the VPC IP of the BLB. Users need to bear the cost of the BLB, making it ideal for clusters with fewer services but a larger number of backend Pods.
Restriction
Due to the inherent limitations of BLB itself, services in this mode have the following restrictions:
- A single service cannot expose the same port for both TCP and UDP simultaneously. If this functionality is required, it is recommended to split them into two distinct services to resolve the conflict.
- For services listening on UDP ports, a UDP health check string needs to be configured. This is done through annotations in the service, with the annotation key:
service.kubernetes.io/cce-appblb-udp-health-check-string. For reference on the health check string, refer to: BLB UDP Configuration - BLB has quota limitations. For details, refer to: BLB Quota Description
- The ClusterIP of a service cannot be predefined during creation.
kube-proxy
When accessing services in this mode, client Pods must include a container running kube-proxy. The resources consumed by the kube-proxy container in the Pod are billed to the user. This mode is best suited for clusters with a large number of services and fewer client Pods.
In this mode, if client Pods need to enable kube-proxy, it must be specified through annotations in the Pod template, with the Annotation Key: bci.virtual-kubelet.io/kube-proxy-enabled
Configuration example
1apiVersion: apps/v1
2kind: Deployment
3metadata:
4 name: busybox
5spec:
6 selector:
7 matchLabels:
8 app: busybox
9 replicas: 1
10 template:
11 metadata:
12 labels:
13 app: busybox
14 annotations:
15 bci.virtual-kubelet.io/kube-proxy-enabled: "true"
16 spec:
17 containers:
18 - name: busybox
19 image: busybox
20 command: [ "/bin/sh", "-c", "sleep 3600" ]
