1.環境:
主機名 ip 角色
master 10.2.1.198 master
node1 10.2.1.174 node
node2 10.2.1.165 node
在每一台的hosts添加解析記錄
2.selinux
官方文檔推薦開啟SELINUX,否則會導致安裝失敗。
修改方式如下:
/etc/selinux/config
SELINUX=enforcing
SELINUXTYPE=targeted
3.在所有節點上生成密鑰對
在master能免密碼登錄node1 ,node2
4.裝依賴包
yum install -y update
重啟后裝包
yum install wget git net-tools bind-utils iptables-services bridge-utils bash-completion kexec-tools sos psacct bash-completion.noarch bash-completion-extras.noarch python-passlib NetworkManager -y
5.安裝docker
yum install docker-1.13.1 -y
6.配置docker使用的存儲
echo DEVS=/dev/sdb > /etc/sysconfig/docker-storage-setup
echo VG=DOCKER >> /etc/sysconfig/docker-storage-setup
echo SETUP_LVM_THIN_POOL=yes >> /etc/sysconfig/docker-storage-setup
echo DATA_SIZE="100%FREE">> /etc/sysconfig/docker-storage-setup
rm -rf /var/lib/docker
wipefs --all /dev/sdb
docker-storage-setup
7.配置docker鏡像加速
選擇阿里雲的鏡像服務器進行加速,修改 /etc/docker/daemon.json 文件,如下所示:
[root@master ~]# more /etc/docker/daemon.json
{
"registry-mirrors": ["https://換成自己的地址.mirror.aliyuncs.com"]
}
配置完成之后,所有主機啟動docker,命令如下:
systemctl enable docker
systemctl start docker
8.用tar.gz安裝ansible, #3.9必須2.5版本
yum -y install epel-release
# Disable the EPEL repository globally so that is not accidentally used during later steps of the installation
sed -i -e "s/^enabled=1/enabled=0/" /etc/yum.repos.d/epel.repo
yum -y install pyOpenSSL
9.從github上下載openshift-ansible已經release的版本
wget https://github.com/openshift/openshift-ansible/archive/openshift-ansible-3.9.32-1.zip
下載完成之后,進行解壓並重命為 openshift-ansible。
10.修改軟件源
由於目前OpenShift-ansible還沒有添加3.9的源,所以需要自行修改下,方法如下:
進行openshift-ansible/roles/openshift_repos/templates/ 復制一份 CentOS-OpenShift-Origin37.repo.j2 為 CentOS-OpenShift-Origin39.repo.j2。
修改CentOS-OpenShift-Origin39.repo.j2中的源修改為國內的,比如阿里雲。
[centos-openshift-origin39]
name=CentOS OpenShift Origin
baseurl=http://mirrors.aliyun.com/centos/7/paas/x86_64/openshift-origin39/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-PaaS
[centos-openshift-origin39-testing]
name=CentOS OpenShift Origin Testing
baseurl=http://buildlogs.centos.org/centos/7/paas/x86_64/openshift-origin39/
enabled={{ 1 if openshift_repos_enable_testing else 0 }}
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-PaaS
[centos-openshift-origin39-debuginfo]
name=CentOS OpenShift Origin DebugInfo
baseurl=http://debuginfo.centos.org/centos/7/paas/x86_64/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-PaaS
[centos-openshift-origin39-source]
name=CentOS OpenShift Origin Source
baseurl=http://vault.centos.org/centos/7/paas/Source/openshift-origin39/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-PaaS
11.配置 ansible inventory 文件,保存到 /etc/ansible/inventory.ini文件中
# Create an OSEv3 group that contains the masters and nodes groups
[OSEv3:children]
#目前配置標准的三個角色
masters
nodes
etcd
# Set variables common for all OSEv3 hosts
[OSEv3:vars]
# SSH user, this user should allow ssh based auth without requiring a password
ansible_ssh_user=root
#使用origin社區版
openshift_deployment_type=origin
#指定安裝版本
openshift_release=3.9
#指定默認域名,訪問的時候需要使用該域名,沒有dns服務器,需要手動添加本地hosts文件
openshift_master_default_subdomain=apps.192.168.40.161.nip.io
#禁止磁盤、內存和鏡像檢查
openshift_disable_check=disk_availability,docker_storage,memory_availability,docker_image_availability
#disk_availability:報錯信息是推薦的master磁盤空間剩余量大於40GB。測試環境無法滿足,跳過檢測。
#memory_availability:報錯信息是推薦的master內存為16GB,node內存為8GB,測試環境無法滿足,跳過檢測。
#docker_image_availability:報錯信息是需要的幾個鏡像未找到,選擇跳過,裝完集群后,在使用的時候再自行下載。
#docker_storage:報錯信息是推薦選擇一塊磁盤空間存儲鏡像,這里選擇跳過。采用docker默認的方式存儲鏡像。
# uncomment the following to enable htpasswd authentication; defaults to DenyAllPasswordIdentityProvider
openshift_master_identity_providers=[{'name':'htpasswd_auth','login':'true','challenge':'true','kind':'HTPasswdPasswordIdentityProvider','filename':'/etc/origin/master/htpasswd'}]
#ntp時間同步
openshift_clock_enabled=true
#節點配額
openshift_node_kubelet_args={'pods-per-core': ['10']}
# host group for masters
[masters]
master openshift_schedulable=True
# host group for nodes, includes region info
[nodes]
master openshift_node_labels="{'region': 'infra'}"
node1 openshift_node_labels="{'region': 'infra', 'zone': 'default'}"
node2 openshift_node_labels="{'region': 'infra', 'zone': 'default'}"
[etcd]
master
12.
修改腳本問題
openshift-ansible/roles/lib_utils/filter_plugins/openshift_master.py 的第487行
注釋掉紅框中兩行

13.開始安裝
ansible-playbook -i /etc/ansible/inventory.ini openshift-ansible/playbooks/prerequisites.yml
ansible-playbook -i /etc/ansible/inventory.ini openshift-ansible/playbooks/deploy_cluster.yml
14.安裝完成后,執行oc get nodes 檢查當前集群的成員列表以及它們的狀態。
oc get nodes
其實在安裝完成之后 第二個節點和第三個節點的roles類型為空,需要將其打上compute標簽,命令如下:
oc label node node1.192.168.40.162.nip.io node-role.kubernetes.io/compute=true
