问题描述
在VKE中创建负载均衡类型的service时报错:
The Service “xxx” is invalid: spec.ports: Invalid value: []core.ServicePort{core.ServicePort{Name:“53-tcp”, Protocol:“TCP”, AppProtocol:(*string)(nil), Port:53, TargetPort:intstr.IntOrString{Type:0, IntVal:53, StrVal:“”}, NodePort:30442}, core.ServicePort{Name:“53-udp”, Protocol:“UDP”, AppProtocol:(*string)(nil), Port:53, TargetPort:intstr.IntOrString{Type:0, IntVal:53, StrVal:“”}, NodePort:30441}}: may not contain more than 1 protocol whentype is ‘LoadBalancer’
问题分析
此问题是发生在VKE 1.20.x 的版本中,是因为负载均衡不支持在同一个lb实例中同时开放不同协议。
问题解决
可以通过修改kube-apiserver启动参数,在 feature-gates 中添加 MixedProtocolLBService 开启特性门控允许 LoadBalancer 类型的服务使用不同的协议。
cat /etc/kubernetes/manifests/kube-apiserver.yaml
...
- --feature-gates=MixedProtocolLBService=true
...
参考链接
[1] https://kubernetes.io/docs/concepts/services-networking/service/#load-balancers-with-mixed-protocol-types 如果您有其他问题,欢迎您联系火山引擎技术支持服务