• k8s cpu绑定


    一、开启cpu Manager
    # more /lib/systemd/system/kubelet.service 
      --cpu-manager-policy=static 
      --kube-reserved=cpu=200m,memory=1Gi,ephemeral-storage=1Gi 
      --system-reserved=cpu=200m,memory=1G 
    

      

    二、如何使用
    Pod 必须是 Guaranteed 的 QoS 类型
    Pod中该Container的Cpu request必须为整数CPUs
     
    三、实例
    # more deploy1.yaml 
    apiVersion: apps/v1 
    kind: Deployment
    metadata:
      name: nginx-deployment
    spec:
      selector:
        matchLabels:
          app: nginx
      replicas: 4
      template:
        metadata:
          labels:
            app: nginx
        spec:
          containers:
          - name: nginx
            image: nginx:1.7.9
            ports:
            - containerPort: 80
            resources:
              limits:
                memory: "200Mi"
                cpu: "2"
              requests:
                memory: "200Mi"
                cpu: "2"
     效果查看
    # docker ps|grep nginx
    7bead158cbf5        84581e99d807                             "nginx -g 'daemon of…"   27 seconds ago      Up 27 seconds                           k8s_nginx_nginx-deployment-c585c6cf8-22x5h_default_3babe9d2-e085-11eb-9b5a-fa163e1b0c2f_0
    ab63ab8d72b3        mirrorgooglecontainers/pause-amd64:3.0   "/pause"                 28 seconds ago      Up 27 seconds                           k8s_POD_nginx-deployment-c585c6cf8-22x5h_default_3babe9d2-e085-11eb-9b5a-fa163e1b0c2f_0
    # cd /sys/fs/cgroup/cpuset/kubepods/pod3babe9d2-e085-11eb-9b5a-fa163e1b0c2f/7bead158cbf532e325fc3c57afe77fda026b32b5eb0dc9ced509e2e3834df35f/
    # more cpuset.cpus 
    1-2 //绑定在cpu1-2
    # more cpuset.mems 
    0
    

      

    四、报错处理
    报错:configured policy "static" differs from state checkpoint policy "none"
    
    # kubectl get node
    NAME           STATUS   ROLES    AGE   VERSION
    10.30.20.106   Ready    <none>   8d    v1.14.4
    10.30.20.119   Ready    <none>   47h   v1.14.4
    10.30.20.129   Ready    <none>   8d    v1.14.4
    10.30.20.94    Ready    <none>   8d    v1.14.4
    
    # kubectl drain 10.30.20.94 --ignore-daemonsets
    # mv /var/lib/kubelet/cpu_manager_state /var/lib/kubelet/cpu_manager_state-old
    # kubectl uncordon minikube
    # kubectl uncordon 10.30.20.94
    node/10.30.20.94 uncordoned
    # systemctl daemon-reload
    # systemctl restart kubelet
    # systemctl status kubelet
    # more /var/lib/kubelet/cpu_manager_state-old
    {"policyName":"none","defaultCpuSet":"","checksum":3242152201}
    

    参考文档:

     

  • 相关阅读:
    男人要知道的40条忠告
    利用xtraBackup实现不停master服务做主从同步
    MY SQL 知识
    房价与阶级
    SQL Server数据库级别触发器
    mysql 5.7开启并行复制
    SQL Server 查出未提交事务(长事务)SQL
    开源数据集
    telnet
    Zend Studio使用综述
  • 原文地址:https://www.cnblogs.com/guoxianqi2020/p/14990958.html
Copyright © 2020-2023  润新知