@(Openshif开源云平台)
参考:《开源容器云Openshift》+官网doc
https://forums.docker.com/t/docker-storage-config-on-centos-7-1/3164
目标:
搭建分布式Openshift Origin,完成企业部署:虚拟机安装1个master节点和2个node节点。了解其部署过程,理解原理。
软件版本:
kubernets:1.6.1
docker:1.12.6
openshift origin:3.6.0
etcd:3.2.1
设置固定IP地址:
master:192.168.2.169
node1: 192.168.2.171
node2:192.168.2.172
安装步骤:
1.安装前预配置
注明:以下只有master的相关配置,因为后续采用Ansible的高级安装方法,即可通过master可直接部署node节点。node1、2虚拟机中只需要配置固定ip地址和主机名(可参考Openshift第一节)
##配置主机名
hostnamectl set-hostname master.example.com
2.安装依赖包
##openshit依赖的软件包
yum install -y wget git net-tools bind-utils iptables-services bridge-utils bash-completion
##install docker
yum install -y docker
##use additional block device原因:doker原生分配的数据卷太小
vi /etc/sysconfig/docker-storage-setup
##add
DEVS=/dev/sdb_fan
VG=docker-vg
##启动容器
systemctl start docker
systemctl enable docker
systemctl restart docker
3.安装Ansible
##install EPEL仓库(目的是为后续安装ansible提供前提,需要自己到网站上查看最新版本,书上给的地址已经过时,大小15k)
yum install http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-10.noarch.rpm
#将enabled从1代替成0
sed -i -e "s/^enabled=1/enabled=0" /etc/yum.repos.d/epel.repo
yum -y --enablerepo=epel install ansible pyOpenSSL
##在master节点上实现SSH密钥(可参见上一节)、实现对远程主机安装openshift
ssh-keygen -f /root/.ssh/id_rsa -N ''
##将密钥通过循环的方式安装在node节点和Master,实现相互信任
for host in master.example.com \
node1.example.com \
node2.example.com; \
do ssh-copy-id -i ~/.ssh/id_rsa.pub $host; \
done
##在Master节点上下载ansible playbook(目的是实现高级安装)
wget http://github.com/openshift/openshift-ansible/archive/openshift-ansible-3.3.26-1.tar.gz
tar zxvf openshift-ansible-3.3.26-1.tar.gz
##安装etcd(数据库,master控制数据放在其中,减少对master的请求)
yum install -y etcd
systemctl enable etcd
systemctl start etcd
4.在master上配置Ansible
目的:Ansible Inventory = hosts文件,记录着对
master\node\etcd的操作信息
##备份原生hosts文件,另存为hosts.org
mv -f /etc/ansible/hosts /etv/ansible/hosts.org
##新创建一个文件
touch hosts
##在hosts中添加如下内容
# Create an OSEv3 group that contains the masters, nodes, and etcd groups
[OSEv3:children]
masters
nodes
etcd
# Set variables common for all OSEv3 hosts
[OSEv3:vars]
ansible_ssh_user=root
deployment_type=origin
openshift_release = 3.6.0
# uncomment the following to enable htpasswd authentication; defaults to
IdentityProvider
openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true', 'challenge': 'true', 'kind': 'HTPasswdPasswordIdentityProvider', 'filename': '/etc/origin/master/htpasswd'}]
# host group for masters
[masters]
master.example.com
# host group for etcd
[etcd]
master.example.com
# host group for nodes, includes region info
[nodes]
master.example.com
node1.example.com
node2.example.com
5.在master上执行安装
ansible-playbook /root/openshift-ansible-openshift-ansible-3.3.26-1/playbooks/byo/config.yml