前言
新增俩台node节点加进k8s集群。
初始化
安装依赖包
以下操作均在所有机器操作
1 | yum install -y epel-release conntrack ntpdate ntp ipvsadm ipset jq iptables curl sysstat libseccomp wget unzip net-tools fuse-devel fuse fuse-libs |
关闭防火墙
1 | systemctl stop firewalld |
关闭 swap 分区
1 | swapoff -a |
关闭 SELinux
1 | setenforce 0 |
加载内核并优化
1 | modprobe ip_vs_rr |
ntp
1 | ntpdate ntp1.aliyun.com |
创建相关目录
1 | mkdir -p /opt/k8s/{bin,work} /etc/{kubernetes,etcd}/cert |
操作
添加hosts
#在之前的master节点添加
1 | [root@test-master-1 ~]# echo "10.16.8.86 test-node-16" >>/etc/hosts |
新加的俩台节点加hosts
1 | cat >>/etc/hosts<<EOF |
分发秘钥等信息
master节点操作
1 | ssh-copy-id -i ~/.ssh/id_rsa.pub test-node-16 |
推送CA证书
1 | cd /etc/kubernetes/cert |
flannal部署
拷贝二进制文件
1 | cd /opt/k8s/work/flannel |
拷贝flanneld密钥
1 | ssh test-node-16 "mkdir -p /etc/flanneld/cert" |
拷贝flannel启动文件
1 | scp /etc/systemd/system/flanneld.service test-node-16:/etc/systemd/system/ |
Kubernetes Node 节点安装Docker
1 | yum install -y yum-utils \ |
创建配置文件
1 | mkdir -p /etc/docker/ |
修改docker启动配置文件
1 | vim /usr/lib/systemd/system/docker.service |
1 | systemctl daemon-reload && systemctl enable docker && systemctl restart docker |
安装kubelet
创建kubelet bootstrap kubeconfig文件
1 | #master节点操作 |
分发kubeconfig
1 | cd /opt/k8s/work |
查看kubeadm为各个节点创建的token
1 | kubeadm token list --kubeconfig ~/.kube/config |
创建和分发kubelet参数配置
1 | cd /opt/k8s/work |
拷贝kubelet启动文件和命令
1 | cd /opt/k8s/work |
启动kubelet
1 | cd /opt/k8s/work |
签注证书
1 | kubectl get csr | grep Pending | awk '{print $1}' | xargs kubectl certificate approve |
安装kube-proxy
推送kube-proxy二进制启动文件和kubeconfig文件
1 | cd /opt/k8s/work/ |
创建和分发kube-proxy配置文件
1 | cd /opt/k8s/work/ |
启动kube-proxy服务
1 | cd /opt/k8s/work |