Creating a LoadBalancer-Type Service

CCE CCE

  • Function Release Records
  • Common Tools
    • Command Line Scenario Examples
  • API Reference
    • Overview
    • Common Headers and Error Responses
    • General Description
  • Product Announcement
    • Announcement on the Discontinuation of CCE Standalone Clusters
    • CCE New Cluster Management Release Announcement
    • Upgrade Announcement for CCE Cluster Audit Component kube-external-auditor
    • CCE Console Upgrade Announcement
    • Announcement on Management Fees for CCE Managed Clusters
    • Container Runtime Version Release Notes
    • Announcement on the Decommissioning of CCE Image Repository
    • Kubernetes Version Release Notes
      • CCE Release of Kubernetes v1_26 History
      • CCE Kubernetes Version Update Notes
      • CCE Release of Kubernetes v1_24 History
      • CCE Release of Kubernetes v1_30 History
      • CCE Release of Kubernetes v1_22 History
      • CCE Release of Kubernetes v1_18 History
      • CCE Release of Kubernetes v1_20 History
      • CCE Release of Kubernetes v1_28 History
      • Release Notes for CCE Kubernetes 1_31 Version
      • Kubernetes Version Overview and Mechanism
    • Security Vulnerability Fix Announcement
      • Vulnerability CVE-2019-5736 Fix Announcement
      • Vulnerability CVE-2021-30465 Fix Announcement
      • CVE-2025-1097, CVE-2025-1098, and Other Vulnerabilities Fix Announcement
      • CVE-2020-14386 Vulnerability Fix Announcement
      • Impact Statement on runc Security Issue (CVE-2024-21626)
  • Service Level Agreement (SLA)
    • CCE Service Level Agreement SLA (V1_0)
  • Typical Practices
    • Pod Anomaly Troubleshooting
    • Adding CGroup V2 Node
    • Common Linux System Configuration Parameters Description
    • Encrypting etcd Data Using KMS
    • Configuring Container Network Parameters Using CNI
    • CCE - Public Network Access Practice
    • Practice of using private images in CCE clusters
    • Unified Access for Virtual Machines and Container Services via CCE Ingress
    • User Guide for Custom CNI Plugins
    • CCE Cluster Network Description and Planning
    • Cross-Cloud Application Migration to Baidu CCE Using Velero
    • CCE Resource Recommender User Documentation
    • Continuous Deployment with Jenkins in CCE Cluster
    • CCE Best Practice-Guestbook Setup
    • CCE Best Practice-Container Network Mode Selection
    • CCE Usage Checklist
    • VPC-ENI Mode Cluster Public Network Access Practice
    • CCE Container Runtime Selection
    • Cloud-native AI
      • Elastic and Fault-Tolerant Training Using CCE AITraining Operator
      • Deploy the TensorFlow Serving inference service
      • Best Practice for GPU Virtualization with Optimal Isolation
  • FAQs
    • How do business applications use load balancer
    • Using kubectl on Windows
    • Cluster management FAQs
    • Common Questions Overview
    • Auto scaling FAQs
    • Create a simple service via kubectl
  • Operation guide
    • Prerequisites for use
    • Identity and access management
    • Permission Management
      • Configure IAM Tag Permission Policy
      • Permission Overview
      • Configure IAM Custom Permission Policy
      • Configure Predefined RBAC Permission Policy
      • Configure IAM Predefined Permission Policy
      • Configure Cluster OIDC Authentication
    • Configuration Management
      • Configmap Management
      • Secret Management
    • Traffic access
      • BLB ingress annotation description
      • Use K8S_Service via CCE
      • Use K8S_Ingress via CCE
      • Implement Canary Release with CCE Based on Nginx-Ingress
      • Create CCE_Ingress via YAML
      • LoadBalancer Service Annotation Description
      • Service Reuses Existing Load Balancer BLB
      • Use Direct Pod Mode LoadBalancer Service
      • NGINX Ingress Configuration Reference
      • Create LoadBalancer_Service via YAML
      • Use NGINX Ingress
    • Virtual Node
      • Configuring BCIPod
      • Configuring bci-profile
      • Managing virtual nodes
    • Node management
      • Add a node
      • Managing Taints
      • Setting Node Blocking
      • Setting GPU Memory Sharing
      • Remove a node
      • Customizing Kubelet Parameters
      • Kubelet Container Monitor Read-Only Port Risk Warning
      • Managing Node Tag
      • Drain node
    • Component Management
      • CCE CSI CDS Plugin Description
      • CCE Fluid Description
      • CCE CSI PFS L2 Plugin
      • CCE Calico Felix Description
      • CCE Ingress Controller Description
      • CCE QoS Agent Description
      • CCE GPU Manager Description
      • CCE Ingress NGINX Controller Description
      • CCE P2P Accelerator Description
      • CCE Virtual Kubelet Component
      • CoreDNS Description
      • CCE Log Operator Description
      • CCE Node Remedier Description
      • CCE Descheduler Description
      • CCE Dynamic Scheduling Plugin Description
      • Kube Scheduler Documentation
      • CCE NPU Manager Description
      • CCE CronHPA Controller Description
      • CCE LB Controller Description
      • Kube ApiServer Description
      • CCE Backup Controller Description
      • CCE Network Plugin Description
      • CCE CSI PFS Plugin Description
      • CCE Credential Controller Description
      • CCE Deep Learning Frameworks Operator Description
      • Component Overview
      • CCE Image Accelerate Description
      • CCE CSI BOS Plugin Description
      • CCE Onepilot Description
      • Description of Kube Controller Manager
      • CCE_Hybrid_Manager Description
      • CCE NodeLocal DNSCache Description
      • CCE Node Problem Detector Description
      • CCE Ascend Mindx DL Description
      • CCE RDMA Device Plugin Description
      • CCE AI Job Scheduler Description
    • Image registry
      • Image Registry Basic Operations
      • Using Container Image to Build Services
    • Helm Management
      • Helm Template
      • Helm Instance
    • Cluster management
      • Upgrade Cluster Kubernetes Version
      • CCE Node CDS Dilatation
      • Managed Cluster Usage Instructions
      • Create cluster
      • CCE Supports GPUSharing Cluster
      • View Cluster
      • Connect to Cluster via kubectl
      • CCE Security Group
      • CCE Node Resource Reservation Instructions
      • Operate Cluster
      • Cluster Snapshot
    • Serverless Cluster
      • Product overview
      • Using Service in Serverless Cluster
      • Creating a Serverless Cluster
    • Storage Management
      • Using Cloud File System
      • Overview
      • Using Parallel File System PFS
      • Using RapidFS
      • Using Object Storage BOS
      • Using Parallel File System PFS L2
      • Using Local Storage
      • Using Cloud Disk CDS
    • Inspection and Diagnosis
      • Cluster Inspection
      • GPU Runtime Environment Check
      • Fault Diagnosis
    • Cloud-native AI
      • Cloud-Native AI Overview
      • AI Monitoring Dashboard
        • Connecting to a Prometheus Instance and Starting a Job
        • NVIDIA Chip Resource Observation
          • AI Job Scheduler component
          • GPU node resources
          • GPU workload resources
          • GPUManager component
          • GPU resource pool overview
        • Ascend Chip Resource Observation
          • Ascend resource pool overview
          • Ascend node resource
          • Ascend workload resource
      • Task Management
        • View Task Information
        • Create TensorFlow Task
        • Example of RDMA Distributed Training Based on NCCL
        • Create PaddlePaddle Task
        • Create AI Training Task
        • Delete task
        • Create PyTorch Task
        • Create Mxnet Task
      • Queue Management
        • Modify Queue
        • Create Queue
        • Usage Instructions for Logical Queues and Physical Queues
        • Queue deletion
      • Dataset Management
        • Create Dataset
        • Delete dataset
        • View Dataset
        • Operate Dataset
      • AI Acceleration Kit
        • AIAK Introduction
        • Using AIAK-Training PyTorch Edition
        • Deploying Distributed Training Tasks Using AIAK-Training
        • Accelerating Inference Business Using AIAK-Inference
      • GPU Virtualization
        • GPU Exclusive and Shared Usage Instructions
        • Image Build Precautions in Shared GPU Scenarios
        • Instructions for Multi-GPU Usage in Single-GPU Containers
        • GPU Virtualization Adaptation Table
        • GPU Online and Offline Mixed Usage Instructions
        • MPS Best Practices & Precautions
        • Precautions for Disabling Node Video Memory Sharing
    • Elastic Scaling
      • Container Timing Horizontal Scaling (CronHPA)
      • Container Horizontal Scaling (HPA)
      • Implementing Second-Level Elastic Scaling with cce-autoscaling-placeholder
      • CCE Cluster Node Auto-Scaling
    • Network Management
      • How to Continue Dilatation When Container Network Segment Space Is Exhausted (VPC-ENI Mode)
      • Container Access to External Services in CCE Clusters
      • CCE supports dual-stack networks of IPv4 and IPv6
      • Using NetworkPolicy Network Policy
      • Traffic Forwarding Configuration for Containers in Peering Connections Scenarios
      • CCE IP Masquerade Agent User Guide
      • Creating VPC-ENI Mode Cluster
      • How to Continue Dilatation When Container Network Segment Space Is Exhausted (VPC Network Mode)
      • Using NetworkPolicy in CCE Clusters
      • Network Orchestration
        • Container Network QoS Management
        • VPC-ENI Specified Subnet IP Allocation (Container Network v2)
        • Cluster Pod Subnet Topology Distribution (Container Network v2)
      • Network Connectivity
        • Container network accesses the public network via NAT gateway
      • Network Maintenance
        • Common Error Code Table for CCE Container Network
      • DNS
        • CoreDNS Component Manual Dilatation Guide
        • DNS Troubleshooting Guide
        • DNS Principle Overview
    • Namespace Management
      • Set Limit Range
      • Set Resource Quota
      • Basic Namespace Operations
    • Workload
      • CronJob Management
      • Set Workload Auto-Scaling
      • Deployment Management
      • Job Management
      • View the Pod
      • StatefulSet Management
      • Password-Free Pull of Container Image
      • Create Workload Using Private Image
      • DaemonSet Management
    • Monitor Logs
      • Monitor Cluster with Prometheus
      • CCE Event Center
      • Cluster Service Profiling
      • CCE Cluster Anomaly Event Alerts
      • Java Application Monitor
      • Cluster Audit Dashboard
      • Logging
      • Cluster Audit
      • Log Center
        • Configure Collection Rules Using CRD
        • View Cluster Control Plane Logs
        • View Business Logs
        • Log Overview
        • Configure Collection Rules in Cloud Container Engine Console
    • Application management
      • Overview
      • Secret
      • Configuration dictionary
      • Deployment
      • Service
      • Pod
    • NodeGroup Management
      • NodeGroup Management
      • NodeGroup Node Fault Detection and Self-Healing
      • Configuring Scaling Policies
      • NodeGroup Introduction
      • Adding Existing External Nodes
      • Custom NodeGroup Kubelet Configuration
      • Adding Alternative Models
      • Dilatation NodeGroup
    • Backup Center
      • Restore Management
      • Backup Overview
      • Backup Management
      • Backup repository
  • Quick Start
    • Quick Deployment of Nginx Application
    • CCE Container Engine Usage Process Overview
  • Product pricing
    • Product pricing
  • Product Description
    • Application scenarios
    • Introduction
    • Usage restrictions
    • Features
    • Advantages
    • Core concepts
  • Solution-Fabric
    • Fabric Solution
  • Development Guide
    • EFK Log Collection System Deployment Guide
    • Using Network Policy in CCE Cluster
    • Creating a LoadBalancer-Type Service
    • Prometheus Monitoring System Deployment Guide
    • kubectl Management Configuration
  • API_V2 Reference
    • Overview
    • Common Headers and Error Responses
    • Cluster Related Interfaces
    • Instance Related Interfaces
    • Service domain
    • General Description
    • Kubeconfig Related Interfaces
    • RBAC Related Interfaces
    • Autoscaler Related Interfaces
    • Network Related Interfaces
    • InstanceGroup Related Interfaces
    • Appendix
    • Component management-related APIs
    • Package adaptation-related APIs
    • Task Related Interfaces
  • Solution-Xchain
    • Hyperchain Solution
  • SDK
    • Go-SDK
      • Overview
      • NodeGroup Management
      • Initialization
      • Install the SDK Package
      • Cluster management
      • Node management
