部署 virtual-kubelet
克隆 virtual-kubelet CRI provider 到本地
git clone https://github.com/virtual-kubelet/cri.git
cd cri
make build && mv bin ../ && cd ..
复制 /etc/kubernetes/admin.conf 到 bin 下
创建客户端 CA 证书
openssl genrsa -out client.key 2048
openssl req -new -key client.key -subj "/CN=admin" -out client.csr
openssl x509 -req -in client.csr -CA /etc/kubernetes/pki/ca.crt -CAkey /etc/kubernetes/pki/ca.key -CAcreateserial -out client.crt -days 36500
- 将生成的 client.key 和 client.crt 文件保存在 /etc/kubernetes/pki 目录下
获取 kube-apiserver 访问 client 所用的证书
sudo mkdir /etc/virtual-kubelet
sudo mv client.key /etc/virtual-kubelet/client.key
sudo mv client.crt /etc/virtual-kubelet/client.crt
启动并部署 virtual-kubelet (在 cri bin 下)
#!/bin/bash
export VKUBELET_POD_IP=<IP of the Linux node>
export APISERVER_CERT_LOCATION="/etc/virtual-kubelet/client.crt"
export APISERVER_KEY_LOCATION="/etc/virtual-kubelet/client.key"
export KUBELET_PORT="10250"
cd bin
./virtual-kubelet --provider cri --kubeconfig admin.conf
部署完成后
kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s-master Ready control-plane,master 12d v1.23.0
virtual-kubelet Ready agent 2d15h v1.15.2-vk-cri-5dec3cb