gpt4 book ai didi

docker - Kubernetes 自动缩放内存不起作用,但适用于 CPU

转载 作者:行者123 更新时间:2023-12-02 06:31:29 25 4
gpt4 key购买 nike

我使用的yaml如下所示

    apiVersion: v1
kind: Service
metadata:
name: xxx-svc
labels:
app: xxxxxx
spec:
type: NodePort
ports:
- port: 8080
selector:
app: xxxxxx
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-xxx
labels:
app: xxxxxx
spec:
selector:
matchLabels:
app: xxxxxx
template:
metadata:
labels:
app: xxxxxx
spec:
containers:
- name: xxxxxx
image: yyy/xxxxxx:latest
ports:
- containerPort: 8080
resources:
requests:
cpu: "100m"
memory: "504Mi"
limits:
cpu: "100m"
memory: "504Mi"
---
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: xxxxxx
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: my-xxx
minReplicas: 1
maxReplicas: 3
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50
- type: Resource
resource:
name: memory
target:
type: Value
averageValue: 500Mi

服务、HPA、部署一切都已成功部署,但是当我检查 hpa(kubectl get hpa)时,我得到的结果低于结果

NAME        REFERENCE              TARGETS                   MINPODS   
MAXPODS REPLICAS AGE

xxxxxx Deployment/my-xxx unknown/500Mi, 1%/50% 1 3 3 69m

我得到(kubectl描述hpa)的原因是

Warning FailedComputeMetricsReplicas 21m (x4 over 22m) horizontal-pod-autoscaler failed to get memory utilization: missing request for memory

内存未知但 CPU 正在工作的原因可能是什么

最佳答案

原因:

Warning FailedComputeMetricsReplicas 21m (x4 over 22m) horizontal-pod-autoscaler failed to get memory utilization: missing request for memory

Kubernetes HPA 默认情况下不适用于内存,您需要为内存创建自定义指标,然后使用它。我找到了一些额外的信息here人们如何尝试解决同样的问题。

Pod Memory Based AutoScaling

In this section, we are discussing how you can deploy autoscaling on the basis of memory that pods are consuming. We have used the command “kubectl top pod” to get the utilized pod memory and applied the logic.

  • Get the average pod memory of the running pods: Execute the script as follows:

关于docker - Kubernetes 自动缩放内存不起作用,但适用于 CPU,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53407841/

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