1、环境配置
(1)添加主机名称解析记录
cat > /etc/hosts << EOF
192.168.44.200 master01 master01.bypass.cn
192.168.44.201 node01 node01.bypass.cn
192.168.44.202 node02 node02.bypass.cn
EOF
(2)禁止K8s使用虚拟内存
swapoff -a
sed -ri 's@(.*swap.*)@#\1@g' /etc/fstab
(3)开启内核ipv4转发
modprobe br_netfilter
cat > /etc/sysctl.d/k8s.conf << EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward=1
vm.swappiness=0
EOF
sysctl -p /etc/sysctl.d/k8s.conf
(4) 安装ipvsadm,加载ipvs模块
apt-get install ipset ipvsadm -y
cat > /etc/modules-load.d/ipvs.conf << EOF
ip_vs
ip_vs_rr
ip_vs_wrr
ip_vs_sh
nf_conntrack
EOF
加载模块,并进行检查
modprobe --all ip_vs ip_vs_rr ip_vs_wrr ip_vs_sh nf_conntrack
lsmod|grep -e ip_vs -e nf_conntrack
(5)时间同步
apt-get install chrony -y
systemctl start chrony
systemctl enable chrony
timedatectl set-timezone Asia/Shanghai
chronyc sources
2、部署集群
(1)安装Containerd
wget http://file.oldxu.net/cri-containerd-1.6.18-linux-amd64.tar.gz
tar xf cri-containerd-1.6.18-linux-amd64.tar.gz -C /
systemctl daemon-reload
systemctl start containerd
systemctl enable containerd
ctr version
mkdir -p /etc/containerd
containerd config default > /etc/containerd/config.toml
vi /etc/containerd/config.toml
修改内容
[plugins."io.containerd.grpc.v1.cri"]
sandbox_image = "registry.aliyuncs.com/google_containers/pause:3.9"
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
SystemdCgroup = true
[plugins."io.containerd.grpc.v1.cri".registry.mirrors]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
endpoint = ["https://kd88kykb.mirror.aliyuncs.com"]
测试
ctr image pull dokcer.io/library/nginx:1.20
(2)安装nerdctl
wget http://file.oldxu.net/nerdctl-1.2.1-linux-amd64.tar.gz
tar xf nerdctl-1.2.1-linux-amd64.tar.gz
mv nerdctl /usr/bin/
#ln -s /usr/bin/docker /usr/bin/nerdctl
#docker images
echo 'source <(nerdctl completion bash)' >> /etc/profile
source /etc/profile
nerdctl pull nginx:1.18
nerdctl images
(3)安装集群工具
curl https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main
EOF
apt update && apt-get install -y kubeadm=1.26.0-00 kubelet=1.26.0-00 kubectl=1.26.0-00
#下载容器镜像
kubeadm config images list --kubernetes-version v1.26.0
kubeadm config images pull --image-repository registry.aliyuncs.com/google_containers --kubernetes-version v1.26.0
(4)初始化Master节点
kubeadm init \
--apiserver-advertise-address=192.168.44.200 \
--control-plane-endpoint="master01.bypass.cn" \
--image-repository=registry.aliyuncs.com/google_containers \
--kubernetes-version=v1.26.0 \
--service-cidr=10.96.0.0/12 \
--pod-network-cidr=10.244.0.0/16 \
--cri-socket=/run/containerd/containerd.sock
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
(5) 初始化node节点
kubeadm join master01.bypass.cn:6443 --token ai9eru.bueon1ib9bhlf5rz \
--discovery-token-ca-cert-hash sha256:50c21633205d2d47d1c4e496a422e2c56018a5bc03d62849ff5c5ceb8456407f文章来源:https://www.toymoban.com/news/detail-698882.html
(6)安装Calico网络插件文章来源地址https://www.toymoban.com/news/detail-698882.html
https://docs.projectcalico.org/manifests/calico.yaml
vi calico.yaml # - name: CALICO_IPV4POOL_CIDR # value: "10.244.0.0/16"
kubectl apply -f calico.yaml
到了这里,关于Ubuntu 20.04 LTS 安装Kubernetes 1.26的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!