部署OpenShift基礎環境
- 基礎配置
-
- 配置網絡
- 關閉防火牆及SELinux
- 添加位址解析
- 安裝基礎包并更新核心
- 安裝EPEL源
- 安裝OpenShift、Docker
- 安裝ansible
- 修改核心參數
- 配置Docker
- 搭建叢集
-
- 克隆并修改網絡
- 配置SSH免密登入
- 安裝OpenShift工具
- OpenShift的配置
-
- 配置Ansible的hosts檔案
- 部署并通路OpenShift
- 驗證
實驗環境要求:
作業系統 | 主機名/IP位址 | 配置設定角色 | 硬體配置 |
---|---|---|---|
CentOS7.3 | master.example.com/192.168.183.110 | Master | 2核2GB硬碟100GB |
CentOS7.3 | node1.example.com/192.168.183.120 | Node | 2核2GB硬碟100GB |
CentOS7.3 | node1.example.com/192.168.183.130 | Node | 2核2GB硬碟100GB |
基礎配置
配置網絡
#重新配置網絡;“ens33”是會變的,使用Tab鍵推出即可
nmcli connection modify "ens33" ipv4.method manual ipv4.addresses "192.168.183.110/24" ipv4.gateway "192.168.183.2" ipv4.dns "114.114.114.114" connection.autoconnect yes
#關閉網絡并重新開機使配置生效
nmcli con down enss33
nmcli con up enss33
關閉防火牆及SELinux
systemctl stop firewalld.service && systemctl disabled firewalld.service
添加位址解析
使用
vim /etc/hosts
添加如下内容:
192.168.183.110 master.example.com
192.168.183.120 node1.example.com
192.168.183.130 node2.example.com
安裝基礎包并更新核心
#安裝基礎軟體包
yum install -y vim wget git net-tools bind-utils iptables-services bridge-utils bash-completion kexec-tools sos psacct
#更新完系統後需要重新開機才能生效
yum update -y
reboot
安裝EPEL源
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
安裝OpenShift、Docker
安裝3.10版本OpenShift
yum install -y centos-release-openshift-origin310 docker
安裝ansible
Ansible所有版本下載下傳網址
OpenShift的版本對應的ansible有嚴格要求,是以ansible需要指定與OpenShift相對應的版本
OpenShift版本 | Ansible版本 |
---|---|
3.9 | 2.5.5 |
3.10 | 2.7 |
為確定伺服器可以連接配接外網,可先執行
yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
#若不能使用yum安裝可直接下載下傳然後上傳到虛拟機即可
yum install -y https://releases.ansible.com/ansible/rpm/release/epel-7-x86_64/ansible-2.7.1-1.el7.ans.noarch.rpm pyOpenSSL
修改核心參數
使用
vim /etc/sysctl.conf
添加如下内容:
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
#儲存并重新整理生效
modprobe br_netfilter
sysctl -p
配置Docker
開機自動啟動docker服務
systemctl enabled docker
在daemon.json中添加如下:
{
"registry-mirrors":["https://registry.docker-cn.com"]
}
搭建叢集
克隆并修改網絡
配置SSH免密登入
安裝OpenShift工具
3.10版OpenShift的安裝指令:
yum install -y openshift-ansible atomic atomic-openshift-utils
OpenShift的配置
配置Ansible的hosts檔案
注意:
3.10的Ansible的hosts檔案與3.9有所改動;新版本
取消
了openshift_master_identity_providers中
“finename”
關鍵字,在[nodes] entry中
添加
“openshift_node_group_name='node-config-master'”
或
“openshift_node_group_name='node-config-master-infra'”
3.10版的Ansible hosts檔案内容如下:
# add follows to the end
[OSEv3:children]
masters
nodes
etcd
[OSEv3:vars]
# admin user created in previous section
ansible_ssh_user=root
openshift_deployment_type=origin
# use HTPasswd for authentication
openshift_master_identity_providers=[{'name':'htpasswd_auth','login':'true','challenge':'true','kind':'HTPasswdPasswordIdentityProvider'}]
openshift_disable_check=disk_availability,docker_storage,memory_availability,docker_image_availability,package_version,package_availability
# allow unencrypted connection within cluster
openshift_docker_insecure_registries=172.30.0.0/16
[masters]
master.example.com openshift_schedulable=true containerized=false
[etcd]
master.example.com
[nodes]
# set labels [region:***,:zone:***](any name you like)
master.example.com openshift_node_group_name='node-config-master-infra'
node1.example.com openshift_node_group_name='node-config-compute'
node2.example.com openshift_node_group_name='node-config-compute'
部署并通路OpenShift
#安裝前的檢查
ansible-playbook /usr/share/ansible/openshift-ansible/playbooks/prerequisites.yml
#安裝
ansible-playbook /usr/share/ansible/openshift-ansible/playbooks/deploy_cluster.yml
#解除安裝
ansible-playbook /usr/share/ansible/openshift-ansible/playbooks/adhoc/uninstall.yml
驗證
注意:
外部浏覽器需要在win10的
C:\Windows\System32\drivers\etc下的hosts
檔案中添加主機解析
192.168.183.110 master.example.com
即可。