OpenShift Origin 3.9のインストール
OpenShift Origin 3.9のセットアップ手順メモ。
前提条件は以下の通り。
- OpenShift用DNSサーバ(dnsmasq)、OpenShift Master 1台、 Node 1台
- VirtualBoxのブリッジネットワーク上に構成
- ゲストマシンのOSは全てCentOS7
DNSサーバのセットアップ
・dnsmasqのインストール
# yum install -y dnsmasq
・/etc/hostsのの追記
dnsmasqは/etc/hostsを設定ファイルとして読み込み、名前解決を行う。
192.168.11.10 dns dns.openshift.example.com 192.168.11.11 master master.openshift.example.com 192.168.11.12 node01 node01.openshift.example.com
・/etc/dnsmasq.confの編集
DNSクエリ要求に応答するドメインの設定(local=)、Route用のワイルドカードDNS(address=)、DNSリクエスト待ち受けのネットワークインタフェース(interface=)、DHCPサーバ機能の無効化(no-dhcp-interface=)を設定。
# diff -u /etc/dnsmasq.conf.org /etc/dnsmasq.conf --- /etc/dnsmasq.conf.org 2018-05-26 12:08:03.447080188 +0900 +++ /etc/dnsmasq.conf 2018-05-26 15:02:48.609040878 +0900 @@ -72,11 +72,13 @@ # Add local-only domains here, queries in these domains are answered # from /etc/hosts or DHCP only. #local=/localnet/ +local=/openshift.example.com/ # Add domains which you want to force to an IP address here. # The example below send any host in double-click.net to a local # web-server. #address=/double-click.net/127.0.0.1 +address=/cloudapps.example.com/192.168.11.11 # --address (and --server) work with IPv6 addresses too. #address=/www.thekelleys.org.uk/fe80::20d:60ff:fe36:f83 @@ -103,7 +105,7 @@ # specified interfaces (and the loopback) give the name of the # interface (eg eth0) here. # Repeat the line for more than one interface. -#interface= +interface=enp0s3 # Or you can specify which interface _not_ to listen on #except-interface= # Or which to listen on by address (remember to include 127.0.0.1 if @@ -112,7 +114,7 @@ # If you want dnsmasq to provide only DNS service on an interface, # configure it as shown above, and then use the following line to # disable DHCP and TFTP on it. -#no-dhcp-interface= +no-dhcp-interface=enp0s3 # On systems which support it, dnsmasq binds the wildcard address, # even when it is listening on only some interfaces. It then discards
・DNSサーバの起動
ここではあくまでローカルの実験用環境のため、DNSリクエストのポート53へのアクセス許可はfirewalldを切って対処。
# systemctl stop firewalld # systemctl disable firewalld # systemctl enable dnsmasq # systemctl start dnsmasq
・DNSサーバのネットワーク設定
DNS1はOpenShift用に起動した内部ネットワーク用のdnsmasqサーバ。DNS2はWebアクセス用のDNSサーバ。
# vim /etc/sysconfig/network-scripts/ifcfg-enp0s3 TYPE=Ethernet BOOTPROTO=none NAME=enp0s3 UUID=4590c759-b0cd-4dc2-9f43-779201c6593c DEVICE=enp0s3 ONBOOT=yes IPADDR=192.168.11.10 PREFIX=24 GATEWAY=192.168.1.1 DNS1=127.0.0.1 DNS2=192.168.11.1 # hostnamectl set-hostname dns.openshift.example.com # systemctl restart network
Masterのセットアップ
・Masterサーバのネットワーク設定
# vim /etc/sysconfig/network-scripts/ifcfg-enp0s3 TYPE=Ethernet BOOTPROTO=none NAME=enp0s3 UUID=4590c759-b0cd-4dc2-9f43-779201c6593c DEVICE=enp0s3 ONBOOT=yes IPADDR=192.168.11.11 PREFIX=24 GATEWAY=192.168.11.1 DNS1=192.168.11.10 # hostnamectl set-hostname master.openshift.example.com # systemctl restart network
・必要パッケージのインストール
# yum install -y wget git net-tools bind-utils yum-utils iptables-services bridge-utils bash-completion kexec-tools sos psacct unzip # yum update # systemctl reboot
OpenShift公式ドキュメントのHost Preparation Installing Base Packagesの通りにインストールすると、後述のAnsibleによるインストール時に以下のエラーが発生したため、unzipのインストールを追加している。
TASK [etcd : Unarchive cert tarball] ************************************************************************************** fatal: [master.openshift.example.com]: FAILED! => {"changed": false, "msg": "Failed to find handler for \"~None/.ansible/tmp/ansible-tmp-1527315221.2-254636300880053/source\". Make sure the required command to extract the file is installed. Command \"unzip\" not found. Command \"/usr/bin/gtar\" could not handle archive."}
・Advanced Instllationに必要なパッケージのインストール
# yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm # sed -i -e "s/^enabled=1/enabled=0/" /etc/yum.repos.d/epel.repo # yum -y --enablerepo=epel install ansible pyOpenSSL
・OpenShift3.9のダウンロード
# cd ~ # git clone https://github.com/openshift/openshift-ansible # cd openshift-ansible # git checkout release-3.9
・Dockerのインストール
# yum install -y docker-1.13.1 # systemctl enable docker # systemctl start docker
Nodeのセットアップ
・Nodeサーバのネットワーク設定
# vim /etc/sysconfig/network-scripts/ifcfg-enp0s3 TYPE=Ethernet BOOTPROTO=none NAME=enp0s3 UUID=4590c759-b0cd-4dc2-9f43-779201c6593c DEVICE=enp0s3 ONBOOT=yes IPADDR=192.168.11.12 PREFIX=24 GATEWAY=192.168.11.1 DNS1=192.168.11.10 # hostnamectl set-hostname node01.openshift.example.com # systemctl restart network
・必要パッケージのインストール
Masterと同じパッケージをインストール
# yum install -y wget git net-tools bind-utils yum-utils iptables-services bridge-utils bash-completion kexec-tools sos psacct unzip # yum update # systemctl reboot
・Dockerのインストール
# yum install -y docker-1.13.1 # systemctl enable docker # systemctl start docker
OpenShift Originのインストール
Masterサーバ上で以下を実行する。
・SSHログイン時の対話型パスワード入力の抑止
# ssh-keygen # for host in master.openshift.example.com node01.openshift.example.com; do ssh-copy-id -i ~/.ssh/id_rsa.pub $host; done
・/etc/ansible/hostsの設定
[OSEv3:children] masters nodes etcd [OSEv3:vars] ansible_ssh_user=root openshift_deployment_type=origin openshift_master_default_subdomain=cloudapps.example.com openshift_disable_check=memory_availability,disk_availability [masters] master.openshift.example.com [etcd] master.openshift.example.com [nodes] master.openshift.example.com openshift_node_labels="{'region': 'infra', 'zone': 'default'}" node01.openshift.example.com openshift_node_labels="{'region': 'primary', 'zone': 'default'}"
・OpenShiftインストールの実行
# ansible-playbook -i /etc/ansible/hosts ~/openshift-ansible/playbooks/prerequisites.yml # ansible-playbook -i /etc/ansible/hosts ~/openshift-ansible/playbooks/deploy_cluster.yml
インストール後の初期セットアップ
後日追記予定