Kubernetes中没有发生负载平衡

时间:2020-10-29 04:59:49

标签: kubernetes load-balancing azure-aks

我最近开始学习Kubernetes,但遇到了问题。我正在尝试部署2个运行相同docker映像的Pod,以实现我提到的副本:deployment.yaml中的2个。我还提到了将服务作为LoadBalancer,并将外部流量策略作为群集。我通过执行kubectl describe服务确认了2个端点。会话持久性也设置为“无”。当我反复将请求发送到服务端口时,所有请求仅被路由到其中一个Pod,另一个仅位于其中。如何提高效率?或关于可能出问题的任何迹象?这是deploy.yaml文件 编辑:Only 1 pod handles all requests in Kubernetes cluster上提到的解决方案对我不起作用。

apiVersion: apps/v1
kind: Deployment
metadata:
  name: project-nameprodmstb
  labels:
    app: project-nameprodmstb
spec:
  replicas: 2
  selector:
    matchLabels:
      app: project-nameprodmstb
  template:
    metadata:
      labels:
        app: project-nameprodmstb
    spec:
      containers:
        - name: project-nameprodmstb
          image: <some_image>
          imagePullPolicy: Always
          resources:
            requests:
              cpu: "1024m"
              memory: "4096Mi"
      imagePullSecrets:
        - name: "gcr-json-key"
      
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
  minReadySeconds: 5

---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: project-nameprodmstb
  name: project-nameprodmstb 
  namespace: development
spec:
  ports:
  - name: project-nameprodmstb
    port: 8006
    protocol: TCP
    targetPort: 8006
  selector:
    app: project-nameprodmstb
  type: LoadBalancer

0 个答案:

没有答案