[英]Digitalocean kubernetes cluster load balancer doesn't work properly as round robin
I created a Digitalocean kube.netes cluster and create a service with 4 replicas.我创建了一个 Digitalocean kube.netes 集群并创建了一个有 4 个副本的服务。 the service type is LoadBalancer .
服务类型是LoadBalancer 。 the load balancer is also created.
还创建了负载平衡器。 but I posted my request to the target endpoint by using postman. and I have written the endpoint with the pod host name .
但我使用 postman 将我的请求发布到目标端点。我已经用 pod主机名编写了端点。 but every time I get the response from the same pod.
但每次我从同一个 pod 得到响应。 if the load is balanced by the load balancer, the requests should go to each and every pods.
如果负载由负载均衡器均衡,请求应该是 go 到每个 pod。 but is not happening as I expected.
但并没有像我预期的那样发生。 my manifest file like below.
我的清单文件如下。
apiVersion: apps/v1
kind: Deployment
metadata:
name: user-service-deployment
labels:
app: user-service
spec:
replicas: 3
selector:
matchLabels:
app: user-service
template:
metadata:
labels:
app: user-service
spec:
containers:
- name: user-service
image: myRepo/ms-user-service:1.0.1
ports:
- containerPort: 8080
env:
- name: SPRING_PROFILES_ACTIVE
value: proud
- name: MY_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
---
apiVersion: v1
kind: Service
metadata:
name: user-service
spec:
selector:
app: user-service
type: LoadBalancer
ports:
- protocol: TCP
port: 8080
targetPort: 8080
please resolve this problem.请解决这个问题。
you have to disable the keepalive feature (service.beta.kube.netes.io/do-loadbalancer-enable-backend-keepalive) when you create the service.创建服务时,您必须禁用 keepalive 功能(service.beta.kube.netes.io/do-loadbalancer-enable-backend-keepalive) 。 under the metadata.annotations you can configure it like the below.
在 metadata.annotations 下,您可以像下面这样配置它。 read for more detail.
阅读更多细节。
apiVersion: v1
kind: Service
metadata:
name: user-service
annotations:
service.beta.kubernetes.io/do-loadbalancer-enable-backend-keepalive: "false"
spec:
selector:
app: user-service
type: LoadBalancer
ports:
- protocol: TCP
port: 8080
targetPort: 8080
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.