All documents
menu
No results found, please re-enter

CCE CCE

  • Function Release Records
  • Common Tools
    • Command Line Scenario Examples
  • API Reference
    • Overview
    • Common Headers and Error Responses
    • General Description
  • Product Announcement
    • Announcement on the Discontinuation of CCE Standalone Clusters
    • CCE New Cluster Management Release Announcement
    • Upgrade Announcement for CCE Cluster Audit Component kube-external-auditor
    • CCE Console Upgrade Announcement
    • Announcement on Management Fees for CCE Managed Clusters
    • Container Runtime Version Release Notes
    • Announcement on the Decommissioning of CCE Image Repository
    • Kubernetes Version Release Notes
      • CCE Release of Kubernetes v1_26 History
      • CCE Kubernetes Version Update Notes
      • CCE Release of Kubernetes v1_24 History
      • CCE Release of Kubernetes v1_30 History
      • CCE Release of Kubernetes v1_22 History
      • CCE Release of Kubernetes v1_18 History
      • CCE Release of Kubernetes v1_20 History
      • CCE Release of Kubernetes v1_28 History
      • Release Notes for CCE Kubernetes 1_31 Version
      • Kubernetes Version Overview and Mechanism
    • Security Vulnerability Fix Announcement
      • Vulnerability CVE-2019-5736 Fix Announcement
      • Vulnerability CVE-2021-30465 Fix Announcement
      • CVE-2025-1097, CVE-2025-1098, and Other Vulnerabilities Fix Announcement
      • CVE-2020-14386 Vulnerability Fix Announcement
      • Impact Statement on runc Security Issue (CVE-2024-21626)
  • Service Level Agreement (SLA)
    • CCE Service Level Agreement SLA (V1_0)
  • Typical Practices
    • Pod Anomaly Troubleshooting
    • Adding CGroup V2 Node
    • Common Linux System Configuration Parameters Description
    • Encrypting etcd Data Using KMS
    • Configuring Container Network Parameters Using CNI
    • CCE - Public Network Access Practice
    • Practice of using private images in CCE clusters
    • Unified Access for Virtual Machines and Container Services via CCE Ingress
    • User Guide for Custom CNI Plugins
    • CCE Cluster Network Description and Planning
    • Cross-Cloud Application Migration to Baidu CCE Using Velero
    • CCE Resource Recommender User Documentation
    • Continuous Deployment with Jenkins in CCE Cluster
    • CCE Best Practice-Guestbook Setup
    • CCE Best Practice-Container Network Mode Selection
    • CCE Usage Checklist
    • VPC-ENI Mode Cluster Public Network Access Practice
    • CCE Container Runtime Selection
    • Cloud-native AI
      • Elastic and Fault-Tolerant Training Using CCE AITraining Operator
      • Deploy the TensorFlow Serving inference service
      • Best Practice for GPU Virtualization with Optimal Isolation
  • FAQs
    • How do business applications use load balancer
    • Using kubectl on Windows
    • Cluster management FAQs
    • Common Questions Overview
    • Auto scaling FAQs
    • Create a simple service via kubectl
  • Operation guide
    • Prerequisites for use
    • Identity and access management
    • Permission Management
      • Configure IAM Tag Permission Policy
      • Permission Overview
      • Configure IAM Custom Permission Policy
      • Configure Predefined RBAC Permission Policy
      • Configure IAM Predefined Permission Policy
      • Configure Cluster OIDC Authentication
    • Configuration Management
      • Configmap Management
      • Secret Management
    • Traffic access
      • BLB ingress annotation description
      • Use K8S_Service via CCE
      • Use K8S_Ingress via CCE
      • Implement Canary Release with CCE Based on Nginx-Ingress
      • Create CCE_Ingress via YAML
      • LoadBalancer Service Annotation Description
      • Service Reuses Existing Load Balancer BLB
      • Use Direct Pod Mode LoadBalancer Service
      • NGINX Ingress Configuration Reference
      • Create LoadBalancer_Service via YAML
      • Use NGINX Ingress
    • Virtual Node
      • Configuring BCIPod
      • Configuring bci-profile
      • Managing virtual nodes
    • Node management
      • Add a node
      • Managing Taints
      • Setting Node Blocking
      • Setting GPU Memory Sharing
      • Remove a node
      • Customizing Kubelet Parameters
      • Kubelet Container Monitor Read-Only Port Risk Warning
      • Managing Node Tag
      • Drain node
    • Component Management
      • CCE CSI CDS Plugin Description
      • CCE Fluid Description
      • CCE CSI PFS L2 Plugin
      • CCE Calico Felix Description
      • CCE Ingress Controller Description
      • CCE QoS Agent Description
      • CCE GPU Manager Description
      • CCE Ingress NGINX Controller Description
      • CCE P2P Accelerator Description
      • CCE Virtual Kubelet Component
      • CoreDNS Description
      • CCE Log Operator Description
      • CCE Node Remedier Description
      • CCE Descheduler Description
      • CCE Dynamic Scheduling Plugin Description
      • Kube Scheduler Documentation
      • CCE NPU Manager Description
      • CCE CronHPA Controller Description
      • CCE LB Controller Description
      • Kube ApiServer Description
      • CCE Backup Controller Description
      • CCE Network Plugin Description
      • CCE CSI PFS Plugin Description
      • CCE Credential Controller Description
      • CCE Deep Learning Frameworks Operator Description
      • Component Overview
      • CCE Image Accelerate Description
      • CCE CSI BOS Plugin Description
      • CCE Onepilot Description
      • Description of Kube Controller Manager
      • CCE_Hybrid_Manager Description
      • CCE NodeLocal DNSCache Description
      • CCE Node Problem Detector Description
      • CCE Ascend Mindx DL Description
      • CCE RDMA Device Plugin Description
      • CCE AI Job Scheduler Description
    • Image registry
      • Image Registry Basic Operations
      • Using Container Image to Build Services
    • Helm Management
      • Helm Template
      • Helm Instance
    • Cluster management
      • Upgrade Cluster Kubernetes Version
      • CCE Node CDS Dilatation
      • Managed Cluster Usage Instructions
      • Create cluster
      • CCE Supports GPUSharing Cluster
      • View Cluster
      • Connect to Cluster via kubectl
      • CCE Security Group
      • CCE Node Resource Reservation Instructions
      • Operate Cluster
      • Cluster Snapshot
    • Serverless Cluster
      • Product overview
      • Using Service in Serverless Cluster
      • Creating a Serverless Cluster
    • Storage Management
      • Using Cloud File System
      • Overview
      • Using Parallel File System PFS
      • Using RapidFS
      • Using Object Storage BOS
      • Using Parallel File System PFS L2
      • Using Local Storage
      • Using Cloud Disk CDS
    • Inspection and Diagnosis
      • Cluster Inspection
      • GPU Runtime Environment Check
      • Fault Diagnosis
    • Cloud-native AI
      • Cloud-Native AI Overview
      • AI Monitoring Dashboard
        • Connecting to a Prometheus Instance and Starting a Job
        • NVIDIA Chip Resource Observation
          • AI Job Scheduler component
          • GPU node resources
          • GPU workload resources
          • GPUManager component
          • GPU resource pool overview
        • Ascend Chip Resource Observation
          • Ascend resource pool overview
          • Ascend node resource
          • Ascend workload resource
      • Task Management
        • View Task Information
        • Create TensorFlow Task
        • Example of RDMA Distributed Training Based on NCCL
        • Create PaddlePaddle Task
        • Create AI Training Task
        • Delete task
        • Create PyTorch Task
        • Create Mxnet Task
      • Queue Management
        • Modify Queue
        • Create Queue
        • Usage Instructions for Logical Queues and Physical Queues
        • Queue deletion
      • Dataset Management
        • Create Dataset
        • Delete dataset
        • View Dataset
        • Operate Dataset
      • AI Acceleration Kit
        • AIAK Introduction
        • Using AIAK-Training PyTorch Edition
        • Deploying Distributed Training Tasks Using AIAK-Training
        • Accelerating Inference Business Using AIAK-Inference
      • GPU Virtualization
        • GPU Exclusive and Shared Usage Instructions
        • Image Build Precautions in Shared GPU Scenarios
        • Instructions for Multi-GPU Usage in Single-GPU Containers
        • GPU Virtualization Adaptation Table
        • GPU Online and Offline Mixed Usage Instructions
        • MPS Best Practices & Precautions
        • Precautions for Disabling Node Video Memory Sharing
    • Elastic Scaling
      • Container Timing Horizontal Scaling (CronHPA)
      • Container Horizontal Scaling (HPA)
      • Implementing Second-Level Elastic Scaling with cce-autoscaling-placeholder
      • CCE Cluster Node Auto-Scaling
    • Network Management
      • How to Continue Dilatation When Container Network Segment Space Is Exhausted (VPC-ENI Mode)
      • Container Access to External Services in CCE Clusters
      • CCE supports dual-stack networks of IPv4 and IPv6
      • Using NetworkPolicy Network Policy
      • Traffic Forwarding Configuration for Containers in Peering Connections Scenarios
      • CCE IP Masquerade Agent User Guide
      • Creating VPC-ENI Mode Cluster
      • How to Continue Dilatation When Container Network Segment Space Is Exhausted (VPC Network Mode)
      • Using NetworkPolicy in CCE Clusters
      • Network Orchestration
        • Container Network QoS Management
        • VPC-ENI Specified Subnet IP Allocation (Container Network v2)
        • Cluster Pod Subnet Topology Distribution (Container Network v2)
      • Network Connectivity
        • Container network accesses the public network via NAT gateway
      • Network Maintenance
        • Common Error Code Table for CCE Container Network
      • DNS
        • CoreDNS Component Manual Dilatation Guide
        • DNS Troubleshooting Guide
        • DNS Principle Overview
    • Namespace Management
      • Set Limit Range
      • Set Resource Quota
      • Basic Namespace Operations
    • Workload
      • CronJob Management
      • Set Workload Auto-Scaling
      • Deployment Management
      • Job Management
      • View the Pod
      • StatefulSet Management
      • Password-Free Pull of Container Image
      • Create Workload Using Private Image
      • DaemonSet Management
    • Monitor Logs
      • Monitor Cluster with Prometheus
      • CCE Event Center
      • Cluster Service Profiling
      • CCE Cluster Anomaly Event Alerts
      • Java Application Monitor
      • Cluster Audit Dashboard
      • Logging
      • Cluster Audit
      • Log Center
        • Configure Collection Rules Using CRD
        • View Cluster Control Plane Logs
        • View Business Logs
        • Log Overview
        • Configure Collection Rules in Cloud Container Engine Console
    • Application management
      • Overview
      • Secret
      • Configuration dictionary
      • Deployment
      • Service
      • Pod
    • NodeGroup Management
      • NodeGroup Management
      • NodeGroup Node Fault Detection and Self-Healing
      • Configuring Scaling Policies
      • NodeGroup Introduction
      • Adding Existing External Nodes
      • Custom NodeGroup Kubelet Configuration
      • Adding Alternative Models
      • Dilatation NodeGroup
    • Backup Center
      • Restore Management
      • Backup Overview
      • Backup Management
      • Backup repository
  • Quick Start
    • Quick Deployment of Nginx Application
    • CCE Container Engine Usage Process Overview
  • Product pricing
    • Product pricing
  • Product Description
    • Application scenarios
    • Introduction
    • Usage restrictions
    • Features
    • Advantages
    • Core concepts
  • Solution-Fabric
    • Fabric Solution
  • Development Guide
    • EFK Log Collection System Deployment Guide
    • Using Network Policy in CCE Cluster
    • Creating a LoadBalancer-Type Service
    • Prometheus Monitoring System Deployment Guide
    • kubectl Management Configuration
  • API_V2 Reference
    • Overview
    • Common Headers and Error Responses
    • Cluster Related Interfaces
    • Instance Related Interfaces
    • Service domain
    • General Description
    • Kubeconfig Related Interfaces
    • RBAC Related Interfaces
    • Autoscaler Related Interfaces
    • Network Related Interfaces
    • InstanceGroup Related Interfaces
    • Appendix
    • Component management-related APIs
    • Package adaptation-related APIs
    • Task Related Interfaces
  • Solution-Xchain
    • Hyperchain Solution
  • SDK
    • Go-SDK
      • Overview
      • NodeGroup Management
      • Initialization
      • Install the SDK Package
      • Cluster management
      • Node management
  • Document center
  • arrow
  • CCECCE
  • arrow
  • Development Guide
  • arrow
  • Creating a LoadBalancer-Type Service
