2.1、环境
master与minion都是使用centos 7的系统
修改hostname与hosts文件:
centos-master:192.168.137.102
centos-minion1:192.168.137.100
centos-minion2:192.168.137.101
2.2、关闭防火墙:
#systemctl disable firewalld
#systemctl stop firewalld
2.3、修改iptables
把icmp-host-prohibited两条注释掉
vi /etc/sysconfig/iptables
重启iptables
#systemctl restart iptables
2.2、安装
centos 7 的源都有,可以使用yum安装
这里使用阿里的镜像:
#wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
master端:
yum -y install etcd kubernetes-master
2.3、修改docker配置文件
vi /etc/sysconfig/docker
添加:
OPTIONS=‘--selinux-enabled=false --insecure-registry gcr.io‘
2.4、修改apiserve配置文件
vi /etc/kubernetes/apiserver
删除代码中的ServiceAccount
KUBE_ADMISSION_CONTROL="--admission_control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ServiceAccount,ResourceQuota"
2.5、修改config文件
vi /etc/kubernetes/config
2.6、启动服务
使用脚本
vi master_start.sh
#!/bin/bash
for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler; do
systemctl restart $SERVICES
systemctl enable $SERVICES
systemctl status $SERVICES
done
设置权限:
chmod +x master_start.sh
启动:
./master_start.sh
2.7、停止服务脚本
vi master_stop.sh
#!/bin/bash
for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler; do
systemctl stop $SERVICES
done
设置权限:
chmod +x master_stop.sh
minion端安装:(这里只用centos-minion1)
2.8、yum安装
yum install kubernetes-node
2.9、修改配置文件
vi /etc/kubernetes/config
2.10、配置kubelet文件
vi /etc/kubernetes/kubelet
2.11、启动服务
vi minion_start.sh
#!/bin/bash
for SERVICES in kube-proxy kubelet docker; do
systemctl restart $SERVICES
systemctl enable $SERVICES
systemctl status $SERVICES
done
设置权限:
chmod +x minion_start.sh
启动:
./minion_start.sh
2.12、停止脚本
vi minion_stop.sh
#!/bin/bash
for SERVICES in kube-proxy kubelet docker; do
systemctl stop $SERVICES
done
设置权限:
chmod +x minion_stop.sh
2.13、检查状态
在master端使用命令检查
#kubectl get nodes
#kubectl cluster-info