简体   繁体   English

Digitalocean kube.netes 集群负载均衡器不能正常工作作为循环法

[英]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.

相关问题 如何在 Kubernetes 集群中使用 grpc-java 使 GRPC 的 round_robin 负载平衡工作? - How to get GRPC's round_robin load balancing to work using grpc-java in Kubernetes cluster? DigitalOcean上的Kubernetes外部负载均衡器服务 - Kubernetes External Load Balancer Service on DigitalOcean Kubernetes 集群的外部负载均衡器 - External Load Balancer for Kubernetes cluster 在 kubernetes 集群中的所有节点上调度 jenkins 从站(循环) - Schedule jenkins slaves across all nodes in kubernetes cluster (round robin) Kubernetes 负载均衡器终止 SSL 以反向代理入口 DigitalOcean - Kubernetes Load Balancer Terminating SSL to Reverse Proxy Ingress DigitalOcean 如何在 kube.netes.network 策略中将 digitalocean 负载均衡器列入白名单? - How to whitelist digitalocean load balancer in kubernetes network policy? 将流量从DigitalOcean负载均衡器转发到Kubernetes服务不起作用 - Forwarding traffic from a DigitalOcean Load Balancer to a Kubernetes Service not working 为Kubernetes HA集群选择AWS负载均衡器 - Choosing of AWS Load Balancer for Kubernetes HA cluster Kubernetes IaaS群集上的Azure负载均衡器 - Azure Load Balancer on Kubernetes IaaS Cluster 将外部http负载均衡器映射到Kubernetes集群 - Mapping an external http load balancer to a Kubernetes Cluster
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM