1.环境准备
    三台Oracle Linux7.9,机器信息如下:

    主机名 节点 操作系统 IP地址 所需组件
    k8s-master-67 主节点master OracleLinux7.9 192.168.2.67 etcd,kube-apiserver,kube-scheduler,kube-controller-manager,docker(看个人需要)
    k8s-node-68 从节点node1 OracleLinux7.9 192.168.2.68 kube-proxy,kubelet,docker
    k8s-node-69 从节点node2 OracleLinux7.9 192.168.2.69 kube-proxy,kubelet,docker

    2.三台机器都做如下操作
    (1)修改各自的hostname及hosts

    1. vi /etc/hostname
    2. k8s-master-67
    3. #k8s-node-68
    4. #k8s-node-69
    5. vi /etc/hosts
    6. 192.168.2.67 k8s-master-67
    7. 192.168.2.68 k8s-node-68
    8. 192.168.2.69 k8s-node-69

    (2)更新源,并添加epel-release源(为redhat系列操作系统提供额外的软件源)

    1. #更新系统
    2. yum update -y
    3. #安装额外的源
    4. yum -y install epel-release

    (3)设置系统

    1. #关闭防火墙
    2. systemctl stop firewalld
    3. #禁止开机自启动
    4. systemctl disable firewalld
    5. #禁用selinux
    6. #临时关闭
    7. setenforce 0
    8. #永久关闭
    9. sed -i 's/^SELINUX=enforcing$/SELINUX=disabled/' /etc/selinux/config
    10. #关闭swap
    11. swapoff -a
    12. #永久关闭
    13. vi /etc/fstab #注释掉最后一行关于swap的配置

    (4)安装额外软件

    1. yum -y install net-tools wget

    (5)安装epel源

    1. wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
    2. #重新生成缓存
    3. yum clean all
    4. yum makecache

    3.Master安装

    1. yum -y install etcd kubernetes-master

    systemctl enable kubelet

    1. kubeadm init --image-repository registry.aliyuncs.com/google_containers --kubernetes-version v1.23.5 --apiserver-advertise-address=192.168.2.67 --service-cidr=10.96.0.0/12 --pod-network-cidr=10.244.0.0/16 --ignore-preflight-errors=all

    docker停止所有容器:docker stop $(docker ps -aq)
    删除所有容器:docker rm $(docker ps -aq)
    删错所有镜像:docker rmi $(docker images -q)
    卸载组件:
    yum remove -y kubelet kubeadm kubectl
    安装组件:
    yum install -y kubelet kubeadm kubectl
    systemctl enable kubelet
    删除 /etc/kubernets
    /var/lib/etcd
    /var/lib/kubelet
    rm -rf /etc/kubernets
    rm -rf /var/lib/kubelet
    参考:
    https://www.cnblogs.com/f66666/p/9834835.html
    https://blog.csdn.net/weixin_42599091/article/details/107224263