what is the default allocation when resources are not specified in kubernetes?

Viewed 333

Below is kubernetes POD definition

apiVersion: v1
kind: Pod
metadata:
  name: static-web
  labels:
    role: myrole
spec:
  containers:
    - name: web
      image: nginx
      ports:
        - name: web
          containerPort: 80
          protocol: TCP

as I have not specified the resources, how much Memory & CPU will be allocated? Is there a kubectl to find what is allocated for the POD?

2 Answers

If resources are not specified for the Pod, the Pod will be scheduled to any node and resources are not considered when choosing a node.

The Pod might be "terminated" if it uses more memory than available or get little CPU time as Pods with specified resources will be prioritized. It is a good practice to set resources for your Pods.

See Configure Quality of Service for Pods - your Pod will be classified as "Best Effort":

For a Pod to be given a QoS class of BestEffort, the Containers in the Pod must not have any memory or CPU limits or requests.

In your case, kubernetes will assign QoS called BestEffort to your pod. That's means kube-scheduler has no idea how to schedule your pod and just do its best.

That's also means your pod can consume any amount of resource(cpu/mem)it want (but the kubelet will evict it if anything goes wrong).

To see the resource cost of your pod, you can use kubectl top pod xxxx

Related