title: Why memory usage is greater than what I set in Kubernetes's node?
body: <p>I allocated resource to 1 pod only with 650MB/30% of memory (with other built-in pods, limit memory is 69% only)</p>
  
  <p>However, when the pod handling process, the usage of pod is within 650MB but overall usage of node is 94%. </p>
  
  <p>Why does it happen because it supposed to have upper limit of 69%? Is it due to other built-in pods which did not set limit? How to prevent this as sometimes my pod with error if usage of Memory > 100%?</p>
  
  <p>My allocation setting (<code>kubectl describe nodes</code>):
  <a href="https://i.stack.imgur.com/tDoZ6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tDoZ6.png" alt="enter image description here"></a></p>
  
  <p>Memory usage of Kubernetes Node and Pod when idle:<br>
  <code>kubectl top nodes</code><br>
  <a href="https://i.stack.imgur.com/JtXgo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JtXgo.png" alt="enter image description here"></a><br>
  <code>kubectl top pods</code><br>
  <a href="https://i.stack.imgur.com/ijLHU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ijLHU.png" alt="enter image description here"></a></p>
  
  <p>Memory usage of Kubernetes Node and Pod when running task:<br>
  <code>kubectl top nodes</code><br>
  <a href="https://i.stack.imgur.com/phCZS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/phCZS.png" alt="enter image description here"></a><br>
  <code>kubectl top pods</code><br>
  <a href="https://i.stack.imgur.com/7Ja9B.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7Ja9B.png" alt="enter image description here"></a></p>
  
  <hr>
  
  <p><strong>Further Tested behaviour:</strong><br>
  1. Prepare deployment, pods and service under namespace <em>test-ns</em><br>
  2. Since only <em>kube-system</em> and <em>test-ns</em> have pods, so assign 1000Mi to each of them (from <code>kubectl describe nodes</code>) aimed to less than 2GB<br>
  3. Suppose memory used in <em>kube-system</em> and <em>test-ns</em> will be less than 2GB which is less than 100%, why memory usage can be 106%?  </p>
  
  <p>In <em>.yaml file:</em>  </p>
  
  <pre><code>    apiVersion: v1
      kind: LimitRange
      metadata:
        name: default-mem-limit
        namespace: test-ns
      spec:
        limits:
        - default:
            memory: 1000Mi
          type: Container
      ---
      apiVersion: v1
      kind: LimitRange
      metadata:
        name: default-mem-limit
        namespace: kube-system
      spec:
        limits:
        - default:
            memory: 1000Mi
          type: Container
      ---
      apiVersion: apps/v1
      kind: Deployment
      metadata:
        name: devops-deployment
        namespace: test-ns
        labels:
          app: devops-pdf
      spec:
        selector:
          matchLabels:
            app: devops-pdf
        replicas: 2
        template:
          metadata:
            labels:
              app: devops-pdf
          spec:
            containers:
            - name: devops-pdf
              image: dev.azurecr.io/devops-pdf:latest
              imagePullPolicy: Always
              ports:
              - containerPort: 3000
              resources:
                requests:
                  cpu: 600m
                  memory: 500Mi
                limits:
                  cpu: 600m
                  memory: 500Mi
            imagePullSecrets:
            - name: regcred
      ---
      apiVersion: v1
      kind: Service
      metadata:
        name: devops-pdf
        namespace: test-ns
      spec:
        type: LoadBalancer
        ports:
        - port: 8007
        selector:
          app: devops-pdf
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/mjIKA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mjIKA.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/EGqCs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EGqCs.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/BXpEe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BXpEe.png" alt="enter image description here"></a></p>