安装K8S
参考:
Centos7安装Docker详细步骤(无坑版教程) - 腾讯云开发者社区-腾讯云
CentOS7 安装 k8s_BY&Crystal的博客-CSDN博客_centos7安装k8s
废话不多说,直接开始:
一,准备
准备2个Centos7的虚拟机。
二,装docker(master和slave1)
1,更新
yum -y update
2,卸载旧docker
yum remove docker docker-common docker-selinux docker-engine
3,安装需要的软件包
yum install -y yum-utils device-mapper-persistent-data lvm2
4,设置镜像源(阿里巴巴)
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
5,安装docker
yum -y install docker-ce-18.03.1.ce
或者查找后,自行安装其他版本
yum list docker-ce --showduplicates | sort -r
查看docker版本
docker version
6,启动
systemctl start docker
systemctl enable docker
三,安装k8s
1,安装epel-release源(master和slave1)
yum -y install epel-release
2,关闭防火墙(master和slave1)
systemctl stop firewalld systemctl disable firewalld setenforce 0 #查看防火墙状态 firewall-cmd --state
四,安装master机器
1,安装kubernetes-master
yum -y install etcd kubernetes-master
2,编辑 etcd.conf
vi /etc/etcd/etcd.conf
修改如下
3,修改 apiserver
vi /etc/kubernetes/apiserver
4,启动etcd、kube-apiserver、kube-controller-manager、kube-scheduler等服务,并设置开机启动
for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler; do systemctl restart $SERVICES;systemctl enable $SERVICES;systemctl status $SERVICES ; done
5,在etcd中定义flannel网络
etcdctl mk /atomic.io/network/config ‘{“Network”:“172.17.0.0/16”}’
五,安装slave机器
1,安装kubernetes-node
yum -y install flannel kubernetes-node
2,为flannel网络指定etcd服务
vi /etc/sysconfig/flanneld
3,修改config
vi /etc/kubernetes/config
4,kubelet配置文件
vim /etc/kubernetes/kubelet
5,slave节点机上启动kube-proxy,kubelet,docker,flanneld等服务,并设置开机启动
for SERVICES in kube-proxy kubelet docker flanneld;do systemctl restart $SERVICES;systemctl enable $SERVICES;systemctl status $SERVICES; done
六,查看
master机器,执行
kubectl get nodes