k8s-pre-install

1. # 关闭防火墙:

systemctl stop firewalld && systemctl disable firewalld && iptables -F

2. # 关闭selinux:

sed -i 's/enforcing/disabled/' /etc/selinux/config && setenforce 0

3. # 关闭swap:

swapoff -a

sed -ri 's/.*swap.*/#&/' /etc/fstab

4. # 设置主机名:

hostnamectl set-hostname k8s-master

5. 在master添加hosts:

cat >> /etc/hosts << EOF

192.168.3.211 k8s-master

192.168.3.212 k8s-node1

192.168.3.213 k8s-node2

EOF

6. #将桥接的IPv4流量传递到iptables的链:

cat > /etc/sysctl.d/k8s.conf << EOF

net.bridge.bridge-nf-call-ip6tables = 1

net.bridge.bridge-nf-call-iptables = 1

EOF

7. 执行命令

sysctl --system # 生效

8. 时间同步:

yum install ntpdate -y

ntpdate time.windows.com

9. 安装Docker

wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo

yum -y install docker-ce-18.06.1.ce-3.el7

10. 修改文件

cat > /etc/docker/daemon.json << EOF

{

"registry-mirrors": ["https://b9pmyelo.mirror.aliyuncs.com"]

}

EOF

11. docker 启动配置

systemctl daemon-reload && systemctl enable docker && systemctl start docker

docker --version

12. 创建 repo 文件

cat > /etc/yum.repos.d/kubernetes.repo << EOF

[kubernetes]

name=Kubernetes

baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64

enabled=1

gpgcheck=0

repo_gpgcheck=0

gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg

EOF

13. 安装

yum install -y kubelet-1.18.0 kubeadm-1.18.0 kubectl-1.18.0

systemctl enable kubelet

你可能感兴趣的:(kubernetes,k8s,kubernetes,docker,容器)