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

Time:09-22

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?

CodePudding user response:

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.

CodePudding user response:

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

That's also means your pod could consumer 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