<p>Is there any method of setting <strong>default</strong> QoS for all of the nodes from given namespace? Or just set QoS on namespace level instead of pod level.
I mean the situation where every existing and every newly created pod will have this default setting for given namespace.</p>

<p>Eg. All pods in namespace <code>kube-system</code> or <code>super-important</code> got QoS level "guaranted". </p>

<p>I want to set the QoS in such a way that in case of any problems with the resources pods from <code>kube-system</code> (or other important groups/namespaces), they be removed last, later than the less important ones.</p>

<p>P.S. I got advice about admission-controllers but i didn't see correlation to QoS.</p>

<p>It's possible. Some basic information about QoS:</p>
<blockquote>
<p>Kubernetes uses QoS classes to make decisions about scheduling and
evicting Pods.</p>
<h3>For a Pod to be given a QoS class of Guaranteed:</h3>
<ul>
<li>Every Container in the Pod must have a memory limit and a memory
request, and they must be the same.</li>
<li>Every Container in the Pod must
have a CPU limit and a CPU request, and they must be the same.</li>
</ul>
<h3>A Pod is given a QoS class of Burstable if:</h3>
<ul>
<li>The Pod does not meet the criteria for QoS class Guaranteed. At least
one Container in the Pod has a memory or CPU request.</li>
</ul>
<h3>For a Pod to be given a QoS class of BestEffort:</h3>
<ul>
<li>The Containers in the Pod must not have any memory or CPU limits or
requests.</li>
</ul>
</blockquote>
<p>Here is an example of how to set the Guaranteed QoS for all pods in the namespace qos-test.</p>
<p>Let's create a namespace qos-test:</p>
<pre><code>$ kubectl create namespace qos-test
</code></pre>
<p>Next, let's create a LimitRange object YAML file (CPU and Memory should be present, limits and requests should be the same):</p>
<pre><code>$ cat &lt;&lt;EOF &gt; limitRange.yaml
apiVersion: v1
kind: LimitRange
metadata:
  name: mem-limit-gua
spec:
  limits:
  - default:
      cpu: 100m
      memory: 512Mi
    defaultRequest:
      cpu: 100m
      memory: 256Mi
    type: Container
EOF
</code></pre>
<p>Then let’s apply it to the namespace qos-test:</p>
<pre><code>$ kubectl create -f limitRange.yaml --namespace=qos-test
</code></pre>
<p>Now, let's create a pod (CPU or Memory requests and limits must not be present in Pod spec):</p>
<pre><code>$ cat &lt;&lt;EOF &gt; default-pod.yaml
apiVersion: v1
kind: Pod
metadata:
  name: default-pod
spec:
  containers:
  - name: default-ctr
    image: nginx
EOF

$ kubectl create -f default-pod.yaml --namespace=qos-test
</code></pre>
<p>Finally, let's check what we've got:</p>
<pre><code>$ kubectl get namespaces
...
$ kubectl get limitrange --all-namespaces -o wide
...
$ kubectl get limitrange -o yaml -n qos-test
...
$ kubectl get pod default-pod -o yaml -n qos-test

apiVersion: v1
kind: Pod
metadata:
  ...
  name: default-pod
  namespace: qos-test
  ...
spec:
  containers:
  - image: nginx
    imagePullPolicy: Always
    name: default-ctr
    resources:
      limits:
        cpu: 100m
        memory: 256Mi
      requests:
        cpu: 100m
        memory: 256Mi
    ...
status:
  ...
  hostIP: 10.0.2.15
  phase: Running
  podIP: 172.17.0.10
  qosClass: Guaranteed
  ...
</code></pre>
<p>As you can see <code>default-pod</code> got the <code>qosClass: Guaranteed</code>.</p>
<p>To create pods with different QoS please refer to this part of documentation:</p>
<ul>
<li><a href="https://kubernetes.io/docs/tasks/configure-pod-container/quality-service-pod/" rel="nofollow noreferrer">Configure Quality of Service for Pods</a></li>
</ul>
<p>You can find more details about configuring default limits for a Namespace in this article:</p>
<ul>
<li><a href="https://kubernetes.io/docs/tasks/administer-cluster/manage-resources/memory-default-namespace/" rel="nofollow noreferrer">Configure Default Memory Requests and Limits for a Namespace</a></li>
</ul>
