• 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

  • 相关阅读:
    程序员代码面试指南:IT名企算法与数据结构题目最优解
    经典排序算法
    Log4j输出格式控制--log4j的PatternLayout参数含义
    常用数据库4 mongodb
    常用数据库2 sqlite及SQL注入
    面试常问-数据库索引实现原理
    自定义web框架
    HTML|CSS之布局相关总结
    C++模板类练习题
    C++中的运算符重载练习题
  • 原文地址:https://www.cnblogs.com/guoxianqi2020/p/14036487.html
Copyright © 2020-2023  润新知