追风赶月莫停留,平芜尽处是春山。这篇文章主要讲述Ubuntu server22.04 ,kubernetes(k8s)1.24.0,congtainerd 1.6.4安装笔记相关的知识,希望能为你提供帮助。
闲来无事写个新版本的安装记录
ip规划
角色 | IP |
master1 | 192.168.0.221 |
node1 | 192.168.0.222 |
node2 | 192.168.0.223 |
node3 | 192.168.0.224 |
k8s-node-01 | 192.168.0.245 |
ntpdate time.windows.com
允许 iptables 检查桥接流量cat < < EOF | sudo tee /etc/modules-load.d/k8s.conf
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
EOF
sudo sysctl --system
Ubuntu 18.04 下关闭 swap 的操作关闭swapswapoff -a# 临时
sed -ri s/.*swap.*/#& / /etc/fstab# 永久
安装 Docker也可以参考其它过程安装apt-get install docker.io
如果需要配置为开机启动,可执行以下命令systemcd enable docker
systemcd start docker
配置docker加速器mkdir -p /etc/docker
tee /etc/docker/daemon.json < < -EOF
"registry-mirrors": ["https://1e60esib.mirror.aliyuncs.com"],
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts":
"max-size": "100m"
EOF
systemctl daemon-reload
systemctl restart docker
安装docker-ce ,containerd.io1 安装
削除旧的版本$ sudo apt-get remove docker docker-engine docker.io containerd runc
$sudo apt-get update
安装相关支持sudo apt-get install \\
apt-transport-https \\
ca-certificates \\
curl \\
gnupg \\
lsb-release
添加证书
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
$ echo \\
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \\
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
安装$ sudo apt-get update
$ sudo apt-get install containerd.io docker-ce docker-ce-cli
配置containerd
生成containerd默认配置文件mkdir -p /etc/containerd
containerd config default | sudo tee /etc/containerd/config.toml
修改配置文件sed -i s/SystemdCgroup = false/SystemdCgroup = true/ /etc/containerd/config.toml & & \\
grep SystemdCgroup -B 11 /etc/containerd/config.toml
老版本要手动追加这个参数SystemdCgroup = true显示内容[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
BinaryName = ""
CriuImagePath = ""
CriuPath = ""
CriuWorkPath = ""
IoGid = 0
IoUid = 0
NoNewKeyring = false
NoPivotRoot = false
Root = ""
ShimCgroup = ""
SystemdCgroup = true
配置容器镜像加速器sed -i s#endpoint = ""#endpoint = "https://xx4bwyg2.mirror.aliyuncs.com"#g /etc/containerd/config.toml & & \\
grep endpoint -B 5 /etc/containerd/config.toml
sed -i s#sandbox_image = "k8s.gcr.io/pause:*"#sandbox_image = "registry.aliyuncs.com/google_containers/pause:3.6"#g /etc/containerd/config.toml & & \\
grep sandbox_image /etc/containerd/config.toml
重启服务器加载配置systemctl daemon-reload
systemctl restart containerd.service
安装 K8S安装 K8S软件包更新 apt 包索引并安装使用 Kubernetes apt 仓库所需要的包:sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl
下载 Google Cloud 公开签名秘钥:
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
添加 Kubernetes apt 仓库:
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
阿里云源安装可以忽略上边的apt-get update & & apt-get install -y apt-transport-https
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 包索引,安装 kubelet、kubeadm 和 kubectl,并锁定其版本:apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl
部署Kubernetes Master6.1 创建kubeadm配置文件
导出默认初始化配置
kubeadm config print init-defaults > kubeadm-config.yaml
vi kubeadm-config.yaml
apiVersion: kubeadm.k8s.io/v1beta3
bootstrapTokens:
- groups:
- system:bootstrappers:kubeadm:default-node-token
ttl: 24h0m0s
usages:
- signing
- authentication
localAPIEndpoint:
advertiseAddress: 192.168.0.221
bindPort: 6443
nodeRegistration:
criSocket: /run/containerd/containerd.sock
imagePullPolicy: IfNotPresent
name: master
taints: null
apiServer:
timeoutForControlPlane: 4m0s
apiVersion: kubeadm.k8s.io/v1beta3
certificatesDir: /etc/kubernetes/pki
clusterName: kubernetes
controllerManager:
dns:
etcd:
local:
dataDir: /var/lib/etcd
imageRepository: registry.aliyuncs.com/google_containers
kind: ClusterConfiguration
kubernetesVersion: 1.24.0
networking:
dnsDomain: cluster.local
serviceSubnet: 10.96.0.0/12
scheduler:
在master1节点执行
kubeadm init --config kubeadm-init.yaml
#如何根据配置文件,列出和拉取镜像
kubeadm config images list --config kubeadm-config.yaml
kubeadm config images pull --config kubeadm-config.yaml
【Ubuntu server22.04 ,kubernetes(k8s)1.24.0,congtainerd 1.6.4安装笔记】不懂得可以留言,作者看到会回不过作者不怎么登陆这个玩意
推荐阅读
- 版本集成之SVN版本库同步工具:svnsync
- Nginx负载均衡中常见的算法及原理有哪些
- Nginx实现反向代理客户端IP透传
- 利用LNMP实现wordpress站点搭建
- 运维小白成长记——第十七周
- CentOS Stream 9 安装与设置的有关技巧
- 2022 年最佳 15 款网络监控工具
- 浅谈JUC工具CountDownLatch
- 华为防火墙GRE隧道配置