LoginSignup
0
0

More than 3 years have passed since last update.

OpenShift Container Platform 4 をIPIインストールする

Last updated at Posted at 2020-06-24

はじめに

本記事では

  • OpenShift 4 をAWS上にIPIインストールする
    • IPIとはinstaller-provisioned infrastructure
    • IPIの他にUPI(user-provisioned infrastructure)インストールがある

方法を扱います。参考文献はこちらです。

AWSの準備

Route 53

以下のいずれかで、好き勝手レコード登録できるHosted Zoneを準備する

  • Route 53でドメイン取得
  • 他のRegisterで取得したドメインをAWSに移管
  • 既にRoute 53上のHosted Zoneからサブドメインを切り出す

IAM User

以下の要件でユーザを作成し、Access Key IDとSecret Access Keyを控える。

  • ユーザ名をipiuser(なんでもいい)
  • アクセスの種類をプログラムによるアクセス
  • ポリシーをAdministratorAccess

ここからすぐにインストール開始したい場合

こちらの手順を実行してください。

少しyamlを変える

こちらの手順に沿って、気持ち程度ですが、お財布に優しいOpenShiftを作ります。

気持ち程度、お財布に優しくしたい

以下の方針で作成したいと思います。

  • m5系のインスタンスタイプで構成したい
    • デフォルトだとm4系で作成される
    • m5系の方が気持ち程度安い
  • replicaを減らしたかった(無理だった)

ssh秘密鍵をssh-agentにセットする

鍵を作成する

$ ssh-keygen -t rsa -b 4096 -N '' -f ~/.ssh/id_rsa
Generating public/private rsa key pair.
Your identification has been saved in /home/openshift/.ssh/id_rsa.
Your public key has been saved in /home/openshift/.ssh/id_rsa.pub.
The key fingerprint is:
...snip...

ssh-agentプロセスをバックグラウンド実行する

$ eval "$(ssh-agent -s)"
Agent pid 1259

鍵を追加する

$ ssh-add ~/.ssh/id_rsa
Identity added: /home/openshift/.ssh/id_rsa (/home/openshift/.ssh/id_rsa)

インストーラのダウンロード

こちらからダウンロードする。

  • Select OSはLinux

tar.gzを解凍する

$ tar xvf ./openshift-install-linux.tar.gz

インストール設定ファイルを作る

配置場所を作る

$ mkdir installation

インストール設定ファイルの雛形を作る

$ ./openshift-install create install-config --dir=./installation/

プロンプト上で以下を聞かれるので、入力する

  • ? SSH Public Key
    • 作成した秘密鍵のファイルパス(Enterでいけた)
  • ? Platform
    • aws
  • ? AWS Access Key ID
    • IAM UserのAccess Key ID
  • ? AWS Secret Access Key
    • IAM UserのSecret Access Key
  • ? Region
    • ap-northeast-1
  • ? Base Domain
    • 好き勝手できるRoute 53のドメイン名を書く(Enterでいけた)
  • ? Cluster Name
    • 適当な名前を入力
  • ? Pull Secret

作成されていることを確認

$ ll installation/
合計 4
-rw-r-----. 1 openshift openshift 3305  6月 19 23:16 install-config.yaml

お財布に優しいyamlに変更する

  • replica数をmasterを3に、workerを3
    • replicaの数を減らすとインストールに失敗する
    • インスタンスタイプを大きくすると行けるかもしれないが、未検証
  • インスタンスタイプをmasterをm5.xlargeに、workerをm5.large
installation/install-config.yaml 
apiVersion: v1
baseDomain: ...snip...
compute:
- architecture: amd64
  hyperthreading: Enabled
  name: worker
  platform:
    aws:
      type: m5.large
  replicas: 3
controlPlane:
  architecture: amd64
  hyperthreading: Enabled
  name: master
  platform:
    aws:
      type: m5.xlarge
  replicas: 3
metadata:
  creationTimestamp: null
  name: pov
networking:
  clusterNetwork:
  - cidr: 10.128.0.0/14
    hostPrefix: 23
  machineNetwork:
  - cidr: 10.0.0.0/16
  networkType: OpenShiftSDN
  serviceNetwork:
  - 172.30.0.0/16
platform:
  aws:
    region: ap-northeast-1
publish: External
pullSecret: ...snip...
sshKey: ...snip...

クラスターをデプロイする

デプロイコマンドを実行する

$ ./openshift-install create cluster --dir=./installation/ --log-level=info

(case) デプロイに失敗した時

自動で消えたりはしないので、デストロイコマンドを実行する

$ ./openshift-install destroy cluster --dir=./installation/ --log-level=info

(option) IAM Userのポリシー変更

インストーラーにセットしたIAM Userが保持している権限を剥奪しておく

  • ポリシーのAdministratorAccessを外す

コンソールログイン

インストーラが走り終わったら、以下のログが出ているので、この情報を使ってログインする

INFO Install complete!
INFO To access the cluster as the system:admin user when using 'oc', run 'export KUBECONFIG=/opt/ocp/installation/auth/kubeconfig' 
INFO Access the OpenShift web-console here: https://console-openshift-console.apps.pov.ocp.example.com
INFO Login to the console with user: kubeadmin, password: xxxxx-xxxxx-xxxxx-xxxxx

おしまい。大きなサーバなので、使っていないときは落とそう。(EIPはお金かかるけど。)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0