我们正在开发一个基于akka集群的应用程序,在Kubernetes集群中运行。我们现在的情况是,如果集群上的负载增加,我们希望应用程序能够扩展。我们正在使用HorizontalPodAutoscaler来实现这一目标。我们的清单文件看起来如下:
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: app
namespace: some-namespace
labels:
componentName: our-component
app: our-component
version: some-version
annotations:
prometheus.io/scrape: "true"
prometheus.io/path: "/metrics"
prometheus.io/port: "9252"
spec:
serviceName: our-component
replicas: 2
selector:
matchLabels:
componentName: our-component
app: our-app
updateStrategy:
type: RollingUpdate
template:
metadata:
labels:
componentName: our-component
app: our-app
spec:
containers:
- name: our-component-container
image: image-path
imagePullPolicy: Always
resources:
requests:
cpu: .1
memory: 500Mi
limits:
cpu: 1
memory: 1Gi
command:
- "/microservice/bin/our-component"
ports:
- name: remoting
containerPort: 8080
protocol: TCP
readinessProbe:
httpGet:
path: /ready
port: 9085
initialDelaySeconds: 40
periodSeconds: 30
failureThreshold: 3
timeoutSeconds: 30
livenessProbe:
httpGet:
path: /alive
port: 9085
initialDelaySeconds: 130
periodSeconds: 30
failureThreshold: 3
timeoutSeconds: 5
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: app-hpa
namespace: some-namespace
labels:
componentName: our-component
app: our-app
spec:
minReplicas: 2
maxReplicas: 8
scaleTargetRef:
apiVersion: apps/v1
kind: StatefulSet
name: our-component
targetCPUUtilizationPercentage: 75我们面临的问题是,一旦我们将应用程序部署到maxReplicas定义的应用程序中,即使应用程序上没有负载,它也会扩展。此外,应用程序似乎从未缩小。
在应用程序中遇到类似问题的人能否分享他们的经验,了解为什么会发生这种情况,以及他们是否能够解决这个问题?
发布于 2022-08-03 22:13:47
问题在于资源请求和限制。您已经将请求的CPU设置为"1“,而将限制设置为"0.1”。因此,正在发生的是,一旦你的吊舱运行,限制自然超过,自动标度启动,并继续扩大到最大数量的复制品。
您需要切换参数名,以便请求变为0.1,限制变为1.0。这样,您的吊舱将以0.1单位的CPU份额开始,一旦所有吊舱的平均使用率超过65%,您将得到更多的副本,如果使用率下降,您将有一个规模下降,正如预期的那样。
作为一个普遍的经验法则,请求小于限制,或者至少等于它。它不可能更高,因为您最终会有一个无限扩展的基础结构。
发布于 2022-08-10 19:38:41
我怀疑这只是因为您的CPU请求值如此之低。对于一个0.1的请求,任何时候都有超过10%的vCPU被Pod使用,它将创建新的Pod。启动活动可以轻松地使用超过0.1CPU。因此,即使是启动活动也足以迫使HBA产生更多的豆荚。但是这些新的豆荚被添加到集群中,所以有一致的活动。再一次,这可能会把所有的吊舱都推到平均0.1以上。
这对我来说有点令人惊讶,因为您可能认为空闲的应用程序会稳定在0.1vCPU以下,但是0.1vCPU非常小。
我会测试:
https://stackoverflow.com/questions/73227230
复制相似问题