Google Kubernetes Engine (GKE) CPU/pod

7/18/2018

On GKE I have created a cluster with 1 node and n1-standard-1 instance type (vCPU:1, RAM: 3.75 GB). The main purpose of the cluster is to host an application that has 3 pods (mysql, backend and frontend) on default namespace. I can deploy mysql with no problem. After that when I try to deploy the backend it just remains in "Pending" state saying that not enough CPU is available. The message is very verbose.

So my question is, is it not possible to have 3 pods running using 1 cpu unit? I want is reduce cost and let those pods use the same cpu. Is it possible to achieve that? If yes, then how?

-- Jahid Shohel
google-kubernetes-engine
kubernetes

2 Answers

7/19/2018

Yes, it is possible to have multiple pods, or 3 in your case, on a single CPU unit.
If you want to manage your memory resources, consider putting constraints such as those described in the official docs. Below is an example.

apiVersion: v1
kind: Pod
metadata:
  name: frontend
spec:
  containers:
  - name: db
    image: mysql
    env:
    - name: MYSQL_ROOT_PASSWORD
      value: "password"
    resources:
      requests:
        memory: "64Mi"
        cpu: "250m"
      limits:
        memory: "128Mi"
        cpu: "500m"

One would need more information regarding your deployment to answer your queries in a more detailer manner. Please consider providing the same.

-- Analytical Monk
Source: StackOverflow

7/19/2018

The error message "pending" is not that informative. Could you please run

kubectl get pods

and get your pod name and again run

kubectl describe pod {podname}

then you can get a idea about the error message.

By the way you can run 3 pods in a single cpu.

-- Sachith.Wanni
Source: StackOverflow