2
votes

For the sake of this question let's assume the following:

  • I have 12 CPU's total on my Kubernetes cluster
  • those 12 CPU's are spread across 3 nodes.
  • I am running a single pod on the cluster, without specifying any CPU resource information. In that case, the default of CPU requests is 100m I believe (10% of a single CPU).
  • the pod is in a deployment with replicas hardcoded to 1 and no autoscaling defined.

As I understand it, this means the single pod will only run on one of the 3 cluster nodes, as a single node can easily satisfy its request CPU. However, the pod "surprises" the cluster by starting to work on something very CPU intensive.

What would happen?

As no "limit" is set for the pod, will Kubernetes allow that pod to use more CPU on that single host node? up to what limit? the Node's CPU limit? some arbitrary default limit?

My question refers only to CPU resources, not memory.

1

1 Answers

3
votes

Each node has a maximum capacity for each of the resource types: the amount of CPU and memory it can provide for Pods so if it exceeds host limit it wil lbe terminated for sure.

If you do not specify a CPU limit for a Container, then one of these situations applies:

1) The Container has no upper bound on the CPU resources it can use. The Container could use all of the CPU resources available on the Node where it is running.

2) The Container is running in a namespace that has a default CPU limit, and the Container is automatically assigned the default limit. Cluster administrators can use a LimitRange to specify a default value for the CPU limit.

Describe command will give you all details about a worker node

$ kubectl describe nodes k8s-node01
Name:               k8s-node01
Roles:              <none>
Labels:             beta.kubernetes.io/arch=amd64

Taints:             <none>
Unschedulable:      false

Capacity:
  cpu:                4
  ephemeral-storage:  40593708Ki
  hugepages-1Gi:      0
  hugepages-2Mi:      0
  memory:             16432224Ki
  pods:               110
Allocatable:
  cpu:                4
  ephemeral-storage:  37411161231
  hugepages-1Gi:      0
  hugepages-2Mi:      0
  memory:             16329824Ki
  pods:               110
System Info:
  Machine ID:                 15b4b4728a454166acafff508d4022e8
  System UUID:                15B4B472-8A45-4166-ACAF-FF508D4022E8
  Boot ID:                    bf52803c-9123-49e2-967b-2585401f958f
  Kernel Version:             4.4.0-169-generic
  OS Image:                   Ubuntu 16.04.6 LTS
  Operating System:           linux
  Architecture:               amd64
  Container Runtime Version:  docker://19.3.4
  Kubelet Version:            v1.17.2
  Kube-Proxy Version:         v1.17.2
PodCIDR:                      192.168.1.0/24
PodCIDRs:                     192.168.1.0/24
Non-terminated Pods:          (3 in total)
  Namespace                   Name                 CPU Requests  CPU Limits  Memory Requests  Memory Limits  AGE
  ---------                   ----                 ------------  ----------  ---------------  -------------  ---
  kube-system                 calico-node-j45l6    250m (6%)     0 (0%)      0 (0%)           0 (0%)         7h1m
  kube-system                 kube-proxy-7w5fc     0 (0%)        0 (0%)      0 (0%)           0 (0%)         7h1m
  mynamespace                 nginx                0 (0%)        0 (0%)      0 (0%)           0 (0%)         33m
Allocated resources:
  (Total limits may be over 100 percent, i.e., overcommitted.)
  Resource           Requests   Limits
  --------           --------   ------
  cpu                250m (6%)  0 (0%)
  memory             0 (0%)     0 (0%)
  ephemeral-storage  0 (0%)     0 (0%)
Events:              <none>