朋友们,我正在尝试按照k8s的hpa 教程实现 HPA,但出现以下错误:
ValidationError(HorizontalPodAutoscaler.status):在 io.k8s.api.autoscaling.v2beta2.HorizontalPodAutoscalerStatus 中缺少必填字段“条件”。
我找不到有关此字段“条件”的任何信息。有人知道我可能做错了什么吗?这是我的 HPA 的 YAML:
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: {{ .Values.name }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ .Values.name}}
minReplicas: {{ .Values.deployment.minReplicas }}
maxReplicas: {{ .Values.deployment.maxReplicas }}
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50
status:
observedGeneration: 1
lastScaleTime: <some-time>
currentReplicas: 2
desiredReplicas: 2
currentMetrics:
- type: Resource
resource:
name: cpu
current:
averageValue: 0
这里是我的部署清单:
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.name }}
spec:
replicas: {{ .Values.deployment.replicaCount }}
selector:
matchLabels:
app: {{ .Values.labels}}
template:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
labels:
app: {{ .Values.labels }}
spec:
initContainers:
- name: check-rabbitmq
image: {{ .Values.initContainers.image }}
command: ['sh', '-c',
'until wget http://$(RABBITMQ_DEFAULT_USER):$(RABBITMQ_DEFAULT_PASS)@rabbitmq:15672/api/aliveness-test/%2F;
do echo waiting; sleep 2; done;']
envFrom:
- configMapRef:
name: {{ .Values.name }}
- name: check-mysql
image: {{ .Values.initContainers.image }}
command: ['sh', '-c', 'until nslookup mysql-primary.default.svc.cluster.local; do echo waiting for mysql; sleep 2; done;']
containers:
- name: {{ .Values.name }}
image: {{ .Values.deployment.image }}
ports:
- containerPort: {{ .Values.ports.containerPort }}
resources:
limits:
cpu: 500m
requests:
cpu: 200m
envFrom:
- configMapRef:
name: {{ .Values.name }}