Ubuntu部署kubeadm

实践目标

  • 安装kubeadm
  • 安装kubelet
  • 安装kubectl

本来打算按照极客时间的文章进行部署的,结果方法好像早就过时了,难蹦,但是还好有官方文档。

安装kubeadm

1.更新apt缓存并且安装必备软件包

1
2
3
sudo apt-get update
# apt-transport-https may be a dummy package; if so, you can skip that package
sudo apt-get install -y apt-transport-https ca-certificates curl gpg

2.下载kubernetes的公共签名密钥,全部共用所以可以忽略URL中的版本信息

1
2
3
# If the directory `/etc/apt/keyrings` does not exist, it should be created before the curl command, read the note below.
# sudo mkdir -p -m 755 /etc/apt/keyrings
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.29/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg

Note: In releases older than Debian 12 and Ubuntu 22.04, directory /etc/apt/keyrings does not exist by default, and it should be created before the curl command.

3.写入apt仓库

1
2
# This overwrites any existing configuration in /etc/apt/sources.list.d/kubernetes.list
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.29/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list

注意此举会覆盖原文件中的所有内容(如果有这个文件的话)

4.更新apt目录,安装kubelet,kubeadm和kubectl,然后锁定他们的版本

1
2
3
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl

5.(可选)kubelet跟随kubeadm启动

1
sudo systemctl enable --now kubelet

Ubuntu部署kubeadm
https://steammilk.com/2024/04/09/2024-all/k8s-kubuadm-deploy/
作者
蒸奶泡
发布于
2024年4月9日
更新于
2025年1月8日
许可协议