Table of contents on this page
  • Quick start
  • Advanced configuration
  • Fixed EIP
  • No EIP allocation (VPC-internal BLB)
  • Custom EIP configuration
  • UDP-Service
  • Specify a subnet for the service’s BLB

Creating a LoadBalancer-Type Service

Updated at:2025-10-27

This guide provides steps to create a LoadBalancer-type service in CCE.

Kubernetes official tutorial: Services

Quick start

When creating a LoadBalancer-type service, the CCE will automatically generate a BLB and bind an EIP to it by default.

Example: Create a simple Nginx service

Plain Text
1---
2kind: Service
3apiVersion: v1
4metadata:
5  name: nginx-service
6spec:
7  selector:
8    app: nginx
9  type: LoadBalancer
10  ports:
11  - name: nginx-port
12    port: 80
13    targetPort: 80
14    protocol: TCP
15---
16apiVersion: apps/v1beta1
17kind: Deployment
18metadata:
19  name: nginx-deployment
20spec:
21  replicas: 1
22  template:
23    metadata:
24      labels:
25        app: nginx
26    spec:
27      containers:
28      - name: nginx
29        image: nginx
30        ports:
31        - containerPort: 80

(1) Creation

$ kubectl create -f nginx.yaml

(2) Query EIP

The IP 8.8.8.8 is the EIP allocated to this Nginx service.

