Exercise 4.2: Working with CPU and Memory Constraints
kubectl create deployment stress --image=vish/stresskubectl get pod -l app=stress \ -o=jsonpath='{.items[0]..spec.containers[0].resources}{"\n"}'kubectl get pod -l app=stress \ -o=jsonpath='{.items[0].status.qosClass}{"\n"}'kubectl get deploy stress -o yaml > stress.yaml.... containers: - image: vish/stress imagePullPolicy: Always name: stress resources: limits: memory: "4Gi" requests: memory: "2500Mi" terminationMessagePath: /dev/termination-log terminationMessagePolicy: File ....kubectl replace -f stress.yamlkubectl patch deploy stress \ --patch '{"spec":{"template":{"spec":{"containers":[{"name":"stress","image":"vish/stress","resources":{"limits":{"memory": "4Gi"},"requests":{"memory":"2500Mi"}}}]}}}}'kubectl get deployment stress \ -o=jsonpath='{.spec.template.spec.containers[0].resources}{"\n"}' | jqkubectl get pod -l app=stress \ -o=jsonpath='{.items[0].status.qosClass}{"\n"}'kubectl logs deploy/stresskubectl get pod -l app=stress -o widekubectl describe node $(kubectl get pod -l app=stress \ -o=jsonpath='{.items[0].spec.nodeName}')kubectl patch deploy stress --patch '{"spec":{"template":{"spec":{"containers":[{"name":"stress","image":"vish/stress","resources":{"limits":{"cpu":"0.5","memory":"4Gi"},"requests":{"cpu":"0.25","memory":"500Mi"}},"args":["-cpus","2","-mem-total","950Mi","-mem-alloc-size","100Mi","-mem-alloc-sleep","1s"]}]}}}}'.... resources: limits: cpu: "0.5" memory: "4Gi" requests: cpu: "0.25" memory: "500Mi" args: - -cpus - "2" - -mem-total - "950Mi" - -mem-alloc-size - "100Mi" - -mem-alloc-sleep - "1s" ....{ kubectl delete deployment stress kubectl create -f stress.yaml }kubectl get pod -l app=stress -o widekubectl delete deployment stress
Last updated