<p>My version Kubernetes is 1.22</p>
<p>I'm taking a Kubernetes CKAD course.</p>
<p>In the resources and limits section it says:</p>
<blockquote>
<p>Let's now look at a container running on a node in the Docker world.</p>
<p>A Docker container has no limit to the resources it can consume on a node.</p>
<p>Say a container starts with one CPU on a node.</p>
<p>It can go up and consume as much resource as it requires suffocating the native processes on the node or other containers of resources.</p>
<p>However, you can set a limit for the resource usage on these parts by default.</p>
<p>Kubernetes sets a limit of one CPU to containers, so if you do not specify explicitly, a container will be limited to consume only one CPU from the node.</p>
<p>The same goes with memory.</p>
<p>By default, Kubernetes sets a limit of 512 Mi on containers.</p>
<p>If you don't like the default limits, you can change them by adding a limit section under the resources section in your file.</p>
<p>Specify new limits for the memory and CPU like this when the pod is created.</p>
</blockquote>
<p>I created podr nginx, in which I specified only reguest:</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  labels:
    run: nginx-test
  name: nginx-test
spec:
  containers:
  - image: nginx
    name: nginx-test
    resources:
      requests:
        memory: &quot;64Mi&quot;
        cpu: &quot;250m&quot;
  dnsPolicy: ClusterFirst
  restartPolicy: Always
</code></pre>
<p>After creating a pod, I saw that the CPU and RAM are unlimited:</p>
<pre><code>  Namespace                   Name                                                              CPU Requests  CPU Limits  Memory Requests  Memory Limits  Age
  ---------                   ----                                                              ------------  ----------  ---------------  -------------  ---
  only-test                   nginx-test                                                        250m (0%)     0 (0%)      64Mi (0%)        0 (0%)         8m33s

</code></pre>
<p>Maybe this is true for Docker? I am using Containerd.</p>

Maksim
<p>I figured it out. To use the default resources, you need to create LimitRange in a specific namespace.</p>
<p>Examples:</p>
<pre><code>apiVersion: v1
kind: LimitRange
metadata:
  name: mem-limit-range
spec:
  limits:
  - default:
      memory: 512Mi
    defaultRequest:
      memory: 256Mi
    type: Container
</code></pre>
<pre><code>apiVersion: v1
kind: LimitRange
metadata:
  name: cpu-limit-range
spec:
  limits:
  - default:
      cpu: 1
    defaultRequest:
      cpu: 0.5
    type: Container
</code></pre>