Plain Text
1$ kubectl get svc
2NAME            CLUSTER-IP     EXTERNAL-IP      PORT(S)        AGE
3nginx-service   1.1.1.1        8.8.8.8          80:30274/TCP   5m

(3) Query BLB

Plain Text
1$ kubectl get svc nginx-service -o jsonpath={.metadata.annotations}
2map[service.beta.kubernetes.io/cce-load-balancer-id:lb-xxxxxx]

lb-xxxxxx is the unique identifier of the BLB associated with this service.

(4) Access test

$ curl -i http://8.8.8.8

Advanced configuration

Fixed EIP

When a service is deleted and recreated, the EIP will change by default. Therefore, dependent services must be updated accordingly. To prevent this, CCE offers a method to fix the EIP for the service.

Solution for fixed EIP:

(1) Pre-purchase an EIP instance on Baidu AI Cloud
(2) When creating the service, set loadBalancerIP to this pre-purchased EIP
(3) After creating the service, the EXTERNAL-IP of the service will be this fixed EIP
(4) When deleting the service, CCE will only unbind the EIP (not release it), so you can reuse the EIP for future service creations

An example is as follows:

Plain Text
1---
2kind: Service
3apiVersion: v1
4metadata:
5  name: nginx-service-eip-with-load-balancer-ip
6spec:
7  selector:
8    app: nginx-eip-with-load-balancer-ip
9  type: LoadBalancer
10  loadBalancerIP: 8.8.8.8
11  ports:
12  - name: nginx-port
13    port: 80
14    targetPort: 80
15    protocol: TCP
16---
17apiVersion: apps/v1beta1
18kind: Deployment
19metadata:
20  name: nginx-deployment-eip-with-load-balancer-ip
21spec:
22  replicas: 1
23  template:
24    metadata:
25      labels:
26        app: nginx-eip-with-load-balancer-ip
27    spec:
28      containers:
29      - name: nginx
30        image: nginx
31        ports:
32        - containerPort: 80

