Getting ready

There are two ways to set a Resource QoS: pod configuration or namespace configuration. If you set a Resource QoS to the Namespace, it will apply to all pods that belong to the same Namespace. If you set a Resource QoS to a pod, it will apply to the pod only. In addition, if you set it to both namespace and pod, it takes a value from the namespace configuration first, and then overwrite it with the pod configuration. Thus, we will set up two Namespaces, one which has a Resource QoS, and one that does not, to see how different they are:

  1. Create two namespaces by using the kubectl command as follows:
$ kubectl create namespace chap8-no-qos
namespace "chap8-no-qos" created

$ kubectl create namespace chap8-qos
namespace "chap8-qos" created
  1. Prepare a YAML file that sets spec.limits.defaultRequest.cpu: 0.1 as follows:
$ cat resource-request-cpu.yml
apiVersion: v1
kind: LimitRange
metadata:
name: resource-request-cpu
spec:
limits:
- defaultRequest:
cpu: 0.1
type: Container
  1. Do this by typing the kubectl command so that it applies to the chap8-qos namespace only:
$ kubectl create -f resource-request-cpu.yml --namespace=chap8-qos
limitrange "resource-request-cpu" created
  1. Check the resource limit on both chap8-qos and chap8-no-qos with the kubectl command:
//chap8-no-qos doesn't have any resource limits value
$ kubectl describe namespaces chap8-no-qos
Name: chap8-no-qos
Labels: <none>
Annotations: <none>
Status: Active
No resource quota.
No resource limits.


//chap8-qos namespace has a resource limits value
$ kubectl describe namespaces chap8-qos
Name: chap8-qos
Labels: <none>
Annotations: <none>
Status: Active
No resource quota.
Resource Limits
Type Resource Min Max Default Request Default Limit Max Limit/Request Ratio
---- -------- --- --- --------------- ------------- -----------------------
Container cpu - - 100m - -
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.38.253