赞
踩
- sudo systemctl disable firewalld
- sudo systemctl stop firewalld
- sudo setenforce 0
- # 永久关闭 修改/etc/sysconfig/selinux文件设置
- sudo sed -i 's/SELINUX=permissive/SELINUX=disabled/' /etc/sysconfig/selinux
- sudo sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
- sudo swapoff -a
- # 永久禁用,打开/etc/fstab注释掉swap那一行。
- sudo sed -i 's/.*swap.*/#&/' /etc/fstab
对于master节点:
- sudo vim /etc/sysctl.d/k8s.conf
-
- net.ipv4.ip_forward = 1
- net.bridge.bridge-nf-call-ip6tables = 1
- net.bridge.bridge-nf-call-iptables = 1
- net.ipv6.conf.all.disable_ipv6 = 1
- net.ipv6.conf.default.disable_ipv6 = 1
- net.ipv6.conf.lo.disable_ipv6 = 1
- net.ipv6.conf.all.forwarding = 1
- vm.swappiness = 0
-
- sudo sysctl --system
对于node节点:
- sudo vim /etc/sysctl.d/k8s.conf
-
- net.bridge.bridge-nf-call-ip6tables = 1
- net.bridge.bridge-nf-call-iptables = 1
-
- sudo sysctl --system
验证是否生效,均返回 1 即正确:
- sysctl -n net.bridge.bridge-nf-call-iptables
- sysctl -n net.bridge.bridge-nf-call-ip6tables
- #!/bin/sh
-
- 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
-
- #安装kubeadm、kubelet、kubectl,注意这里默认安装当前最新版本v1.14.1:
- yum install -y kubeadm-1.21.3-0 kubelet-1.21.3-0 kubectl-1.21.3-0
- #yum install -y kubeadm kubelet kubectl
- systemctl enable kubelet && systemctl start kubelet
-
-
- # pull all images that k8s needs
- ver=v1.21.3
- registry=registry.cn-hangzhou.aliyuncs.com/google_containers
- images=`kubeadm config images list --kubernetes-version=$ver |awk -F '/' '{print $2}'`
-
- for image in $images
- do
- if [ $image != coredns ];then
- docker pull ${registry}/$image
- if [ $? -eq 0 ];then
- docker tag ${registry}/$image k8s.gcr.io/$image
- docker rmi ${registry}/$image
- else
- echo "ERROR: 下载镜像报错,$image"
- fi
- else
- docker pull coredns/coredns:1.8.0
- docker tag coredns/coredns:1.8.0 k8s.gcr.io/coredns/coredns:v1.8.0
- docker rmi coredns/coredns:1.8.0
- fi
- done
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。