The queried EXTERNAL-IP will be the fixed EIP:

Plain Text
1kubectl get svc nginx-service
2NAME                                    TYPE           CLUSTER-IP       EXTERNAL-IP      PORT(S)        AGE
3nginx-service-eip-with-loadBalancerIP   LoadBalancer   1.1.1.1          8.8.8.8          80:30601/TCP   1m

No EIP allocation (VPC-internal BLB)

When the user uses:
(1) Set Service.Spec.Type = LoadBalancer
(2) Add the following annotation to the service: service.beta.kubernetes.io/cce-load-balancer-internal-vpc: "true"

An example is as follows:

Plain Text
1---
2kind: Service
3apiVersion: v1
4metadata:
5  name: nginx-service-blb-internal-vpc
6  annotations:
7    service.beta.kubernetes.io/cce-load-balancer-internal-vpc: "true"
8spec:
9  selector:
10    app: nginx-blb-internal-vpc
11  type: LoadBalancer
12  ports:
13  - name: nginx-port
14    port: 80
15    targetPort: 80
16    protocol: TCP
17---
18apiVersion: apps/v1beta1
19kind: Deployment
20metadata:
21  name: nginx-deployment-blb-internal-vpc
22spec:
23  replicas: 1
24  template:
25    metadata:
26      labels:
27        app: nginx-blb-internal-vpc
28    spec:
29      containers:
30      - name: nginx
31        image: nginx
32        ports:
33        - containerPort: 80

