二进制安装kubelet
时间: 2023-10-05 09:04:32 浏览: 87
1. 首先下载二进制包:https://github.com/kubernetes/kubernetes/releases
2. 解压缩 `tar -zxvf kubernetes-server-linux-amd64.tar.gz`
3. 将 `kubelet` 文件复制到 `/usr/local/bin/` 目录下:`sudo cp kubernetes/server/bin/kubelet /usr/local/bin/`
4. 创建 `kubelet` 的配置文件 `/etc/kubernetes/kubelet`,内容如下:
```
apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration
address: 0.0.0.0
port: 10250
cgroupDriver: systemd
clusterDNS:
- 10.96.0.10
clusterDomain: cluster.local
```
5. 创建 `kubelet` 的 systemd unit 文件 `/etc/systemd/system/kubelet.service`,内容如下:
```
[Unit]
Description=kubelet: The Kubernetes Node Agent
Documentation=https://kubernetes.io/docs/
[Service]
ExecStart=/usr/local/bin/kubelet \
--config=/etc/kubernetes/kubelet \
--kubeconfig=/etc/kubernetes/kubelet.kubeconfig \
--bootstrap-kubeconfig=/etc/kubernetes/bootstrap.kubeconfig \
--cert-dir=/etc/kubernetes/pki \
--pod-manifest-path=/etc/kubernetes/manifests \
--cgroup-driver=systemd \
--rotate-certificates \
--allow-privileged=true \
--fail-swap-on=false \
--runtime-cgroups=/systemd/system.slice \
--kubelet-cgroups=/systemd/system.slice \
--feature-gates=RotateKubeletServerCertificate=true \
--feature-gates=RotateKubeletClientCertificate=true \
--eviction-hard=memory.available<300Mi,nodefs.available<10%,nodefs.inodesFree<5%,imagefs.available<10%,imagefs.inodesFree<5% \
--eviction-soft=memory.available<500Mi,nodefs.available<20%,nodefs.inodesFree<10%,imagefs.available<20%,imagefs.inodesFree<10%
Restart=always
StartLimitInterval=0
RestartSec=10
[Install]
WantedBy=multi-user.target
```
6. 启动 `kubelet`:`sudo systemctl enable kubelet && sudo systemctl start kubelet`
7. 检查 `kubelet` 是否正常工作:`sudo systemctl status kubelet`
阅读全文