Error saying failed to get CPU consumption and request some pods do not have request for cpu

0 votes

I have a kubernetes cluster which works fine but for some reason, autoscaling doesn't work.

Here is a list of all the pods currently

[root@kube-master test] [dev] # kubectl get pods --all-namespaces
NAMESPACE        NAME                                  READY     STATUS    RESTARTS   AGE
default          my-nginx-8kmlz                        1/1       Running   0          11h
default          my-nginx-z8cxb                        1/1       Running   0          11h
kube-system      heapster-v10-vdc1v                    3/3       Running   0          11h
kube-system      kube-apiserver-10.122.0.20            1/1       Running   0          4d
kube-system      kube-controller-manager-10.122.0.20   1/1       Running   1          9h
kube-system      kube-dns-6iw3a                        4/4       Running   0          4d
kube-system      kube-proxy-10.122.0.20                1/1       Running   0          3d
kube-system      kube-proxy-10.122.42.163              1/1       Running   0          4d
kube-system      kube-proxy-10.122.43.138              1/1       Running   1          4d
kube-system      kube-scheduler-10.122.0.20            1/1       Running   1          4d

So heapster is running against my proxy and I can access

http://10.122.0.20:8080/api/v1/proxy/namespaces/kube-system/services/heapster/api/v1/model/namespaces/default/pods/my-nginx-8kmlz/stats

In my controller logs the only thing I really see is

W1224 18:27:43.425126       1 horizontal.go:185] Failed to reconcile my-nginx: failed to compute desired number of replicas based on CPU utilization for ReplicationController/default/my-nginx: failed to get cpu utilization: failed to get CPU consumption and request: some pods do not have request for cpu
Aug 31, 2018 in Kubernetes by lina
• 8,220 points

retagged Nov 12, 2018 by Omkar 1,112 views

1 answer to this question.

0 votes

You are missing a CPU request on your pods. You can confirm that by running the following command:

kubectl get dc $YOUR_DC -o yaml

In order to use the CPU autoscaling, you'll need to specify a CPU request under the resources section for your pod spec. For example

...
    spec:
      containers:
      - image: nginx
        name: nginx
        resources:
          requests:
            cpu: 400m
...
answered Aug 31, 2018 by Kalgi
• 52,350 points

Related Questions In Kubernetes

0 votes
1 answer

Is possible to have same k8s service for multiple pods?

Reserve a static IP and then assign ...READ MORE

answered Jul 20, 2018 in Kubernetes by Kalgi
• 52,350 points
3,148 views
0 votes
1 answer

Unable to get cgroup stats for docker and kubelet services

Try and start kubelet with the following ...READ MORE

answered Sep 3, 2018 in Kubernetes by DareDev
• 6,890 points
5,103 views
0 votes
1 answer

How do I create a service account for my dashboard and get all the credentails

Run the following commands: This command will create ...READ MORE

answered Oct 8, 2018 in Kubernetes by Kalgi
• 52,350 points
1,705 views
+1 vote
1 answer
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17, 2019 in Others by anonymous
15,456 views
0 votes
3 answers

Nginx reverse proxy URL getting rewritten

Hey @Gopi, try your ingress probably like ...READ MORE

answered Feb 12, 2019 in Kubernetes by Kalgi
• 52,350 points
4,712 views
+1 vote
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP