环境:
A、B两天机器A机器IP:192.169.0.104,B机器IP:192.168.0.102,其中A为Master节点,B为Slave节点
操作系统:Centos7
Master与Slave节点相同配置
增加主机名与IP的映射
vim /etc/hosts,添加以下配置:
192.168.0.104 master
192.168.0.102 slave
增加Kubernetes安装源
cd /etc/yum.repo.d
新建virt7-testing.repo源文件,vim virt7-testing.repo 添加以下内容:
[virt7-testing]
name=virt7-testing
baseurl=http://cbs.centos.org/repos/virt7-testing/x86_64/os/
gpgcheck=0
安装kubernetes
yum -y install --enablerepo=virt7-testing kubernetes
关闭防火墙
Systemctl disable iptables-services firewalld
Systemctl stop iptables-services firewalld
service iptables save
Master节点个性配置
安装Etcd
yum install http://cbs.centos.org/kojifiles/packages/etcd/0.4.6/7.el7.centos/x86_64/etcd-0.4.6-7.el7.centos.x86_64.rpm
修改配置
Vim /etc/kubernetes/config 修改以下内容:
KUBE_MASTER="--master=http://master:8080"
KUBE_ETCD_SERVERS="--etcd_servers=http://master:4001"
vim /etc/kubernetes/apiserver 修改以下内容:
KUBE_API_ADDRESS="--address=0.0.0.0"
KUBE_API_PORT="--port=8080"
#KUBE_ETCD_SERVERS="--etcd_servers=http://127.0.0.1:2379"
启动服务
for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler; do
systemctl restart $SERVICES
systemctl enable $SERVICES
systemctl status $SERVICES
done
Slave节点个性配置
修改配置
Vim /etc/kubernetes/config 修改以下内容:
KUBE_MASTER="--master=http://master:8080"
KUBE_ETCD_SERVERS="--etcd_servers=http://master:4001"修改/etc/kubernetes/kubelet文件内容:
###
# kuberneteskubelet(minion) config
KUBELET_ADDRESS="--address=0.0.0.0"
KUBELET_PORT="--port=10250"
KUBELET_HOSTNAME="--hostname_override=centos-minion"
KUBELET_API_SERVER="--api_servers=http://centos-master:8080“
# Add your own!
KUBELET_ARGS=""启动服务
for SERVICES in kube-proxy kubelet docker; do
systemctl restart $SERVICES
systemctl enable $SERVICES
systemctl status $SERVICES
done
校验是否成功
在master节点中执行 kubectl get nodes 命令显示以下结果表示成功: