本篇將介紹透過上上一篇所提到的 OpenShift Ansible 來快速部署,OKD (The Origin Community Distribution of Kubernetes) 的 release-3.11
版本,我們透過實體 裸機機器(Bare-metal Server)
來進行部署環境。
請參考官方的文件規則
本次安裝作業系統採用 CentOS 7,測試環境為實體主機:
IP Address | Hostname | Sepc | Remark | Hard Disk Drive |
---|---|---|---|---|
192.168.101.130 | paas01 | 8 core/ 8G | Master node | SSD 256 GB |
192.168.101.131 | paas02 | 8 core/ 8G | Infra node | HDD 1TB |
192.168.101.132 | paas03 | 8 core/ 8G | AP node | HDD 1TB |
192.168.101.133 | paas04 | 8 core/ 8G | AP node | HDD 500 GB |
192.168.101.134 | paas05 | 8 core/ 8G | AP node | HDD 500 GB |
ISO: Centos-7-x86_64-Minimal-1810.iso
安裝前需要確認以下幾個項目:
root
權限,並且不需要輸入密碼。建議部署這邊可以透過一台在同網域的
Basion主機
直接操作連線至多台主機環境
為方便識別裸機機器對應名稱,這邊修改每台實體機 hostname
# Master
$ hostnamectl set-hostname paas01.paas.domain.tw
# Infra node
$ hostnamectl set-hostname paas02.paas.domain.tw
# AP node
$ hostnamectl set-hostname paas01.paas.domain.tw
$ hostnamectl set-hostname paas01.paas.domain.tw
$ hostnamectl set-hostname paas01.paas.domain.tw
配置 CentOS 系統網路,透過CLI設定配置當前實體機網卡(ifcfg-xxx):
# ifcfg-em1 是網卡名稱,如果是 eth0 修改對應網卡 ifcfg-eth0
$ vim /etc/sysconfig/network-scripts/ifcfg-em1
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=em1
UUID=7c200433-ead4-43e3-a571-0dfeb0515a96
DEVICE=em1
ONBOOT=yes
IPADDR=192.168.101.XXX
PREFIX=24
GATEWAY=192.168.101.254
DNS1=8.8.8.8
IPV6_PRIVACY=no
DOMAIN=paas.domain.tw
$ systemctl restart NetworkManager
$ cat /etc/resolv.conf
search paas.domain.tw # restart後會增加cluster.local
nameserver 8.8.8.8
$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:YWid3TtIfGyFM8MsaZf1YYp9RcgC60plBJrhPNqEEDk root@basion.paas.domain.tw
The key's randomart image is:
+---[RSA 2048]----+
| oo . ..o= =o=o|
| E. + * =++&.=.o|
| .. X =.B+=B ..|
| = o * + .. |
| . . S o o |
| . . . |
| . |
| |
| |
+----[SHA256]-----+
...
...
$ for seq in {1..5};
do
ssh-copy-id root@paas0$seq.paas.domain.tw; \
echo paas0$seq;\
done
#test ssh connection
$ for seq in {1..5};
do
ssh root@paas0$seq.paas.domain.tw echo paas0$seq; \
done
要安裝 OpenShift 或是 OKD,都必須 啟用 SELinux,否則安裝會失敗。必須設定 SELINUX=enforcing 與 SELINUXTYPE=targeted。
修改方式如下:
$ cat /etc/selinux/config
$ enforcing
$ seenforcing
$ selinuxenabled
$ sestatus
$ cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
---
$ for seq in {1..5};
do
ssh root@paas0$seq.paas.domain.tw sestatus; \
echo paas0$seq;\
done
此次實驗請於 Domain 提供平台,設置「區域檔紀錄」類型 A 配置每個節點如下配置:
IP Address | Hostname | Type | TTL |
---|---|---|---|
192.168.101.130 | paas01.paas.domain.tw | A | 3600 |
192.168.101.131 | paas02.paas.domain.tw | A | 3600 |
192.168.101.132 | paas03.paas.domain.tw | A | 3600 |
192.168.101.133 | paas04.paas.domain.tw | A | 3600 |
192.168.101.134 | paas05.paas.domain.tw | A | 3600 |
192.168.101.131 | *.apps.paas.domain.tw | A | 3600 |
192.168.101.130 | webconsole.paas.domain.tw | A | 3600 |
remark: 部分DNS service 有提供設定wildcard domain 的服務,如果沒有提供的話,建議之後在上面透過Route 進出的apps,可以透過正向表列方式將domain指向 infra node
$ for seq in {1..5};
do
ssh root@paas0$seq.paas.domain.tw 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
echo paas0$seq;\
done
$ for seq in {1..5};
do
ssh root@paas0$seq.paas.domain.tw yum install docker-1.13.1 -y;
ssh root@paas0$seq.paas.domain.tw echo pupaas0$seq done;
done
$ for seq in {1..5};
do
ssh root@paas0$seq.paas.domain.tw systemctl enable docker;
ssh root@paas0$seq.paas.domain.tw systemctl restart docker ;
ssh root@paas0$seq.paas.domain.tw echo pupaas0$seq done;
done
$ for seq in {1..5};
do
ssh root@paas0$seq.paas.domain.tw docker info | grep Version;
ssh root@paas0$seq.paas.domain.tw echo pupaas0$seq done;
done
此部分於部署節點 (此實驗採用 Master節點
) 啟用 EPEL 倉庫以安裝 Ansible
# 全局禁用EPEL套件庫,以便在安裝的後續步驟中不會有狀況
$ yum -y install epel-release;
$ yum -y --enablerepo=epel install ansible pyOpenSSL;
通過以上配置,及完成各個節點的事前配置