初始化系统 所有服务器初始化节点,在之前部署k8s有提到,这里不做赘述,请参考 https://blog.csdn.net/weixin_43757555/article/details/108142265 初始化完成后关闭 NUMA
cp /etc/default/grub{,.bak} vim /etc/default/grub # 在 GRUB_CMDLINE_LINUX 一行添加 `numa=off` 参数,如下所示: < GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rhgb quiet" --- > GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rhgb quiet numa=off" cp /boot/grub2/grub.cfg{,.bak} grub2-mkconfig -o /boot/grub2/grub.cfg安装集群
kube-proxy开启ipvs的前置条件
modprobe br_netfilter vim /etc/sysconfig/modules/ipvs.modules #!/bin/bash modprobe -- ip_vs modprobe -- ip_vs_rr modprobe -- ip_vs_wrr modprobe -- ip_vs_sh modprobe -- nf_conntrack_ipv4 chmod 755 /etc/sysconfig/modules/ipvs.modules && bash /etc/sysconfig/modules/ipvs.modules && lsmod | grep -e ip_vs -e nf_conntrack_ipv4安装 Docker 软件
yum install -y yum-utils device-mapper-persistent-data lvm2 yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo yum update -y && yum install -y docker-ce mkdir /etc/docker vim /etc/docker/daemon.json { "exec-opts": ["native.cgroupdriver=systemd"], "log-driver": "json-file", "log-opts": { "max-size": "100m" } } mkdir -p /etc/systemd/system/docker.service.d systemctl daemon-reload && systemctl restart docker && systemctl enable docker在主节点启动 Haproxy 与 Keepalived 容器
mkdir -p /usr/local/kubernetes/install资料地址: 链接:https://pan.baidu.com/s/1cAT1qnuvqgvw63KSRoJXLQ 提取码:bxvi 上传hapoxy、keeplived、kubeadm包和start.keep包 导入kubeadm镜像 解压start.keep包,进入到cd data/lb
vim etc/haproxy.cfg 先只保留一个server rancher01 192.168.66.10:6443 Vim start-haproxy.sh 修改IP和端口6443 执行start-haproxy脚本 Ss -anpt|gree 6443 Vim start-keeplive.sh 修改VIP、网卡 执行脚本start-keeplive.shIfconfig查看一下VIP有没有生成
初始化节点
kubeadm config print init-defaults > kubeadm-config.yaml vim kubeadm-config.yaml localAPIEndpoint: advertiseAddress: 192.168.66.10 controlPlaneEndpoint: "192.168.66.10:6444 kubernetesVersion: v1.15.1 networking: podSubnet: "10.244.0.0/16" serviceSubnet: 10.96.0.0/12 --- apiVersion: kubeproxy.config.k8s.io/v1alpha1 kind: KubeProxyConfiguration featureGates: SupportIPVSProxyMode: true mode: ipvs 添加controlPlaneEndpoint:”vip地址” kubeadm init --config=kubeadm-config.yaml --experimental-upload-certs | tee kubeadm-init.log加入主节点以及其余工作节点 执行安装日志中的加入命令 3个主节点添加完成后,修改etc/haproxy.cfg,添加3个主结点server信息 rancher01 192.168.66.10:6443 删除haproxy节点信息重新生成
docker rm -f HAProxy-k8s && bash /data/lb/start-haproxy.sh将/data/lb/start-haproxy.sh文件拷到其它节点,执行删除重新添加
Etcd 集群状态查看
kubectl -n kube-system exec etcd-k8s-master01 -- etcdctl --endpoints=https://192.168.92.10:2379 --ca-file=/etc/kubernetes/pki/etcd/ca.crt --cert-file=/etc/kubernetes/pki/etcd/server.crt --key-file=/etc/kubernetes/pki/etcd/server.key cluster-health kubectl get endpoints kube-controller-manager --namespace=kube-system -o yaml kubectl get endpoints kube-scheduler --namespace=kube-system -o yaml部署网络
kubectl apply -f kube-flannel.yml自此高可用k8s集群已经部署完毕