k8s 1.5.2 安装脚本

Posted zhangb8042

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了k8s 1.5.2 安装脚本相关的知识,希望对你有一定的参考价值。

技术分享图片
 1 #!/bin/bash
 2 export RED=\E[1;31m
 3 export RES=\E[0m
 4 export GRN=\E[1;32m
 5 master_input=`echo  -e " ${RED} 输入master主机ip  ${RES}"`
 6 #node_input=`echo  -e "${GRN} 输入第${i}node主机ip ${RES}"`
 7 node_number=`echo  -e "${GRN} 输入node的数量 ${RES}"`
 8 
 9 echo  -e " ${RED} 开始安装master端  ${RES}"
10 read -p "$node_number" num
11 if [ -z `echo ${num}|sed "s/[0-9]//g"` ];then 
12     echo "${RED} ${num}台node ${RES}"
13     for ((i=1;i<=$num;i++));do export  node_input=`echo  -e "${GRN} 输入第${i}node主机ip ${RES}"`;read -p "$node_input" node$i_ip;done
14 else
15     echo -e " ${RED} 输入有误!!${RES}"
16     exit 1
17 fi
18 
19 hostname master
20 echo "`ip a s eth0|awk -F ‘[ /]+‘ ‘NR==3{print $3}‘` master " >>/etc/hosts
21 for ((i=1;i<=$num;i++));do  echo "$node$i_ip   node$i" >>/etc/hosts;done
22 
23 cat >>/etc/yum.repos.d/virt7-docker-common-release.repo<<EOF
24 [virt7-docker-common-release]
25 name=virt7-docker-common-release
26 baseurl=http://cbs.centos.org/repos/virt7-docker-common-release/x86_64/os/
27 gpgcheck=0
28 EOF
29 
30 yum -y install --enablerepo=virt7-docker-common-release kubernetes etcd flannel
31 
32 sed -ri.bak s#(--master=http://)(.*)(:8080)#\1master\3#g /etc/kubernetes/config 
33 sed -i.bak s#--insecure-bind-address=127.0.0.1#--insecure-bind-address=0.0.0.0#g /etc/kubernetes/apiserver
34 sed s#,ServiceAccount##g /etc/kubernetes/apiserver
35 systemctl restart etcd.service  kube-apiserver.service  kube-controller-manager.service  kube-scheduler.service
36 systemctl enable etcd.service  kube-apiserver.service  kube-controller-manager.service  kube-scheduler.service
master脚本

 

技术分享图片
 1 #!/bin/bash
 2 export RED=\E[1;31m
 3 export RES=\E[0m
 4 export GRN=\E[1;32m
 5 echo -e "${RED} 请确保master已经hosts解析 ${RES}"
 6 echo  -e " ${RED} 开始安装node端  ${RES}"
 7 cat >>/etc/yum.repos.d/virt7-docker-common-release.repo<<EOF
 8 [virt7-docker-common-release]
 9 name=virt7-docker-common-release
10 baseurl=http://cbs.centos.org/repos/virt7-docker-common-release/x86_64/os/
11 gpgcheck=0
12 EOF
13 yum -y install --enablerepo=virt7-docker-common-release kubernetes etcd flannel
14 sed -ri.bak s#(--master=http://)(10.0.0.140)(:8080)#\1master\2#g /etc/kubernetes/config
15 sed -i.bak s#--address=127.0.0.1#--address=0.0.0.0#g  /etc/kubernetes/kubelet
16 sed -i "s#hostname-override=node1#hostname-override=`hostname`#g"  /etc/kubernetes/kubelet
17 systemctl  restart kube-proxy.service  kubelet.service  docker
18 systemctl  enable kube-proxy.service  kubelet.service  docker
node脚本

 

 

 

以上是关于k8s 1.5.2 安装脚本的主要内容,如果未能解决你的问题,请参考以下文章

入门K8s:一键脚本搭建Linux服务器集群

入门K8s:一键脚本搭建Linux服务器集群

k8s一键安装脚本(二进制)

使用velero去备份k8s集群

使用树莓派搭建K8S集群(ARM64架构,附安装脚本)

k3s单机版安装部署 附一键安装脚本