童话述说我的结局

童话述说我的结局

一、Resource和Dashboard

1.1、Resource

因为K8S的最小操作单元是Pod,所以这里主要讨论的是Pod的资源

官网:https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/

Kubernetes的Resource和Dashboard(十三)-LMLPHP

 在K8S的集群中,Node节点的资源信息会上报给APIServer,可以通过下面两个属性设置cpu和内存大小

  • requests
  • limits

配置文件案例如下

 apiVersion: v1
 kind: Pod
 metadata:
 name: frontend
 spec:
 containers:
   - name: db
  image: mysql
  env:
     - name: MYSQL_ROOT_PASSWORD
    value: "password"
  resources:
    requests:
      memory: "64Mi"     # 表示64M需要内存
      cpu: "250m"        # 表示需要0.25核的CPU
    limits:
      memory: "128Mi"
      cpu: "500m"
   - name: wp
  image: wordpress
  resources:
    requests:
      memory: "64Mi"
      cpu: "250m"
    limits:
      memory: "128Mi"
      cpu: "500m"
01-29 07:16