• Kubernetes (三)资源预留


    一、kubernetes中的资源计算方式

    节点可为pod分配的资源计算方法:
    Node Allocatable Resource = Node Capacity(资源总大小) - Kube-reserved(kube组件保留资源) - system-reserved(系统保留资源) - eviction-threshold(用户设置的驱逐阈值)
     
    二、资源预留配置
    配置在kubelet服务
    1、硬驱逐阈值
    --eviction-hard=memory.available<500Mi,nodefs.available<1Gi,imagefs.available<100Gi
    当出现MemoryPressure时,Scheduler不会调度新的Best-Effort QoS Pods到此节点。
    当出现DiskPressure时,Scheduler不会调度任何新Pods到此节点。
     
    2、最小驱逐回收
    --eviction-minimum-reclaim="memory.available=500Mi,nodefs.available=500Mi,imagefs.available=2Gi"`
     
    3、驱逐等待时间
    --eviction-pressure-transition-period=20s
     
    4、节点状态更新间隔
    --node-status-update-frequency=10s
     
    5、设置预留系统服务的资源
    --system-reserved=cpu=200m,memory=1G
     
    6、用于配置为kube组件(kubelet,kube-proxy,dockerd等)预留的资源量
    --kube-reserved=cpu=200m,memory=1G
     
    三、调整实例
    # vim /usr/lib/systemd/system/kubelet.service
    [Unit]
    Description=Kubernetes Kubelet
    Documentation=https://github.com/GoogleCloudPlatform/kubernetes
    After=docker.service
    Requires=docker.service
    
    [Service]
    WorkingDirectory=/var/lib/kubelet
    ExecStart=/opt/kubernetes/bin/kubelet 
      --address=10.30.20.44 
      --hostname-override=10.30.20.44 
      --pod-infra-container-image=mirrorgooglecontainers/pause-amd64:3.0 
      --experimental-bootstrap-kubeconfig=/opt/kubernetes/cfg/bootstrap.kubeconfig 
      --kubeconfig=/opt/kubernetes/cfg/kubelet.kubeconfig 
      --cert-dir=/opt/kubernetes/ssl 
      --client-ca-file=/opt/kubernetes/ssl/ca.pem 
      --network-plugin=cni 
      --eviction-hard=memory.available<1600Mi,nodefs.available<5Gi,imagefs.available<5Gi 
      --eviction-minimum-reclaim=memory.available=2000Mi,nodefs.available=10Gi,imagefs.available=10Gi 
      --eviction-pressure-transition-period=20s 
      --node-status-update-frequency=10s 
      --system-reserved=cpu=200m,memory=1G 
      --kube-reserved=cpu=200m,memory=1G 
      --cni-conf-dir=/etc/cni/net.d 
      --cni-bin-dir=/opt/kubernetes/bin/cni 
      --cluster-dns=10.10.0.2 
      --cluster-domain=cluster.local. 
      --hairpin-mode hairpin-veth 
      --allow-privileged=true 
      --anonymous-auth=false 
      --fail-swap-on=false 
      --logtostderr=true 
      --v=2 
      --log-dir=/opt/kubernetes/log 
      --authentication-token-webhook
    Restart=on-failure
    RestartSec=5
    
    [Install]
    WantedBy=multi-user.target
    调整前,可分配内存:32841936Ki

    Capacity:
     cpu:                16
     ephemeral-storage:  20469Mi
     hugepages-1Gi:      0
     hugepages-2Mi:      0
     memory:             32944336Ki
     pods:               110
    Allocatable:
     cpu:                16
     ephemeral-storage:  19316971898
     hugepages-1Gi:      0
     hugepages-2Mi:      0
     memory:             32841936Ki
     pods:               110
    调整后,可分配内存:29352811Ki

    Capacity:
     cpu:                16
     ephemeral-storage:  20469Mi
     hugepages-1Gi:      0
     hugepages-2Mi:      0
     memory:             32944336Ki
     pods:               110
    Allocatable:
     cpu:                15600m
     ephemeral-storage:  15349Mi
     hugepages-1Gi:      0
     hugepages-2Mi:      0
     memory:             29352811Ki
     pods:               110

  • 相关阅读:
    开发工具IDEA
    了解java 的一角
    枚举类和Random
    字符串String和StringBuffer进行字符串拼接的发现
    java里的包装类
    String和StringBuffer的区别
    StringBuffer进行字符串拼接
    Hashmat
    第三单元作业总结
    第二单元作业总结
  • 原文地址:https://www.cnblogs.com/guoxianqi2020/p/14036487.html
Copyright © 2020-2023  润新知