gpt4 book ai didi

Kubernetes 请求不平衡

转载 作者:行者123 更新时间:2023-12-05 03:47:22 25 4
gpt4 key购买 nike

我们的 kubernetes 集群的流量刚刚增加,我注意到在我们的 6 个应用程序 pod 中,其中 2 个似乎使用得不多。 kubectl top pods 返回以下内容

CPU usage

您可以看到在 6 个 pod 中,有 4 个使用了超过 50% 的 CPU(2 个 vCPU 节点),但其中两个根本没有做太多事情。

我们的集群是在 AWS 上设置的,使用 ALB 入口 Controller 。负载均衡器配置为使用最少未完成的请求,而不是Round robin,试图平衡更多,但我们仍然看到这种不平衡。

有什么方法可以确定为什么会发生这种情况,或者这是否确实是一个问题?我希望这是正常行为而不是问题,但我宁愿调查它。

应用部署配置

这是主要应用程序 pod 的配置。真的没什么特别的

apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "app.fullname" . }}
labels:
{{- include "app.labels" . | nindent 4 }}
app.kubernetes.io/component: web
spec:
replicas: {{ .Values.app.replicaCount }}
selector:
matchLabels:
app: {{ include "app.fullname" . }}-web

template:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/config_maps/app-env-vars.yaml") . | sha256sum }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 10 }}
{{- end }}
labels:
{{- include "app.selectorLabels" . | nindent 8 }}
app.kubernetes.io/component: web
app: {{ include "app.fullname" . }}-web
spec:
serviceAccountName: {{ .Values.serviceAccount.web }}
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app
operator: In
values:
- {{ include "app.fullname" . }}-web
topologyKey: failure-domain.beta.kubernetes.io/zone
containers:
- name: {{ .Values.image.name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- bundle
args: ["exec", "puma", "-p", "{{ .Values.app.containerPort }}"]
ports:
- name: http
containerPort: {{ .Values.app.containerPort }}
protocol: TCP
readinessProbe:
httpGet:
path: /healthcheck
port: {{ .Values.app.containerPort }}
scheme: HTTP
initialDelaySeconds: 10
periodSeconds: 5
timeoutSeconds: 5
resources:
{{- toYaml .Values.resources | nindent 12 }}
envFrom:
- configMapRef:
name: {{ include "app.fullname" . }}-cm-env-vars

- secretRef:
name: {{ include "app.fullname" . }}-secret-rails-master-key

- secretRef:
name: {{ include "app.fullname" . }}-secret-db-credentials

- secretRef:
name: {{ include "app.fullname" . }}-secret-db-url-app

- secretRef:
name: {{ include "app.fullname" . }}-secret-redis-credentials

最佳答案

这是 Kubernetes 的一个已知问题。
简而言之,Kubernetes 不会对长期存在的 TCP 连接进行负载平衡。
excellent article详细介绍。

您所服务的负载分布与案例完全一致。

关于Kubernetes 请求不平衡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64876107/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com