kubernetes基础知识:限制POD和容器运行的CPU、内存
限制运行内存
https://kubernetes.io/docs/tasks/configure-pod-container/assign-memory-resource/
先看一个pod的yaml文件(官方提供)
apiVersion: v1 kind: Pod metadata: name: memory-demo namespace: mem-example spec: containers: - name: memory-demo-ctr image: polinux/stress resources: limits: memory: "200Mi" requests: memory: "100Mi" command: ["stress"] args: ["--vm", "1", "--vm-bytes", "150M", "--vm-hang", "1"]
限制CPU
https://kubernetes.io/docs/tasks/configure-pod-container/assign-cpu-resource/
先来看个官方例子
apiVersion: v1 kind: Pod metadata: name: cpu-demo namespace: cpu-example spec: containers: - name: cpu-demo-ctr image: vish/stress resources: limits: cpu: "1" requests: cpu: "0.5" args: - -cpus - "2"