kubernetes kubeadm 初始化准备

文档说明: 只是记录关键点

k8s 版本 > 1.19

实验环境: linux debian 11

准备contianerd

apt install -y containerd.io

rm -rf /etc/containerd/config.toml
containerd config default | sudo tee /etc/containerd/config.toml
vi /etc/containerd/config.toml
SystemdCgroup = true


准备 ipset ipvsadm

apt  -y install ipset ipvsadm -y

sudo cat /sys/class/dmi/id/product_uuid
cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF

cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables  = 1
net.ipv6.conf.all.forwarding        = 1
net.ipv4.conf.all.forwarding        = 1
net.ipv4.ip_forward                 = 1
EOF
sudo sysctl --system
swapoff -a # 关闭swap缓存


准备kubelet kubeadm kubectl

#!/bin/bash
set -eux
set -o pipefail

__CURRENT__=`pwd`
__DIR__=$(cd "$(dirname "$0")";pwd)
cd ${__DIR__}


test -f /etc/apt/sources.list.d/kubernetes.list && rm -rf /etc/apt/sources.list.d/kubernetes.list

apt-get update -y  && apt-get install -y apt-transport-https sudo
apt install -y   ca-certificates  curl gnupg  gnupg2  gnupg1  lvm2  lsb-release apt-transport-https  curl

mkdir -p /etc/apt/keyrings/
test -f /etc/apt/keyrings/kubernetes-archive-keyring.gpg && rm -rf /etc/apt/keyrings/kubernetes-archive-keyring.gpg
curl -fsSL https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-archive-keyring.gpg

# 因为阿里云限速,下载很慢,所以换成中科大的镜像
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg] https://mirrors.ustc.edu.cn/kubernetes/apt/ kubernetes-xenial main" |  tee /etc/apt/sources.list.d/kubernetes.list

apt-get update -y
apt-get install -y kubelet kubeadm kubectl

# 锁定版本
# apt-mark hold kubelet kubeadm kubectl
# 安装指定版本也是可以的,如下
# apt-get install -y  kubelet=1.24.7-00 kubeadm=1.24.7-00 kubectl=1.24.7-00

参考文档

  1. install-kubectl-linux
  2. 容器运行时
  3. containerd
  4. kubernetes concepts

下一篇 kubernetes kubeadm 初始化

posted @ 2022-10-22 13:07  jingjingxyk  阅读(72)  评论(0编辑  收藏  举报