kubeadm安装kubernates1.25集群并配置dashboard

一、Containerd配置(全节点)

1、如果已经安装docker,先卸载

apt-get remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine docker-ce containerd -y

2、如果服务器没有默认的docker源,首先配置源

sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.aliyun.com/docker-ce/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update

3、安装Containerd 

apt-get install containerd.io -y

4、配置Containerd的内核

cat <

5、创建Containerd的配置文件

sudo mkdir -p /etc/containerd
containerd config default | sudo tee /etc/containerd/config.toml

sed -i 's#SystemdCgroup = false#SystemdCgroup = true#g' /etc/containerd/config.toml
sed -i 's#k8s.gcr.io/pause#registry.cn-hangzhou.aliyuncs.com/google_containers/pause#g'  /etc/containerd/config.toml
sed -i 's#registry.gcr.io/pause#registry.cn-hangzhou.aliyuncs.com/google_containers/pause#g'  /etc/containerd/config.toml
sed -i 's#registry.k8s.io/pause#registry.cn-hangzhou.aliyuncs.com/google_containers/pause#g'  /etc/containerd/config.toml

6、启动containerd

systemctl daemon-reload
systemctl restart containerd
ctr plugin ls

二、配置国内源并安装 kubectl、kubeadm和kubelet(全节点)

# 添加apt-key
curl -s https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | sudo apt-key add -
# 添加源
echo "deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main" >/etc/apt/sources.list.d/kubernetes.list
#安装kubelet、kubeadm、kubectl
sudo apt-get update
sudo apt-get install -y kubelet=1.25.0-00 kubeadm=1.25.0-00 kubectl=1.25.0-00
sudo apt-mark hold kubelet kubeadm kubectl

三、集群初始化(全节点)

#关闭swap
swapoff -a
#永久关闭
vim /etc/fstab #注释自动挂载swapoff
#指定镜像
kubeadm config images pull \
--image-repository registry.cn-hangzhou.aliyuncs.com/google_containers --kubernetes-version 1.25.0

四、master节点初始化

安装日志中会有修改kubectl和node初始化的提示,按提示操作即可

kubeadm init --apiserver-advertise-address 192.168.127.128   --image-repository registry.cn-hangzhou.aliyuncs.com/google_containers --cri-socket "unix:///var/run/containerd/containerd.sock" --kubernetes-version 1.25.0

操作后有如下图提示,按照提示操作即可

kubeadm安装kubernates1.25集群并配置dashboard_第1张图片

 其中mkdir -p xxxx 和export xxxx 是将kubectl连接k8s用的,kubeadm join用于将node节点加入主节点使用

五、node节点初始化

kubeadm join 192.168.127.128:6443 --token gpevsm.tg1ttdvief4ao2ta     --discovery-token-ca-cert-hash sha256:4e193ae81e7f1f8762a03c7f541c2348a447b5b04993f274869c564fb63706ef

六、Addons安装

#创建calico.yaml
kubectl  create -f calico.yaml
#创建metrics-server.yaml
把/etc/kubernetes/pki/front-proxy-ca.crt复制到所有的Node节点
kubectl  create -f comp.yaml
#创建dashboard
kubectl create -f dashboard.yaml -f user.yaml
kubectl  create token admin-user -n kube-system

  yaml文件地址:https://download.csdn.net/download/qq_20948277/87755208

你可能感兴趣的:(kubernetes,容器,运维,kubernetes)