2018年6月14日木曜日

OpenShift Enterprise 3.7とTungstenFabric(OpenContrail)のインストール

今回はRedhat OpenShift EnterpriseとTungstenFabric(OpenContrailから名前変更)のインストール手順を解説します。

OpenShift EnterpriseはRedhatのRepositoryからダウンロードする必要があるため、Redhatのトライアルページより評価ライセンスを取得してください。
** OpenShift Originもありますが、3.7のインストール時に依存関係でうまくいかないのでEnterpriseを推奨します。

環境と構成
Master node: 192.168.0.3
Centos7.4 CPU 8 core, 32 GB Memory, 160 GB Disk
Slave Node: 192.168.0.4
Centos7.4 CPU 8 core, 32 GB Memory, 160 GB Disk

物理サーバでもKVM,ESXi上の仮想マシン、AWS,Azuruなどのパブリッククラウド上の仮想マシンでも動作します。

手順

  1. サーバ事前準備
  2. Redhat Subscriptionの登録
  3. パッケージインストール
  4. ansible playbookの作成
  5. ansible playbookの実行
  6. インストール確認
  7. OpenShiftユーザー登録

1.サーバ事前準備

Master nodeで証明書を作成し、すべてのサーバに公開鍵を登録する。
ssh-keygen を実行

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:PtKQwG9czoaofivrXhXa7lE4e9WBxwiREo49/0JzKjg root@telemetry1
The key's randomart image is:
+---[RSA 2048]----+
|      ..oo       |
|   . +. .. +     |
|    + =.. o +    |
|     B @   o .   |
|    o % S o .    |
|   . = X *       |
|  . E * B .      |
| ....o = o       |
| o=+...          |
+----[SHA256]-----+

公開鍵を登録

sudo cat .ssh/id_rsa.pub >> /root/.ssh/authorized_keys

Slave nodeにはid_rsa.pubをコピーし、同様にrootに鍵を登録する。

/etc/hostsの登録
すべてのサーバにホスト名でIPが引けるように設定。ドメイン含めた登録が必要

cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.3 openshift-1 openshift-1.localdomain
192.168.0.4 openshift-2 openshift-2.localdomain

接続確認
[root@openshift-1 ~]# ssh openshift-1.localdomain
The authenticity of host 'openshift-1.localdomain (192.168.0.3)' can't be established.
ECDSA key fingerprint is SHA256:mdqM+NSjkyew6ErUSGjBXPst/V9L34e2ik0f04RuLZo.
ECDSA key fingerprint is MD5:73:62:a6:55:d4:ab:4a:6d:94:0f:1f:f9:94:25:fd:55.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'openshift-1.localdomain' (ECDSA) to the list of known hosts.
Last login: Wed Jun 13 18:21:05 2018
[root@openshift-1 ~]#
[root@openshift-1 ~]#

2.Redhat Subscriptionの登録

RedhatのWeb サイトで取得したユーザーをすべてのノードに登録します。

subscription-manager register --username (username) --password (password) --force

サブスクリプションをすべてのノードの登録します。
subscription-manager list --available --matches '*OpenShift*'
subscription-manager attach --pool=(pool-ID)

不要なRepositoryを無効にし、必要なもののみ有効にします。
subscription-manager repos --disable="*"
subscription-manager repos \
                --enable="rhel-7-server-rpms" \
                --enable="rhel-7-server-extras-rpms" \
                --enable="rhel-7-server-ose-3.7-rpms" \
                --enable="rhel-7-fast-datapath-rpms"

3.パッケージインストール

必要パッケージをインストールします。
yum install wget -y && wget -O /tmp/epel-release-latest-7.noarch.rpm https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && rpm -ivh /tmp/epel-release-latest-7.noarch.rpm
sudo rpm --import "https://sks-keyservers.net/pks/lookup?op=get&search=0xee6d536cf7dc86e2d7d56f59a178ac6c6238f52e"
yum update -y
yum install atomic-openshift-excluder atomic-openshift-utils git python-netaddr ansible ntp -y
atomic-openshift-excluder unexclude -y

systemctl stop ntpd
ntpdate -s ntp.nict.jp
systemctl start ntpd

git clone https://github.com/savithruml/openshift-ansible -b contrail-openshift
wget -O /root/openshift-ansible/inventory/byo/ose-prerequisites.yml https://raw.githubusercontent.com/savithruml/openshift-contrail/master/openshift/install-files/all-in-one/ose-prerequisites.yml
wget -O /root/openshift-ansible/inventory/byo/ose-install https://raw.githubusercontent.com/savithruml/openshift-contrail/master/openshift/install-files/all-in-one/ose-install