The queried EXTERNAL-IP can only be accessed within the VPC:

Plain Text
1kubectl get svc nginx-service
2NAME                             TYPE           CLUSTER-IP       EXTERNAL-IP      PORT(S)        AGE
3nginx-service-blb-internal-vpc   LoadBalancer   1.1.1.1          2.2.2.2          80:30601/TCP   1m

Note: This internal BLB works normally only between clusters in the same VPC. When using an internal BLB within the same cluster, issues may occur. It is recommended to use the Service’s ClusterIP directly for intra-cluster access

Custom EIP configuration

Supported EIP configuration types

Prepaid

Item Restriction
Public network bandwidth 1-200Mbps,Int
Purchase period [1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 24, 36] (unit: month)

Postpaid

Charge type Public network bandwidth Cost examples
Traffic-based billing (ByTraffic) 1~1000Mbps,Int Configuration fee: ¥0.00032/minute; traffic fee: ¥0.76/GB
Bandwidth-based billing (ByBandwidth) 1-200Mbps,Int Configuration fee (example for 1 Mbps): ¥0.00094/minute

Usage method Set the following annotations when creating the service:

Plain Text
1// Bill type (default: Postpaid; options: Postpaid, Prepaid)
2service.beta.kubernetes.io/cce-elastic-ip-payment-timing:"Postpaid"
3 // Charge type (default: ByTraffic; options: ByTraffic, ByBandwidth)
4service.beta.kubernetes.io/cce-elastic-ip-billing-method:"ByTraffic"
5 // Public network bandwidth (unit: Mbps; default: 1,000 or 200). For Prepaid/bandwidth-type EIPs: Limited to integers between 1 and 200. For traffic-type EIPs: Limited to integers between 1 and 1,000.
6service.beta.kubernetes.io/cce-elastic-ip-bandwidth-in-mbps:"1000"
7 // Duration (required for Prepaid; unit: month; options: [1,2,3,4,5,6,7,8,9,12,24,36]). Invalid for Postpaid
8service.beta.kubernetes.io/cce-elastic-ip-reservation-length:"36"

