Red HatでOpenShiftのサポートをしているid:nekopです。OpenShift 4.1が本日リリースされたので、インストールしてみます。
今回はAWSを利用して一番簡単なほぼ全自動のIPI(インストーラによるインフラ作成インストール)というインストールを行います。IPIではRed Hat CoreOSが利用されます。IPIの他に、ホストなどを自前で用意するUPI(ユーザによるインフラ作成インストール)というインストール方法もあります。
AWS IPIではRoute 53上で管理可能なPublic Domainが必要なので、ドメインを取得する、もしくは所持しているドメインのサブドメインをRoute 53に作成して、親ドメインから委任設定する必要があります。下記例示に利用しているshift.example.com
は実際には存在しないドメインです。
最初にinstall-config.yml
を作成して、バックアップを作成しておきます。install-config.yml
ファイルはインストール実行時に消去されるので、インストールを試行錯誤する場合に取っておいたほうがラクです。個人的には実際にはgit init
してGitで管理しています。
$ ./openshift-install create install-config ? SSH Public Key /home/nekop/.ssh/id_rsa.pub ? Platform aws ? Region ap-northeast-1 ? Base Domain shift.example.com ? Cluster Name tkimura ? Pull Secret [? for help] ***** # ダウンロードしたpull secretをここにコピー&ペースト $ cp -a install-config.yml{,org}
自分が利用しているAWSアカウントでは、ap-northeast-1a
がCapacity Constrained
だそうで、subnetが作成できないなどの利用制限があったのでinstall-config.yml
をカスタマイズして利用するゾーンを指定します。install-config.yml
にはplatform
という項目が3回出現しますが、それに全て以下のようにzonesを指定します。
platform: aws: zones: - ap-northeast-1c - ap-northeast-1d
編集して上記を反映、再バックアップします。
$ vi install-config.yml $ cp -a install-config.yml{,.modified}
クラスタを作成します。このステップは30分程度かかりますが、基本的に何もすることはなく待っているだけです。デフォルトで3 masters 3 nodes構成ですが、mastersの数はよっぽどのことがない限り3で問題ないですし、nodesの数はoc scale machineset tkimura-xxxxx-worker-ap-northeast-1c --replicas=5
というようなオペレーションでいつでも増減できるのであまり気にしなくて良いです。
$ ./openshift-install create cluster INFO Creating infrastructure resources... INFO Waiting up to 30m0s for the Kubernetes API at https://api.tkimura.shift.example.com:6443... INFO API v1.13.4+838b4fa up INFO Waiting up to 30m0s for bootstrapping to complete... INFO Destroying the bootstrap resources... INFO Waiting up to 30m0s for the cluster at https://api.tkimura.shift.example.com:6443 to initialize... INFO Waiting up to 10m0s for the openshift-console route to be created... INFO Install complete! INFO To access the cluster as the system:admin user when using 'oc', run 'export KUBECONFIG=/home/nekop/ocp4/auth/kubeconfig' INFO Access the OpenShift web-console here: https://console-openshift-console.apps.tkimura.shift.example.com INFO Login to the console with user: kubeadmin, password: xxxxx-xxxxx-xxxxx-xxxxx
インストールの各フェーズにかかった時間はおおむね以下となりました。
- masterとbootstrap、基本インフラ作成 7分 (うちamiコピー5分)
- master/etcdの起動完了 10分
- bootstrap完了 5分
- クラスタオペレータの完了(ワーカーノード起動も含む) 9分
インストーラーは最初に3 mastersと1つのbootstrapというインスタンスを作成します。OpenShift 4では、masterが自律的にmasterの設定やアップデートを行うようになっていますが、最初のmasterが存在しない状態では何も実行できないので、bootstrapという初期設定を行うmasterが実行され、bootstrapによって最初の3 mastersが設定されます。
最後にインストール時のログを抜き出したものを載せておきます。
time="2019-06-04T15:33:46+09:00" level=debug msg="OpenShift Installer v4.1.0-201905212232-dirty" time="2019-06-04T15:34:08+09:00" level=info msg="Creating infrastructure resources..." time="2019-06-04T15:34:23+09:00" level=debug msg="aws_ami_copy.main: Creating..." time="2019-06-04T15:39:42+09:00" level=debug msg="aws_ami_copy.main: Creation complete after 5m18s (ID: ami-0673c877e07ae917b)" time="2019-06-04T15:40:42+09:00" level=debug msg="Apply complete! Resources: 109 added, 0 changed, 0 destroyed." time="2019-06-04T15:40:42+09:00" level=info msg="Waiting up to 30m0s for the Kubernetes API at https://api.tkimura.shift.example.com:6443..." time="2019-06-04T15:50:54+09:00" level=info msg="API v1.13.4+838b4fa up" time="2019-06-04T15:50:54+09:00" level=info msg="Waiting up to 30m0s for bootstrapping to complete..." time="2019-06-04T15:55:44+09:00" level=debug msg="Bootstrap status: complete" time="2019-06-04T15:55:44+09:00" level=info msg="Destroying the bootstrap resources..." time="2019-06-04T15:56:29+09:00" level=debug msg="Destroy complete! Resources: 12 destroyed." time="2019-06-04T15:56:29+09:00" level=info msg="Waiting up to 30m0s for the cluster at https://api.tkimura.shift.example.com:6443 to initialize..." time="2019-06-04T16:07:56+09:00" level=debug msg="Cluster is initialized" time="2019-06-04T16:07:56+09:00" level=info msg="Install complete!"
これでインストールは完了です。インストールプロセスの詳細などは以下のblogが詳しいです。
Red Hatでは運用が簡単なKubernetesディストリビューション製品OpenShiftを一緒に育てるエンジニアを募集しております!
https://global-redhat.icims.com/jobs/68813/software-maintenance-engineer---openshift/jobglobal-redhat.icims.com