I'm working on Google Kubernetes Engine on a single cluster. The cluster automatically scales the number of nodes. I have three created a Deployment and set up the auto-scaling policy using the website (Workloads -> Deployment -> Actions -> Auto-scaling), so not manually writing the YAML configuration. Based on an official guide, I did not make any mistake.
If you do not specify requests, you can autoscale based only on the absolute value of the resource's utilization, such as milliCPUs for CPU utilization.
The following is the full deployment 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
The problem is that the HPA does not see the metric (average CPU utilization), which is really strange (see image). HPA cannot read metric value
What I am missing?