Kubelet --cgroup-driver=systemd

 Cgroup driver


上面可以看到cgroup是通过一系列的文件来管控所有的资源分配的,包括创建了一个cgroup,同时将一个cgroup和这个进程进行关联,也就是将进程号echo到那个procs文件里面,同时修改cpu的quota来限制其使用的资源,这一整套都是cgroup的文件系统,cgroup本身可以有不同的driver。

  • SyStemd 驱动:(整个操作系统是使用了systemd cgroup driver,当使用kubernetes的时候,要将两者统一,如果其他进程是使用systemd拉起来的,systemd拉起来的那些进程就由systemd这套系统去管控的,docker拉起的进程是由cgroupfs这套系统去管控的,这就会出现同一套资源被两套系统网外分,当系统压力大的时候就会引发不必要的问题,所以kubernetes在启动的时候会做一些检查,在启动kubelet的时候,去判断docker使用了哪一个cgroup driver,如果docker本身不是使用systemd,那么它就会默认报错不启动)

当操作系统使用systemd作为init system时,初始化进程生成一个根cgroup目录结构并作为cgroup管理器。

systemd与cgroup紧密结合,并且为每个systemd unit分配cgroup。,

  • cgroupfs 驱动:

docker默认用cgroupfs作为cgroup驱动。

存在问题∶

  • 因此,在systemd作为init system的系统中,默认并存着两套groupdriver。
  • 这会似的系统中docker和kubelet管理的 进程被cgroupfs驱动管,而systemd拉起的服务由systemd驱动管,让cgroup管理混乱且容易在资源紧张时引发问题。

因此kubelet会默认--cgroup-driver=systemd,若运行时cgroup不一致时,kubelet会报错

所以在搭建kubrnetes集群的时候,你往往需要去修改docker本身的cgroup driver,那么kubelet才能够启动起来。

### Kubernetes Kubelet `ExecStart` Configuration and Parameters Explanation The `kubelet` service is a critical component of the Kubernetes architecture, running on each node to ensure containers are functioning as expected. The configuration for starting this service can be found within systemd’s unit file typically located at `/etc/systemd/system/kubelet.service.d/10-kubeadm.conf`. This file contains directives that define how the kubelet should start up. For configuring the `ExecStart`, one must understand its role in specifying the command line used when launching the process managed by the service definition[^1]. In context with kubernetes: - **Command Line Flags**: These flags provide necessary configurations such as where to find the API server (`--kubeapi-server`) or what cgroup driver to use (`--cgroup-driver`). Each flag serves specific purposes related either directly to operational aspects like logging level (`--v=2`) or indirectly through integration points between components. - **Environment Variables**: Environment variables set before invoking the binary allow dynamic adjustments without modifying static files every time there's a change needed; examples include setting paths for certificates or keys required during secure communications among cluster nodes. A typical snippet from an environment file might look something similar below which sets various options including but not limited to network plugin name(`KUBELET_NETWORK_PLUGIN=cni`), path to CNI config directory(`KUBELET_CNI_CONF_DIR=/etc/cni/net.d`). ```bash KUBELET_KUBECONFIG_ARGS="--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf" KUBELET_SYSTEM_PODS_ARGS="--cni-conf-dir=/etc/cni/net.d --cni-bin-dir=/opt/cni/bin" KUBELET_DNS_ARGS="--cluster-dns=10.96.0.10 --cluster-domain=cluster.local" KUBELET_AUTHORIZATION_ARGS="--authorization-mode=Webhook --client-ca-file=/etc/kubernetes/pki/ca.crt" KUBELET_ADMISSION_CONTROL_ARGS="--enable-admission-plugins=NodeRestriction" ``` In addition to these settings provided via environment variables, actual execution starts using following syntax inside `.service` file under `[Service]` section: ```ini ExecStart=/usr/local/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_SYSTEM_PODS_ARGS $KUBELET_NETWORK_ARGS $KUBELET_DNS_ARGS $KUBELET_AUTHORIZATION_ARGS $KUBELET_ADMISSION_CONTROL_ARGS ``` This approach allows administrators flexibility while maintaining consistency across deployments since changes only require updates to variable definitions rather than altering multiple instances manually throughout system configurations. --related questions-- 1. How does changing the value of `--cgroup-driver` affect container runtime compatibility? 2. What security implications arise from adjusting the `--authorization-mode` parameter? 3. Can you explain why it's important to correctly configure DNS arguments for proper pod communication within a Kubernetes cluster? 4. Under what circumstances would someone need to modify the admission control plugins enabled via `--enable-admission-plugins` option?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值