Postpay example:

Plain Text
1kind: Service
2apiVersion: v1
3metadata:
4  name: nginx-service
5  annotations:
6    service.beta.kubernetes.io/cce-elastic-ip-payment-timing: "Postpaid"
7    service.beta.kubernetes.io/cce-elastic-ip-billing-method: "ByTraffic"
8    service.beta.kubernetes.io/cce-elastic-ip-bandwidth-in-mbps: "200"
9spec:
10  selector:
11    app: nginx
12  type: LoadBalancer
13  ports:
14  - name: http
15    port: 80
16    targetPort: 80

Example: Prepaid EIP configuration (ensure sufficient account balance; otherwise, creation will fail)

Plain Text
1kind: Service
2apiVersion: v1
3metadata:
4  name: nginx-service
5  annotations:
6    service.beta.kubernetes.io/cce-elastic-ip-payment-timing: "Prepaid"
7    service.beta.kubernetes.io/cce-elastic-ip-bandwidth-in-mbps: "10"
8    service.beta.kubernetes.io/cce-elastic-ip-reservation-length:"1"
9spec:
10  selector:
11    app: nginx
12  type: LoadBalancer
13  ports:
14  - name: http
15    port: 80
16    targetPort: 80

Notes Default configuration: Default: Postpaid + traffic-based billing + 1,000 Mbps bandwidth.

