英文:
How can I configure traffic balancing for a service using Istio?
问题
我们使用一个无头服务来平衡流量,但程序员不喜欢这个选项。安装了istio,我阅读了文档,但我的眼睛睁得很大。
现在的任务是:
将流量平衡到服务上,在我的情况下是:results-service2.predprod.svc.cluster.local
我理解正确吗,只需创建一个DestinationRule
,所有流入的流量都将使用LEAST_CONN
平衡算法在副本之间平衡到results-service2.predprod.svc.cluster.local
吗?
在我的情况下:
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: results-load-balancer
spec:
host: results-service2.predprod.svc.cluster.local
trafficPolicy:
loadBalancer:
simple: LEAST_CONN
英文:
We use a headless service to balance traffic, but progers do not like this option. Installed istio, I read the documentation, but my eyes run wide.
Now the task is:
Balance traffic to the service, in my case: results-service2.predprod.svc.cluster.local
Do I understand correctly that it is enough for me to create a DestinationRule
and all incoming traffic to results-service2.predprod.svc.cluster.local
will be balanced on replicas using the LEAST_CONN
balancing algorithm?
In my case:
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: results-load-balancer
spec:
host: results-service2.predprod.svc.cluster.local
trafficPolicy:
loadBalancer:
simple: LEAST_CONN
答案1
得分: 1
Istio目标规则用于定义服务的负载均衡算法。默认情况下,Istio使用"LEAST_REQUEST"作为负载均衡算法。"LEAST_CONN"是已弃用的算法。更多详情请参考istio文档。如果您想要将负载均衡算法更改为"ROUND_ROBIN"或另一种支持的方法,可以按照以下示例进行操作:
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: configure-client-mtls-dr-with-workloadselector
spec:
host: example.com
workloadSelector:
matchLabels:
app: ratings
trafficPolicy:
loadBalancer:
simple: ROUND_ROBIN
英文:
Istio destination rule is place to define service load balancing algorithm. By default istio uses "LEAST_REQUEST" as LB algorithm. "LEAST_CONN" is deprecated algorithm. More details are mentioned in istio documentation. If you would like to change LB algorithm to "ROUND_ROBIN" or another supported methon this can be done as per below sample
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: configure-client-mtls-dr-with-workloadselector
spec:
host: example.com
workloadSelector:
matchLabels:
app: ratings
trafficPolicy:
loadBalancer:
simple: ROUND_ROBIN
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论