Kubernetes Resource Qoutas

配置参数:

  • spec.containers[].resources.limits.cpu
  • spec.containers[].resources.limits.memory
  • spec.containers[].resources.requests.cpu
  • spec.containers[].resources.requests.memory

限制Pod CPU和Memory

apiVersion: apps/v1
kind: Deployment
metadata:
  name: tomcat
spec:
  replicas: 3
  selector:
    matchLabels:
      name: tomcat
  template:
    metadata:
      labels:
        name: tomcat
    spec:
      containers:
      - name: tomcat
        image: kubeguide/tomcat-app:v1
        ports:
        - containerPort: 8080
        env:
        - name: MYSQL_SERVICE_HOST
          value: "mysql"
        - name: MYSQL_SERVICE_PORT
          value: "3306"
        resources:
          requests:
            # 内存没什么好解释的, 单位 Mi Gi
             memory: 64Mi
            # 千分之一的CPU配额为最小单位,用m来表示,100m表示占用0.1个cpu.
             cpu: 250m
          limits:
            memory: 128Mi
            cpu: 500m

 

更多详细说明:

https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#extended-resources

https://kubernetes.io/docs/concepts/policy/resource-quotas/#viewing-and-setting-quotas

posted @ 2018-08-28 08:14  Vincen_shen  阅读(218)  评论(0编辑  收藏  举报