Change:
```console $ kubectl run nginx --image=nginx --replicas=1 --namespace=limit-example <del> CONTROLLER   CONTAINER(S)   IMAGE(S)   SELECTOR    REPLICAS nginx        nginx          nginx      run=nginx   1 </del> <ins> replicationcontroller "nginx" created </ins> $ kubectl get pods --namespace=limit-example <del> POD           IP           CONTAINER(S)   IMAGE(S)   HOST          LABELS      STATUS    CREATED          MESSAGE nginx-ykj4j   10.246.1.3                             10.245.1.3/   run=nginx   Running   About a minute nginx          nginx                                Running   54 seconds $ kubectl get pods nginx-ykj4j --namespace=limit-example -o yaml | grep resources -C 5 </del> <ins> NAME          READY     STATUS    RESTARTS   AGE nginx-aq0mf   1/1       Running   0          35s $ kubectl get pods nginx-aq0mf --namespace=limit-example -o yaml | grep resources -C 8 </ins> ``` ```yaml <ins> resourceVersion: "127" selfLink: /api/v1/namespaces/limit-example/pods/nginx-aq0mf uid: 51be42a7-7156-11e5-9921-286ed488f785 spec: </ins> containers: <del> - capabilities: {} image: nginx </del> <ins> - image: nginx </ins> imagePullPolicy: IfNotPresent name: nginx resources: limits: <del> cpu: 250m </del> <ins> cpu: 300m memory: 200Mi requests: cpu: 200m </ins> memory: 100Mi terminationMessagePath: /dev/termination-log volumeMounts: ``` <del> Note that our nginx container has picked up the namespace default cpu and memory resource limits. </del> <ins> Note that our nginx container has picked up the namespace default cpu and memory resource *limits* and *requests*. </ins> Let's create a pod that exceeds our allowed limits by having it have a container that requests 3 cpu cores. ```console $ kubectl create -f docs/admin/limitrange/invalid-pod.yaml --namespace=limit-example <del> Error from server: Pod "invalid-pod" is forbidden: Maximum CPU usage per pod is 2, but requested 3 </del> <ins> Error from server: error when creating "docs/admin/limitrange/invalid-pod.yaml": Pod "invalid-pod" is forbidden: [Maximum cpu usage per Pod is 2, but limit is 3., Maximum cpu usage per Container is 2, but limit is 3.] </ins> ``` Let's create a pod that falls within the allowed limit boundaries. ```console $ kubectl create -f docs/admin/limitrange/valid-pod.yaml --namespace=limit-example <del> pods/valid-pod $ kubectl get pods valid-pod --namespace=limit-example -o yaml | grep -C 5 resources </del> <ins> pod "valid-pod" created $ kubectl get pods valid-pod --namespace=limit-example -o yaml | grep -C 6 resources </ins> ``` ```yaml <ins> uid: 162a12aa-7157-11e5-9921-286ed488f785 spec: </ins> containers: <del> - capabilities: {} image: gcr.io/google_containers/serve_hostname </del> <ins> - image: gcr.io/google_containers/serve_hostname </ins> imagePullPolicy: IfNotPresent <del> name: nginx </del> <ins> name: kubernetes-serve-hostname </ins> resources: limits: cpu: "1" memory: 512Mi <del> securityContext: capabilities: {} </del> <ins> requests: cpu: "1" memory: 512Mi </ins> ``` <del> Note that this pod specifies explicit resource limits so it did not pick up the namespace default values. </del> <ins> Note that this pod specifies explicit resource *limits* and *requests* so it did not pick up the namespace default values. Note: The *limits* for CPU resource are not enforced in the default Kubernetes setup on the physical node that runs the container unless the administrator deploys the kubelet with the folllowing flag: ``` $ kubelet --help Usage of kubelet .... --cpu-cfs-quota[=false]: Enable CPU CFS quota enforcement for containers that specify CPU limits $ kubelet --cpu-cfs-quota=true ... ``` </ins> Step 4: Cleanup ----------------------------

Discussion:
Since resource QoS is implemented, limitrange also supports request constraint, we can add an example for that.
cc