Fixed EIP: Updating the configuration of a fixed EIP is not supported via service annotations. Modify it manually in the console.

Updating service EIP configurations (manual annotation editing): Only the public network bandwidth can be updated

Prepay:

(1) For Prepaid EIPs: Automatic renewal is not available (due to EIP API limitations). Renew manually via the console.

(2) For Prepaid EIPs: The charge type does not need to be set

(3) For Prepaid EIPs: Deleting the service will not release the EIP; it will be released only after expiration

UDP-Service

To use UDP for the service, set spec.ports.protocol to UDP. Example steps:

Plain Text
1---
2apiVersion: v1
3kind: Service
4metadata:
5  name: udp-server-demo-svc
6  labels:
7    app: udp-server-demo
8spec:
9  type: LoadBalancer
10  ports:
11  - name: udp-server-demo-port
12    port: 3005
13    targetPort: 3005
14    protocol: UDP
15  selector:
16    app: udp-server-demo
17---
18apiVersion: extensions/v1beta1
19kind: Deployment
20metadata:
21  name: udp-server-demo
22  labels:
23    app: udp-server-demo
24spec:
25  replicas: 1
26  selector:
27    matchLabels:
28      app: udp-server-demo
29  template:
30    metadata:
31      labels:
32        app: udp-server-demo
33    spec:
34      containers:
35      - name: udp-server-demo
36        image: hub.baidubce.com/jpaas-public/udp-server-demo:latest
37        ports:
38        - containerPort: 3005
39          protocol: UDP

(1) Deploy a UDP test service

Plain Text
1$ kubectl apply -f udp.yaml

(2) Verify the UDP Service is created successfully

Plain Text
1$ kubectl get svc
2NAME                  TYPE           CLUSTER-IP       EXTERNAL-IP      PORT(S)          AGE
3kubernetes            ClusterIP      172.16.0.1       <none>           443/TCP          6h
4udp-server-demo-svc   LoadBalancer   172.16.122.139   10.10.10.10      3005:31441/UDP   1m

(3) View the service logs

Plain Text
1$ kubectl logs -f udp-server-demo-6fdf5d796f-h6595
2Received: HealthCheck
3Get Health Check, response OK
4Received: HealthCheck
5Get Health Check, response OK
6Received: HealthCheck
7Get Health Check, response OK

Note: According to Baidu AI Cloud Load Balance (BLB) requirements, for services with UDP listeners, BLB will forward traffic to backend pods only if the UDP health check passes. Ensure your backend UDP service responds to the health check string. For details, see: [UDP Health Check Introduction](BLB/Operation guide/General-purpose BLB instance/Creating BLB Ordinary Instance.md#Configure UDP listener)

Specify a subnet for the service’s BLB

To facilitate network resource management, CCE supports specifying a subnet for the BLB when creating the service When the user uses:

(1) Set Service.Spec.Type = LoadBalancer

(2) Add an annotation to the service to specify the subnet ID:, service.beta.kubernetes.io/cce-load-balancer-internal-vpc: "sbn-*"

An example is as follows:

YAML
1---
2kind: Service
3apiVersion: v1
4metadata:
5  name: nginx-service-blb-subnet-id
6  annotations:
7    service.beta.kubernetes.io/cce-load-balancer-subnet-id: "sbn-123456"
8spec:
9  selector:
10    app: nginx
11  type: LoadBalancer
12  ports:
13  - name: nginx-port
14    port: 80
15    targetPort: 80
16    protocol: TCP
17---
18apiVersion: apps/v1beta1
19kind: Deployment
20metadata:
21  name: nginx-deployment-blb-subnet-id
22spec:
23  replicas: 1
24  template:
25    metadata:
26      labels:
27        app: nginx
28    spec:
29      containers:
30      - name: nginx
31        image: nginx
32        ports:
33        - containerPort: 80

After deploying the service, verify the BLB’s subnet in the BLB page of the Baidu AI Cloud console Note: The subnet can only be specified when creating the service. Adding or modifying this annotation for an existing service is not supported

Previous
Using Network Policy in CCE Cluster
Next
Prometheus Monitoring System Deployment Guide