K8sv1.10快速安装,只需三步即可(执行三个.sh脚本,下面贴出了脚本内容,直接复制即可)
#测试环境centos 7.3 , docker 17.06
-
第一步:初始化环境
~]# vi env_set.sh
1 #!/bin/bash 2 3 #check 4 5 [[ $UID -ne 0 ]]&& { echo "Must run in root user !";exit; } 6 7 echo '# 基础配置# 8 9 #关闭防火墙 10 11 #关闭Selinux 12 13 #关闭Swap 14 15 #内核配置 16 17 #防火墙# 18 19 systemctl stopfirewalld &>/dev/null 20 21 systemctl disablefirewalld &>/dev/null 22 23 [[ -f /etc/init.d/ufw]] && { ufw disable;} 24 25 [[ -f/etc/init.d/iptables ]] && { /etc/init.d/iptables stop; } 26 27 #关闭Selinux 28 29 setenforce 0 &>/dev/null 30 31 sed -i"s/^SELINUX=enforcing/SELINUX=disabled/g" /etc/sysconfig/selinux 32 33 sed -i"s/^SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config 34 35 sed -i"s/^SELINUX=permissive/SELINUX=disabled/g" /etc/sysconfig/selinux 36 37 sed -i"s/^SELINUX=permissive/SELINUX=disabled/g" /etc/selinux/config 38 39 #关闭Swap 40 41 swapoff -a 42 43 sed's/.*swap.*/#&/' /etc/fstab &>/dev/null 44 45 #内核# 46 47 cat <<EOF >/etc/sysctl.d/k8s.conf 48 49 net.ipv4.ip_forward =1 50 51 net.bridge.bridge-nf-call-ip6tables= 1 52 53 net.bridge.bridge-nf-call-iptables= 1 54 55 vm.swappiness=0 56 57 EOF 58 59 sysctl -p/etc/sysctl.d/k8s.conf &>/dev/null 60 61 echo "sysctl -p/etc/sysctl.d/k8s.conf" >>/etc/profile 62 63 echo "#myset 64 65 * soft nofile 65536 66 67 * hard nofile 65536 68 69 * soft nproc 65536 70 71 * hard nproc 65536 72 73 * soft memlock unlimited 74 75 * hard memlock unlimited 76 77 ">>/etc/security/limits.conf 78 79 #hosts
-
第二步:下载相关组件
~]# vi download.sh
1 #安装kubelet kubeadm 2 3 curl -s http://elven.vip/ks/sh/kubelet.sh|bash 4 5 echo '下载K8S相关镜像' 6 7 MyUrl=registry.cn-shanghai.aliyuncs.com/alik8s 8 9 images=(kube-proxy-amd64:v1.10.0kube-controller-manager-amd64:v1.10.0 kube-scheduler-amd64:v1.10.0kube-apiserver-amd64:v1.10.0 etcd-amd64:3.1.12kubernetes-dashboard-amd64:v1.8.3 heapster-grafana-amd64:v4.4.3heapster-influxdb-amd64:v1.3.3 heapster-amd64:v1.4.2k8s-dns-dnsmasq-nanny-amd64:1.14.8 k8s-dns-sidecar-amd64:1.14.8k8s-dns-kube-dns-amd64:1.14.8 pause-amd64:3.1) 10 11 # 12 13 for imageName in${images[@]} ; do 14 15 docker pull $MyUrl/$imageName 16 17 docker tag $MyUrl/$imageNamek8s.gcr.io/$imageName 18 19 docker rmi $MyUrl/$imageName 20 21 done 22 23 # 24 25 docker pull$MyUrl/flannel:v0.10.0-amd64 26 27 docker tag$MyUrl/flannel:v0.10.0-amd64 quay.io/coreos/flannel:v0.10.0-amd64 28 29 docker rmi$MyUrl/flannel:v0.10.0-amd64 30 31 echo '下载yml文件,部署flannel网络,dashboard用到' 32 33 mkdir -p$HOME/k8s/heapster ; cd $HOME/ 34 35 YmlUrl=http://elven.vip/ks/k8s/oneinstall/yml 36 37 curl -s$YmlUrl/kube-flannel.yml >k8s/kube-flannel.yml 38 39 curl -s$YmlUrl/kubernetes-dashboard.yaml >k8s/kubernetes-dashboard.yaml 40 41 curl -s$YmlUrl/heapster-rbac.yaml >k8s/heapster-rbac.yaml 42 43 curl -s$YmlUrl/heapster/influxdb.yaml >k8s/heapster/influxdb.yaml 44 45 curl -s$YmlUrl/heapster/heapster.yaml >k8s/heapster/heapster.yaml 46 47 curl -s$YmlUrl/heapster/grafana.yaml >k8s/heapster/grafana.yaml 48 49 echo 50 51 echo '镜像列表' 52 53 docker images |egrep'k8s.gcr.io|quay.io' 54 55 echo 56 57 echo "yml部署文件" 58 59 ls -l $HOME/k8s/ 60 61 echo
-
第三步:安装部署k8s
~]# vi install.sh
1 #!/bin/bash 2 3 #k8s v1.10 master 单节点安装 4 5 #check 6 7 [[ $UID -ne 0 ]]&& { echo "Must run in root user !";exit; } 8 9 #重置# 10 11 kubeadm reset&>/dev/null 12 13 echo -e"