在 AWS EKS 上使用 NGINX 负载均衡器面临负载均衡问题

问题描述 投票:0回答:0

我正在 Amazon Elastic Kubernetes Service (Amazon EKS) 上部署一个 triton 推理服务器,并使用 Nginx 开源负载均衡器进行负载均衡。我们的 EKS 集群是私有的(EKS 节点位于私有子网中),因此没有人可以从外部世界访问它。

因为,triton 推理服务器具有三个端点:-

端口 8000:用于 HTTP 请求

端口 8001:用于 grpc 请求

8002 端口:Prometheus 指标服务器

首先,我在 AWS EKS 上为 Triton 创建了一个部署,并使用 clusterIP = None 公开它,以便所有副本端点都被 NGINX 负载均衡器公开和识别。

apiVersion: v1
kind: Service
metadata:
  name: triton
  labels:
    app: triton
spec:
  clusterIP: None
  ports:
     - protocol: TCP
       port: 8000
       name: http
       targetPort: 8000
     - protocol: TCP
       port: 8001
       name: grpc
       targetPort: 8001
     - protocol: TCP
       port: 8002
       name: metrics
       targetPort: 8002
  selector:
    app: triton

然后,我使用以下配置为 nginx 开源负载均衡器创建了一个映像。 EKS 节点上 NGINX 的配置文件位于 /etc/nginx/conf.d/nginx.conf.

resolver kube-dns.kube-system.svc.cluster.local valid=5s;
 upstream backend {
    zone upstream-backend 64k;
    server triton.default.svc.cluster.local:8000;
 }
  
 upstream backendgrpc {
    zone upstream-backend 64k;
    server triton.default.svc.cluster.local:8001;
 }
  
 server {
    listen 80;
    location / {
      proxy_pass http://backend/;
    }
 }
  
 server {
         listen 89 http2;
  
         location / {
             grpc_pass grpc://backendgrpc;
         }
 }
  
 server {
     listen 8080;
     root /usr/share/nginx/html;
     location = /dashboard.html { }
     location = / {
        return 302 /dashboard.html;
     }
 } 

Nginx 开源 LB 的 Dockerfile 是:-

FROM nginx
RUN rm /etc/nginx/conf.d/default.conf
COPY /etc/nginx/conf.d/nginx.conf /etc/nginx/conf.d/default.conf

我为 NGINX 创建了一个 ReplicationController。要从私有注册表中拉取镜像,Kubernetes 需要凭据。 配置文件中的 imagePullSecrets 字段指定 Kubernetes 应该从名为 ecr-cred 的 Secret 中获取凭证。

nginx-rc 文件看起来像:-

 apiVersion: v1
 kind: ReplicationController
 metadata:
   name: nginx-rc
 spec:
   replicas: 1
   selector:
     app: nginx
   template:
     metadata:
       labels:
         app: nginx
     spec:
       imagePullSecrets:
       - name: ecr-cred
       containers:
       - name: nginx
         command: [ "/bin/bash", "-c", "--" ]
         args: [ "nginx; while true; do sleep 30; done;" ]
         imagePullPolicy: IfNotPresent
         image: <Image URL with tag>
         ports:
           - name: http
             containerPort: 80
             hostPort: 8085
           - name: grpc
             containerPort: 89
             hostPort: 8087
           - name: http-alt
             containerPort: 8080
             hostPort: 8086
           - name: triton-svc
             containerPort: 8000
             hostPort: 32309

现在,我面临的问题是,当 pod 增加时,nginx 负载均衡器没有在这些新添加的 pod 之间进行负载平衡。

任何人都可以帮助我吗?

amazon-web-services nginx nvidia amazon-eks triton
© www.soinside.com 2019 - 2024. All rights reserved.