ELB Type |
Application scenario |
Whether to Support HTTP or HTTPS |
Description |
---|---|---|---|
Shared load balancer |
Interconnecting with an existing load balancer |
Yes |
None |
Automatically creating a load balancer |
Yes |
None |
|
Dedicated load balancer |
Interconnecting with an existing load balancer |
Yes (A YAML file is required.) |
|
Automatically creating a load balancer |
Yes (A YAML file is required.) |
|
If a Service is HTTP/HTTPS-compliant, add the following annotations:
The value of protocol-port must be the same as the port in the spec.ports field of the Service. The format is Protocol:Port. The port matches the one in the service.spec.ports field and is released as the corresponding protocol.
cert-id indicates the certificate ID in ELB certificate management. When https is configured for protocol-port, the certificate of the ELB listener will be set to the server certificate. When multiple HTTPS Services are released, they will use the same certificate.
The following is a configuration example for automatically creating a dedicated load balancer, in which key configurations are marked in red:
apiVersion: v1 kind: Service metadata: annotations: # Specify the Layer 4 and Layer 7 flavors in the parameters for automatically creating a load balancer. kubernetes.io/elb.autocreate: ' { "type": "public", "bandwidth_name": "cce-bandwidth-1634816602057", "bandwidth_chargemode": "traffic", "bandwidth_size": 5, "bandwidth_sharetype": "PER", "eip_type": "5_bgp", "available_zone": [ "" ], "l7_flavor_name": "L7_flavor.elb.s2.small", "l4_flavor_name": "L4_flavor.elb.s1.medium" }' kubernetes.io/elb.class: performance # Dedicated load balancer kubernetes.io/elb.protocol-port: "https:443,http:80" # HTTP/HTTPS and port number, which must be the same as the port numbers in spec.ports kubernetes.io/elb.cert-id: "17e3b4f4bc40471c86741dc3aa211379" # Certificate ID of the LoadBalancer Service labels: app: nginx name: test name: test namespace: default spec: ports: - name: cce-service-0 port: 443 protocol: TCP targetPort: 80 - name: cce-service-1 port: 80 protocol: TCP targetPort: 80 selector: app: nginx version: v1 sessionAffinity: None type: LoadBalancer
Use the preceding example configurations to create a Service. In the new ELB load balancer, you can see that the listeners on ports 443 and 80 are created.