zoukankan      html  css  js  c++  java
  • Docker中的Cgroup Driver:Cgroupfs 与 Systemd

    在安装kubernetes的过程中,会出现

    failed to create kubelet: misconfiguration: kubelet cgroup driver: "cgroupfs" is different from docker cgroup driver: "systemd"
    文件驱动默认由systemd改成cgroupfs, 而我们安装的docker使用的文件驱动是systemd, 造成不一致, 导致镜像无法启动

    docker info查看

    Cgroup Driver: systemd

    现在有两种方式, 一种是修改docker, 另一种是修改kubelet,

    修改docker:#
    修改或创建/etc/docker/daemon.json,加入下面的内容:

    {
    "exec-opts": ["native.cgroupdriver=systemd"]
    }
    重启docker:

    systemctl restart docker
    systemctl status docker
    修改kubelet:#
    vim /etc/systemd/system/kubelet.service.d/10-kubeadm.conf

    Note: This dropin only works with kubeadm and kubelet v1.11+

    [Service]
    Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf"
    Environment="KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml"

    This is a file that "kubeadm init" and "kubeadm join" generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically

    EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env

    This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use

    the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.

    EnvironmentFile=-/etc/sysconfig/kubelet
    ExecStart=
    ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS
    添加如下内容--cgroup-driver=systemd

    img

    或者:

    配置kubelet使用国内pause镜像

    配置kubelet的cgroups

    获取docker的cgroups

    $ DOCKER_CGROUPS=$(docker info | grep 'Cgroup' | cut -d' ' -f3)
    $ echo $DOCKER_CGROUPS

    $ cat >/etc/sysconfig/kubelet<<EOF
    KUBELET_CGROUP_ARGS="--cgroup-driver=$DOCKER_CGROUPS"
    KUBELET_EXTRA_ARGS="--pod-infra-container-image=registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.1"
    EOF

    启动

    $ systemctl daemon-reload
    $ systemctl enable kubelet && systemctl restart kubelet
    或者:

    DOCKER_CGROUPS=$(docker info | grep 'Cgroup' | cut -d' ' -f3)
    echo $DOCKER_CGROUPS
    cat >/etc/sysconfig/kubelet<<EOF
    KUBELET_EXTRA_ARGS="--cgroup-driver=$DOCKER_CGROUPS --pod-infra-container-image=registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.1"
    EOF

    启动

    $ systemctl daemon-reload
    $ systemctl enable kubelet && systemctl restart kubelet
    参考:#
    https://www.cnblogs.com/sparkdev/p/9523194.html

    https://www.jianshu.com/p/02dc13d2f651

  • 相关阅读:
    《linux 内核全然剖析》 笔记 CODE_SPACE 宏定义分析
    Item 8:析构函数不要抛出异常 Effective C++笔记
    Eclipse经常使用快捷键
    多人即时战斗游戏服务端系列[2]--90坦克Online游戏对象介绍以及渲染机制
    STM8S awu及看门狗IWDG WWDG应用(转)
    使用STM8SF103 ADC采样电压(转)
    BHS-STM32工具系列
    STM32 FLASH模拟EEPROM 使用和优化(转)
    STM32+NRF24L01无线(转)
    像51一样操作STM32的IO(转)
  • 原文地址:https://www.cnblogs.com/javalinux/p/14007344.html
Copyright © 2011-2022 走看看