Write LoadBalancer in Tencent Cloud and Huawei Cloud

When using Kubernetes to deploy applications on Tencent Cloud and Huawei Cloud, you can use the LoadBalancer type Service to configure the load balancer.

Example on Tencent Cloud:

apiVersion: v1
kind: Service
metadata:
  name: my-web-service
  annotations:
    service.cloud.tencent.com/loadbalancer-type: "ExternalTraffic"
spec:
  type: LoadBalancer
  selector:
    app: my-web-app
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8080

In the above example, we annotationsspecify the type when creating the load balancer on Tencent Cloud by adding ExternalTraffic. This will use Tencent Cloud's load balancing service and forward traffic from the external load balancer to the Pod associated with the Service.

Example on Huawei Cloud:

apiVersion: v1
kind: Service
metadata:
  name: my-web-service
  annotations:
    service.beta.huawei.com/loadbalancer-type: "ExternalELB"
spec:
  type: LoadBalancer
  selector:
    app: my-web-app
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8080

In the above example, we annotationsspecify the type when creating the load balancer on Huawei Cloud by adding ExternalELB. This will use Huawei Cloud's elastic load balancing service and forward traffic from the external load balancer to the Pod associated with the Service.

Both examples are based on a Service of type LoadBalancer and use cloud provider-specific annotations to configure the load balancer type. Specific comments and setting options may vary depending on the cloud platform. Please refer to the documentation and requirements of the corresponding cloud platform for correct configuration.

Guess you like

Origin blog.csdn.net/qq_44370158/article/details/132289045