The yaml I used is shown below
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
Service, HPA, Deployment everything deployed successfully, but when I check hpa (kubectl get hpa) I am getting below result
NAME REFERENCE TARGETS MINPODS
MAXPODS REPLICAS AGE
xxxxxx Deployment/my-xxx unknown/500Mi, 1%/50% 1 3 3 69m
The reason I got (kubectl describe hpa) is
Warning FailedComputeMetricsReplicas 21m (x4 over 22m) horizontal-pod-autoscaler failed to get memory utilization: missing request for memory
What might be the reason that memory is Unknown but CPU is working