kubernetes 资源需求、资源限制
来源:原创
时间:2019-01-23
作者:脚本小站
分类:云原生
Qos:
Guranteed:同时设置了CPU和memory 的request 和 limits,当资源不足时优先满足此类Pod的运行
Burstable:至少有一个容器设置了CPU或menory的 requests,属于中等优先级
BestEffort:没有一个容器设置了 requests 或 limits的属于最低优先级
使用kubectl describe pods <podname> 可以查看到,在 QoS Class 一栏。
apiVersion: v1 kind: Pod metadata: name: request-test namespace: default labels: app: myapp spec: containers: - name: myapp image: myapp:v1 imagePullPolicy: IfNotPresent resources: requests: # 最少有这么多资源才去运行这个Pod cpu: "500m" memory: "500Mi" limits: # 限制资源使用的最大值 cpu: "500m" memory: "500Mi"
磁盘限制:
apiVersion: v1 kind: Pod metadata: name: frontend spec: containers: - name: db image: mysql env: - name: MYSQL_ROOT_PASSWORD value: "password" resources: requests: ephemeral-storage: "2Gi" limits: ephemeral-storage: "4Gi" - name: wp image: wordpress resources: requests: ephemeral-storage: "2Gi" limits: ephemeral-storage: "4Gi"