k8s系列-12-离线二进制方式进行安装k8s
老板们,点个关注吧。
有些情况不支持你连接外网,那么这种情况下就不支持kubespray方式了,那如何安装kubenetes呢?下面我们再采用二进制的方式来进行安装下看看吧。
介绍
生产高可用
证书永不过期
不依赖第三方ansible等工具
采用本地代理,不依赖haproxy或者keepalived
深入学习的人
喜欢掌控每个组件的人
正在部署生产环境的人
环境
node-name | ip-address |
role |
node1 |
192.168.112.130 |
master、etcd |
node2 |
192.168.112.131 | master、worker、etcd |
node3 |
192.168.112.132 | worker、etcd |
配置主机名和路由
[ ]
node1
[ ]
[ ]
[ ]
192.168.112.130 node1
192.168.112.131 node2
192.168.112.132 node3
[ ]
安装依赖
# 更新yum源
[root@node1 ~]# yum update -y
# 下载依赖
[root@node1 ~]# yum install -y socat conntrack ipvsadm ipset jq sysstat curl iptables libseccomp yum-utils
策略调整
[ ]
[ ]
SELINUX=disabled
[ ]
[ ]
[ ]
[ ]
[ ]
[ ]
参数设置
[ ]
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_nonlocal_bind = 1
net.ipv4.ip_forward = 1
vm.swappiness = 0
vm.overcommit_memory = 1
[ ]
免密配置
[ ]
[ ]
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDImB4dg1iR14Ghmd6J2h2BhBxZi59NR3xgD3dXWn8i3VPpzydKhR5bw2Q8+gqQPGqUtGCWbjtf30KrMGm2idpf8GJu5caJVMSFoscSYbv9nv9UvNCEuyDSgmpoZSDBxNK9CxBSNSBCvyOcFrjGyEyrBBCyjFVH/T71hG9SUwvdR3E38Qyv7/npYmVaoLADvDDf9E1c6siQLe8jbhvz6fjXVXLFG00/+1p6qox8dvNKQK30D7rYB8NunqnMN4vDFarQSCRJ8u6x9yThqTV0j8G8pXX3YkmMbTJT7BqAjeF3fuDgoy57/s3CgjxPqKE09tqx2B9Qaj/Lud/8xCfQ2Xvr root@node1
[ ]
# 将上一步cat之后获取的信息进行分发
[root@node1 ~]# echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDImB4dg1iR14Ghmd6J2h2BhBxZi59NR3xgD3dXWn8i3VPpzydKhR5bw2Q8+gqQPGqUtGCWbjtf30KrMGm2idpf8GJu5caJVMSFoscSYbv9nv9UvNCEuyDSgmpoZSDBxNK9CxBSNSBCvyOcFrjGyEyrBBCyjFVH/T71hG9SUwvdR3E38Qyv7/npYmVaoLADvDDf9E1c6siQLe8jbhvz6fjXVXLFG00/+1p6qox8dvNKQK30D7rYB8NunqnMN4vDFarQSCRJ8u6x9yThqTV0j8G8pXX3YkmMbTJT7BqAjeF3fuDgoy57/s3CgjxPqKE09tqx2B9Qaj/Lud/8xCfQ2Xvr root@node1" >> ~/.ssh/authorized_keys
[root@node1 ~]#
软件包下载
软件包分发
上传到任一节点上,我这里上传的是node1节点。
[root@node1 ~]# pwd
/root
[root@node1 ~]# tar xf kubernetes-v1.20.2.tar.gz
[root@node1 ~]# cd kubernetes-v1.20.2/
[root@node1 kubernetes-v1.20.2]# ls
etcd-v3.4.10-linux-amd64.tar.gz kube-apiserver kube-controller-manager kubectl kubelet kube-proxy kube-scheduler
[root@node1 kubernetes-v1.20.2]# chmod +x kube*
# 分发master组件
[root@node1 kubernetes-v1.20.2]# MASTERS=(node1 node2)
[root@node1 kubernetes-v1.20.2]# for instance in ${MASTERS[@]}; do scp kube-apiserver kube-controller-manager kube-scheduler kubectl root@${instance}:/usr/local/bin/; done
# 分发worker组件
[root@node1 kubernetes-v1.20.2]# WORKERS=(node2 node3)
[root@node1 kubernetes-v1.20.2]# for instance in ${WORKERS[@]}; do scp kubelet kube-proxy root@${instance}:/usr/local/bin/; done
# 分发etcd组件
[root@node1 kubernetes-v1.20.2]# tar xf etcd-v3.4.10-linux-amd64.tar.gz
[root@node1 kubernetes-v1.20.2]# cd etcd-v3.4.10-linux-amd64/
[root@node1 etcd-v3.4.10-linux-amd64]# ETCDS=(node1 node2 node3)
[root@node1 etcd-v3.4.10-linux-amd64]# for instance in ${ETCDS[@]}; do scp etcd etcdctl root@${instance}:/usr/local/bin/; done
往期推荐
添加关注,带你高效运维