环境:
centos7

192.168.1.10:k8s-maser
192.168.1.11:k8s-node1
192.168.1.12:k8s-node2

1: 关闭防火墙,关闭selinux
systemctl stop firewalld
setenforce 0

2:修改主机名
hostnamectl set-hostname k8s-master1
hostnamectl set-hostname k8s-node1
hostnamectl set-hostname k8s-node2

3:修改hosts文件
192.168.1.10 k8s-master
192.168.1.11 k8s-node1
192.168.1.12 k8s-node2

4:禁用swap内存交换
swapoff -a
echo “swapoff -a” >> /etc/rc.local

5:安装docker
下载docker yum源
wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo

查询可用版本:
yum list docker-ce --showduplicates | sort -r

安装docker18.06指定版本
yum -y install docker-ce-18.06.3.ce-3.el7

版本验证:
[root@server01 docker]# docker --version
Docker version 18.06.3-ce, build d7080c1

运行docker

6: 上传k8s.repo
master上执行:
yum -y install kubeadm-1.17.0 kubelet-1.17.0 kubectl-1.17.0
systemctl enable kubelet

node上执行:
yum -y install kubelet-1.17.0 kubeadm-1.17.0
systemctl enable kubelet

7:初始化集群
导入镜像
docker load -i k8s_v1.17.0.tar

8:初始化k8s集群
kubeadm init --apiserver-advertise-address=192.168.1.10 --image-repository registry.aliyuncs.com/google_containers --kubernetes-version v1.17.0 --service-cidr=10.1.0.0/16 --pod-network-cidr=10.244.0.0/16

初始化完成之后执行:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown ( i d − u ) : (id -u): (idu):(id -g) $HOME/.kube/config

9:将node加入到集群中:
kubeadm join 192.168.1.10:6443 --token 98biv0.ho8l1zic23n90vm9
–discovery-token-ca-cert-hash sha256:37878f92eb083b149479250592ad1369d8ee1aac8a938bee1660991758534ce7

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