k8s一鍵安裝

#!/bin/bash

#yum源配置
systemctl stop firewalld.service 
systemctl disable firewalld.service
yum install ipset ipvsadm wget bash-completion.noarch -y

cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
       https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF

wget https://download.docker.com/linux/centos/docker-ce.repo -P /etc/yum.repos.d/

#關閉selinux

setenforce 0
sed -i 's/^SELINUX=enforcing$/SELINUX=disabled/' /etc/selinux/config
#關閉Swap
swapoff -a

#路由設置看需要可以不設置

cat <<EOF >  /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
vm.swappiness=0
EOF
sysctl --system
sysctl -p /etc/sysctl.d/k8s.conf

#加載內核

chmod +x /etc/sysconfig/modules/ipvs.modules && /etc/sysconfig/modules/ipvs.modules

lsmod | grep -e ip_vs -e nf_conntrack_ipv4
cut -f1 -d " "  /proc/modules | grep -e ip_vs -e nf_conntrack_ipv4
lsmod | grep ip_vs

#安裝二進制包請稍後

yum makecache fast -y

yum install -y kubelet kubeadm kubectl && yum install -y docker-ce docker-ce-cli containerd.io

systemctl enable kubelet docker 
systemctl start docker 

#配置docker阿里雲加速器"


tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://0k0953tv.mirror.aliyuncs.com"]
}
EOF
systemctl daemon-reload
systemctl restart docker
kubeadm init --image-repository registry.aliyuncs.com/google_containers  --pod-network-cidr=10.244.0.0/16

下載安裝flannel網卡

wget  https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
kubectl apply -f kube-flannel.yml
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章