4.ansible playbookの作成

contrail-openshiftへ移動
cd contrail-openshift

inventory/byo/ose-installファイルの修正 Githubにサンプルをアップロードしています。下の方のIPアドレスとホスト名を環境に合わせて変更してください。

5.ansible playbookの実行

Ansible Playbookを実行します。
ansible-playbook -i inventory/byo/ose-install inventory/byo/ose-prerequisites.yml
ansible-playbook -i inventory/byo/ose-install playbooks/byo/openshift_facts.yml
ansible-playbook -i inventory/byo/ose-install playbooks/byo/config.yml
なにもエラーが無く終了したら完了です。
うまくいかない場合、TungstenFabricのSlackチャネル#users_japaneseまで質問を投げてください。日本語で質問できます。

終了したらSlave nodeをリブートします。
ssh 192.168.0.4 reboot

6.インストール確認

oc get pod -n kube-systemをMaster nodeで実行し、パッケージが正常かどうしているか確認します。
以下のようにCrashLoopBackOffやImagePullBackOffが表示される場合があります。
oc get pod -n kube-system
NAME                                 READY     STATUS             RESTARTS   AGE
config-zookeeper-t5246               1/1       Running            0          8h
contrail-agent-5bftt                 2/2       Running            6          9m
contrail-analytics-2gttb             7/7       Running            5          17m
contrail-analytics-zookeeper-jbdjd   1/1       Running            0          8h
contrail-analyticsdb-4bz9w           2/2       Running            1          17m
contrail-configdb-cb4db              1/1       Running            0          17m
contrail-controller-config-xmtmd     5/5       Running            0          13m
contrail-controller-control-jxrmw    4/4       Running            3          12m
contrail-controller-webui-5xg58      0/2       CrashLoopBackOff   12         9m
contrail-kube-manager-48bl5          1/1       Running            0          8h
kafka-26kmm                          1/1       Running            0          8h
rabbitmq-dnwnb                       1/1       Running            0          8h
redis-x2t5t                          1/1       Running            0          8h

ImagePullBackOffの場合は/etc/resolve.confが自身のIPアドレスに変更されているため、修正してください。
CrashLoopBackOffの場合は一度PODを削除して再作成されるのを待ってください。
oc delete pod -n kube-system config-zookeeper-t5246 など

contrail-controller-webuiがCrashLoopBackOffの場合、構成ファイルを修正してください。
oc edit configmap env -n kube-systemを実行し、"ANALYTICS_API_VIP:"と"CONFIG_API_VIP:"を削除したあと、oc delete pod -n kube-system contrail-kube-manager-xxxx を実行し、暫く待つとRunningになります。
oc get pod -n kube-systemを実行し、以下のようにすべてRunningになれば終了です。
oc get pod -n kube-system
NAME                                 READY     STATUS    RESTARTS   AGE
config-zookeeper-t5246               1/1       Running   0          8h
contrail-agent-5bftt                 2/2       Running   6          25m
contrail-analytics-2gttb             7/7       Running   5          33m
contrail-analytics-zookeeper-jbdjd   1/1       Running   0          8h
contrail-analyticsdb-4bz9w           2/2       Running   1          33m
contrail-configdb-cb4db              1/1       Running   0          33m
contrail-controller-config-xmtmd     5/5       Running   0          29m
contrail-controller-control-jxrmw    4/4       Running   3          28m
contrail-controller-webui-psbjt      2/2       Running   0          1m
contrail-kube-manager-48bl5          1/1       Running   0          8h
kafka-26kmm                          1/1       Running   0          8h
rabbitmq-dnwnb                       1/1       Running   0          8h
redis-x2t5t                          1/1       Running   0          8h

7.OpenShiftユーザー登録

OpenShiftで使用するユーザーを登録します。

htpasswd /etc/origin/master/htpasswd admin
oadm policy add-cluster-role-to-user cluster-admin admin

最後にWebUIにアクセスできるか確認します。
OpenShift Enterprise WebUI : https://192.168.0.3:8443 admin/上で設定したパスワード
TungstenFabric WebUI : https://192.168.0.3:8143 admin/contrail123
** エラーがありますが、Process Failure やA Core File has been generatedは表示上の問題ですので無視してください。

リモートからアクセスでいない場合、iptablesに引っかかっています。
iptables -I INPUT -j ACCEPTなどで8443や8143ポートを開けてください。

** PODの作成やFirewallの作成は6/16更新予定です。
**更新しました

0 件のコメント:

コメントを投稿