kuberntes -node kubeadm 1.14.1的shell脚本(2)

IP:CentOS7
备注,脚本中涉及的IP ,hosts,要根据实际情况修改,请勿直接用,会报错。。如果有疑问请留言,或者私信。互相交流学习。
#!/bin/bash
#author shadow2017
#kubernetes 1.14.1
yum install vim wget net-tools lrzsz -y
#1:配置环境:
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
iptables -F
iptables -t nat -F
iptables -I FORWARD -s 0.0.0.0/0 -d 0.0.0.0/0 -j ACCEPT
yum -y install ntp
ntpdate pool.ntp.org
systemctl start ntpd
systemctl enable ntpd
systmctl stop firewalld.serice iptables.service
systemctl disable firewalld.service
systemctl disable iptable.service
#2:配置hosts 解析
cat > /etc/hosts <<EOF
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.137 k8s-test
EOF
#3:配置内核参数:
cat > /etc/sysctl.conf <<EOF
net.ipv4.ip_forward=1
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-arptables = 1
vm.swappiness=0
EOF
#4:关闭selinux
echo -n “正在关闭SELinux……”
setenforce 0 > /dev/null 2>&1
sed -i ‘/^SELINUX=/s/=.*/=disabled/’ /etc/selinux/config
if [ KaTeX parse error: Expected 'EOF', got '#' at position 51: …inux初始化完毕!" fi #̲setenforce 0 #s…/SELINUX=disabled/’ /etc/selinux/config
cat /etc/selinux/config
#5:保存修改内核参数生效
sysctl -p
#6:配置kubernetes

echo -n “正在配置kubernetes.repo”
cat > /etc/yum.repos.d/kubernetes.repo <<EOF
[kubernetes]
name=Kubernetes Repo
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
enabled=1
EOF
if [ $? -eq 0 ];then
echo -n “kubernetes配置完毕!”
fi
#7、安装Docker
echo -n “正在安装docker…!”
wget -P /etc/yum.repos.d https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum list docker-ce --showduplicates | sort -r
yum install docker-ce -y
#8:启动docker并设置开机启动
systemctl start docker
systemctl enable docker
systemctl status docker
if [ $? -eq 0 ];then
echo -n “docker安装配置完毕!”
fi
#9:执行下面命令配置加速器:
echo -n “配置加速器…”
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io
systemctl restart docker
#10:安装kubeadm和kubelet
#备注:
#可以指定型号安装:

echo -n “安装kubeadm,kubelet,kubectl…!”
yum install -y kubelet-1.14.1 kubernetes-cni-0.6.0-0.x86_64 kubeadm-1.14.1 kubectl-1.14.1 --disableexcludes=kubernetes &&
systemctl enable --now kubelet &&
systemctl start kubelet &&
systemctl status kubelet
#11:设置开机启动kubelet
systemctl daemon-reload &&
systemctl start kubelet &&
systemctl enable kubelet &&
systemctl status kubelet
if [ $? -eq 0 ];then
echo -n “kubeadm,kubelet,kubectl haved install
!”
fi

#12:此时查看下面两个文件的值是否为1
cat /proc/sys/net/bridge/bridge-nf-call-ip6tables
cat /proc/sys/net/bridge/bridge-nf-call-ip6tables

#master节点所需要的全部镜像如下:
echo -n “Downloading the kubernetes_node image…”

docker pull mirrorgooglecontainers/etcd:3.3.10 &&
docker pull willdockerhub/coredns:1.3.1 &&
docker pull mirrorgooglecontainers/kube-proxy:v1.14.1 &&
docker pull mirrorgooglecontainers/pause:3.1

#15:给镜像打上标签:
echo -n “Labeling kubernetes mirror…!”
docker tag mirrorgooglecontainers/kube-proxy:v1.14.1 k8s.gcr.io/kube-proxy:v1.14.1
docker tag mirrorgooglecontainers/pause:3.1 k8s.gcr.io/pause:3.1
docker tag mirrorgooglecontainers/etcd:3.3.10 k8s.gcr.io/etcd:3.3.10
docker tag willdockerhub/coredns:1.3.1 k8s.gcr.io/coredns:1.3.1
if [ $? -eq 0 ];then
echo -n “Preparations for the mirror work have been completed!”
fi

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值