通过Service YAML文件中的Annotation(注解),可以实现丰富的负载均衡功能。本文从ELB、监听和后端服务器组三种资源维度介绍通过注解可以对ELB进行的常见配置操作。
注解使用说明
l 注解的内容是区分大小写。
l annotations字段格式 service.beta.kubernetes.io/xxx
ELB
ELB的典型操作
l 指定负载均衡的规格
apiVersion: v1 kind: Service metadata: annotations: service.beta.kubernetes.io/ctyun-loadbalancer-spec: "${负载均衡的规格ID}" name: nginx namespace: default spec: ports: - port: 443 protocol: TCP targetPort: 443 selector: name: nginx type: LoadBalancer |
l 使用一个已有的负载均衡
apiVersion: v1 kind: Service metadata: annotations: service.beta.kubernetes.io/ctyun-loadbalancer-id: "${负载均衡ID}" name: nginx namespace: default spec: ports: - port: 443 protocol: TCP targetPort: 443 selector: name: nginx type: LoadBalancer |
常用注解
l ELB常用注解
注解 | 类型 | 描述 | 默认值 | 支持的CCM版本 |
service.beta.kubernetes.io/ctyun-loadbalancer-address-type | String | 创建公网类型或者私网类型的ELB,取值可以是 internet或者 intranet | intranet | v1.0.0及以上 |
service.beta.kubernetes.io/ctyun-loadbalancer-id | String | 指定已有负载均衡实例的 ID。 删除 service 时该 ELB 不会被删除。 | 无 | v1.0.0及以上 |
service.beta.kubernetes.io/ctyun-loadbalancer-spec | String | 负载均衡的规格 | 无 | v1.0.0及以上 |
service.beta.kubernetes.io/ctyun-loadbalancer-resource-pack-id | String | 开通ELB所使用的资源包ID | 无 | v1.0.0及以上 |