【发布时间】:2020-10-24 12:16:49
【问题描述】:
我正在单个集群上开发 Google Kubernetes Engine。 集群会自动扩展节点数量。 我已经创建了三个部署并使用网站设置了自动扩展策略(工作负载 -> 部署 -> 操作 -> 自动扩展),因此无需手动编写 YAML 配置。 基于官方guide,我没有犯任何错误。
如果您不指定请求,则可以仅基于 资源利用率的绝对值,例如 milliCPUs CPU 利用率。
以下是完整的部署 YAML:
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: student
name: student
namespace: ulibretto
spec:
replicas: 1
selector:
matchLabels:
app: student
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
app: student
spec:
containers:
- env:
- name: CLUSTER_HOST
valueFrom:
configMapKeyRef:
key: CLUSTER_HOST
name: shared-env-vars
- name: BIND_HOST
valueFrom:
configMapKeyRef:
key: BIND_HOST
name: shared-env-vars
- name: TOKEN_TIMEOUT
valueFrom:
configMapKeyRef:
key: TOKEN_TIMEOUT
name: shared-env-vars
image: gcr.io/ulibretto/github.com/ulibretto/studentservice
imagePullPolicy: IfNotPresent
name: studentservice-1
---
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
labels:
app: student
name: student-hpa-n3bp
namespace: ulibretto
spec:
maxReplicas: 100
metrics:
- resource:
name: cpu
targetAverageUtilization: 80
type: Resource
minReplicas: 1
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: student
---
apiVersion: v1
kind: Service
metadata:
annotations:
cloud.google.com/neg: '{"ingress":true}'
labels:
app: student
name: student-ingress
namespace: ulibretto
spec:
clusterIP: 10.44.5.59
ports:
- port: 5000
protocol: TCP
targetPort: 5000
selector:
app: student
sessionAffinity: None
type: ClusterIP
问题在于 HPA 没有看到指标(平均 CPU 利用率),这真的很奇怪(见图)。 HPA cannot read metric value
我错过了什么?
【问题讨论】:
标签: kubernetes yaml google-kubernetes-engine gcloud