共计 2523 个字符,预计需要花费 7 分钟才能阅读完成。
背景
最近,我在虚拟机上通过 rpm 包安装了 k8s 集群。我想创建静态 Pod,那么就需要更改 kubelet 的启动参数。相关环境信息如下:
role | OS | IP | module |
---|---|---|---|
Master | CentOS7.2 | 10.1.2.182 | kube-apiserver kube-controller-manager kube-scheduler |
Node1 | Centos7.2 | 10.1.2.183 | kubelet kube-proxy |
Node2 | Centos7.2 | 10.1.2.184 | kubelet kube-proxy |
一、查看 kubelet 启动参数
k8s 组件是通过 systemctl 来管理的,因此可以在 /etc/systemd/system
或 /usr/lib/systemd/system 下查找相关配置文件
找到 kubelet 对应服务的配置文件目录
# cd /etc/systemd/system/kubelet.service.d/
查看原文件内容
# cat 10-kubeadm.conf
[Service]
Environment="KUBELET_KUBECONFIG_ARGS=--config=/etc/kubelet.d/ --kubeconfig=/etc/kubernetes/kubelet.conf --require-kubeconfig=true"
Environment="KUBELET_SYSTEM_PODS_ARGS=--pod-manifest-path=/etc/kubernetes/manifests --allow-privileged=true"
Environment="KUBELET_NETWORK_ARGS=--network-plugin=cni --cni-conf-dir=/etc/cni/net.d --cni-bin-dir=/opt/cni/bin"
Environment="KUBELET_DNS_ARGS=--cluster-dns=10.12.0.10 --cluster-domain=cluster.local"
Environment="KUBELET_EXTRA_ARGS=--v=4"
ExecStart=
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_SYSTEM_PODS_ARGS $KUBELET_NETWORK_ARGS $KUBELET_DNS_ARGS $KUBELET_EXTR
A_ARGS
查看 kubelet 的相关启动参数
# ps -ef | grep kubelet
/usr/bin/kubelet --kubeconfig=/etc/kubernetes/kubelet.conf --require-kubeconfig=true --pod-manifest-path=/etc/kubernetes/manifests --allow-privileged=true --network-plugin=cni --cni-conf-dir=/etc/cni/net.d --cni-bin-dir=/opt/cni/bin --cluster-dns=10.12.0.10 --cluster-domain=cluster.local --v=4
二、修改 kubelet 启动参数
添加一个新的参数 –config
# vim 10-kubeadm.conf
[Service]
Environment="KUBELET_KUBECONFIG_ARGS=--config=/etc/kubelet.d/ --kubeconfig=/etc/kubernetes/kubelet.conf --require-kubeconfig=true"
Environment="KUBELET_SYSTEM_PODS_ARGS=--pod-manifest-path=/etc/kubernetes/manifests --allow-privileged=true"
Environment="KUBELET_NETWORK_ARGS=--network-plugin=cni --cni-conf-dir=/etc/cni/net.d --cni-bin-dir=/opt/cni/bin"
Environment="KUBELET_DNS_ARGS=--cluster-dns=10.12.0.10 --cluster-domain=cluster.local"
Environment="KUBELET_EXTRA_ARGS=--v=4"
ExecStart=
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_SYSTEM_PODS_ARGS $KUBELET_NETWORK_ARGS $KUBELET_DNS_ARGS $KUBELET_EXTR
A_ARGS
执行如下命令使新增参数生效
# systemctl stop kubelet
# systemctl daemon-reload
# systemctl start kubelet
检查新增参数是否已经生效
# ps -ef | grep kubelet
/usr/bin/kubelet --config=/etc/kubelet.d/ --kubeconfig=/etc/kubernetes/kubelet.conf --require-kubeconfig=true --pod-manifest-path=/etc/kubernetes/manifests --allow-privileged=true --network-plugin=cni --cni-conf-dir=/etc/cni/net.d --cni-bin-dir=/opt/cni/bin --cluster-dns=10.12.0.10 --cluster-domain=cluster.local --v=4
同理,此方法也可添加 kubelet 其他启动参数。
本文永久更新链接地址 :http://www.linuxidc.com/Linux/2017-01/139667.htm
正文完
星哥说事-微信公众号
![post-qrcode](https://www.xgss.net/wp-content/uploads/2023/07/二维码-微信公众号256x256.jpg)