8
3

More than 3 years have passed since last update.

Red Hat OpenShift Service on AWS(ROSA)を動かしてみた!

Last updated at Posted at 2021-03-29

※ 2021/04/15 ログイン方法について追記

こんにちは!

今回はAWSで新しくGAしたサービスのRed Hat OpenShift Service on AWS(ROSA)についての記事となります。

そもそもROSAとは「AWSでマネージドされたOpenshift」となります。今までOpenshiftをAWSで利用しようと思うと、自分で構築する必要がありMasterNodeの管理なども自身でおこなわなければならず少しハードルが高かったです。

今回登場したROSAを利用することでAWSマネージドサービスとしてOpenshiftが使えるのは使い勝手上がるのでないかと思います。

Openshiftを利用するメリット

  • 学習コストを抑えられる
    • オンプレでもパブリッククラウドでも同じ機能・UIを利用することができる
  • Kubernetesのディストリビューションの中でもかなりメジャー
    • 金融などでも実績がある

そんなOpenshiftですがAWS上で利用しようすると先述のように管理のオーバーヘッドが大きかったのですが、ROSAでクイック(実際そんなにクイックじゃないかもですが)に構築できるのはうれしいですね!

構築編

せっかくなので実際に動かしてみました!

しかし、AWSマネージドコンソールからROSAに行くと「有効化」のボタンしかありません。有効化しても「有効化しました」っと表示されるだけです。。。。CLIを利用するようです。

事前準備(rosaコマンドのインストール)

ROSAを利用すためにはコマンドラインから実行する必要があるようです。

「rosa」コマンドを以下よりダウンロードして実行できるように準備してください。

ROSA CLI Downloads | Red Hat OpenShift Service on AWS

ちなみ私はLinux版をダウンロードしましたが、シンプルにtar.gzにrosaがあるだけでした^^;

事前準備(AWSアカウント)

アクセスキーとシークレットキーが必要になります。またRegionの設定をしていないとエラーになります。

$ cat ~/.aws/credentials 
[default]
aws_access_key_id     = AKIxxxxxxxxxxxxxx
aws_secret_access_key = *******************************
region = ap-northeast-1 #リージョンの指定がないとエラーになる

事前準備(ocコマンド)

ocコマンドにPATHが通っている必要があります。

ない場合は以下のようなエラーが表示されます。

W: OpenShift command-line tool is not installed.
Run 'rosa download oc' to download the latest version, then add it to your PATH.

ocコマンドは以下より手順よりインストールできます。

Getting started with the OpenShift CLI - OpenShift CLI (oc) | CLI tools | OpenShift Container Platform 4.7

事前準備(Redhatアカウント)

RedhatのHPよりトークンを取得する必要があるので事前に登録しておくとよいでしょう。

事前準備(Gitlabアカウント)

OAuthを利用してOpenshiftへログインします。今回私はGitLabと連携させました。(一番簡単そう。。。)

そのため、Gitlabのアカウントを用意しました。

クラスター構築

手順は以下を参考にしています。

Getting started with Red Hat OpenShift Service on AWS

  1. 初期設定

    最初に起動するとRedhatアカウントからTokenを取得するし入力します。

    $ rosa init
    To login to your Red Hat account, get an offline access token at https://cloud.redhat.com/openshift/token/rosa
    ? Copy the token and paste it here: #取得したトークンをここに貼り付ける
    

    https://cloud.redhat.com/openshift/token/rosa にアクセスするとRedhatアカウントの入力が求められます。

    入力後以下のようなトークンが表示されます。こちらで取得したトークンを上記に貼り付けます。

    スクリーンショット 2021-03-29 22.41.19 2.png

    正常に初期設定が完了すると以下のようになります。

    $ rosa init
    ---
    ./rosa init
    I: Logged in as 'xxxxxx@xxxxx' on 'https://api.openshift.com'
    I: Validating AWS credentials...
    I: AWS credentials are valid!
    I: Validating SCP policies...
    I: AWS SCP policies ok
    I: Validating AWS quota...
    I: AWS quota ok
    I: Ensuring cluster administrator user 'osdCcsAdmin'...
    I: Admin user 'osdCcsAdmin' already exists!
    I: Validating SCP policies for 'osdCcsAdmin'...
    I: AWS SCP policies ok
    I: Validating cluster creation...
    I: Cluster creation valid
    I: Verifying whether OpenShift command-line tool is available...
    I: Current OpenShift Client Version: 4.7.0
    
  2. クラスター作成

    $ rosa create cluster --cluster-name <cluster_name>
    ---以下実行結果---
    $ ./rosa create cluster --cluster-name xxx
    
    I: Creating cluster 'xxx'
    I: To view a list of clusters and their status, run 'rosa list clusters'
    I: Cluster 'xxx' has been created.
    I: Once the cluster is installed you will need to add an Identity Provider before you can login into the cluster. See 'rosa create idp --help' for more information.
    I: To determine when your cluster is Ready, run 'rosa describe cluster -c xxx'.
    I: To watch your cluster installation logs, run 'rosa logs install -c xxxx --watch'.
    Name:                       xxx
    ID:                         xxxxxxxxxxxxxxxxx
    External ID:                
    OpenShift Version:          
    Channel Group:              stable
    DNS:                        xxxxx.zcab.p1.openshiftapps.com
    AWS Account:                xxxxxxxxxx
    API URL:                    
    Console URL:                
    Region:                     ap-northeast-1
    Multi-AZ:                   false
    Nodes:
     - Master:                  3
     - Infra:                   2
     - Compute:                 2 (m5.xlarge)
    Network:
     - Service CIDR:            172.30.0.0/16
     - Machine CIDR:            10.0.0.0/16
     - Pod CIDR:                10.128.0.0/14
     - Host Prefix:             /23
    State:                      pending (Preparing account)
    Private:                    No
    Created:                    xxxxxx
    Details Page:               https://cloud.redhat.com/openshift/details/1jks9vqnnffm5i35f6tgitkbe848qrbd
    
  3. IDPの設定
    IDPの準備ができない方はrosa create admin -c <cluster_name>を利用するもう少し簡単にログインができます。
    詳細は下記に!

    $ rosa create idp --cluster <cluster_name> --interactive
    ---以下実行結果---
    $ ./rosa create idp --cluster xxx --interactive
    I: Interactive mode enabled.
    Any optional fields can be left empty and a default will be selected.
    ? Type of identity provider:  [Use arrows to move, type to filter]
    > github
      gitlab
      google
      ldap
      openid
    

    今回は「gitlab」を選択して利用しました。「openid」に対応していれば何でもいけそうです。

  4. 権限付与

    $ rosa grant user dedicated-admin --user <idp_user_name> --cluster <cluster_name>
    ---実行ログ---
    ./rosa grant user dedicated-admin --user yusuer --cluster xxx
    I: Granted role 'dedicated-admins' to user 'yusuer' on cluster 'xxx'
    
    
  5. クラスタの詳細確認

    $ rosa describe cluster <cluster_name> #←このコマンドだと動かなかった
    $ rosa describe cluster --cluster=<cluster_name> #←こちらは動作した
    ---以下実行結果---
    ./rosa describe cluster --cluster=xxx
    Name:                       xxx
    ID:                         xxxxxxxxxxxxx
    External ID:                xxxxxxxxxxxxx
    OpenShift Version:          4.7.2
    Channel Group:              stable
    DNS:                        xxx.xxxx.p1.openshiftapps.com
    AWS Account:                000000000000
    API URL:                    https://api.xxx.p1.openshiftapps.com:6443
    Console URL:                https://console-openshift-console.apps.xxx.xxxx.p1.openshiftapps.com
    Region:                     ap-northeast-1
    Multi-AZ:                   false
    Nodes:
     - Master:                  3
     - Infra:                   2
     - Compute:                 2 (m5.xlarge)
    Network:
     - Service CIDR:            172.30.0.0/16
     - Machine CIDR:            10.0.0.0/16
     - Pod CIDR:                10.128.0.0/14
     - Host Prefix:             /23
    State:                      ready 
    Private:                    No
    Created:                    Mar 29 2021 01:05:19 UTC
    Details Page:               https://cloud.redhat.com/openshift/details/xxxxxxxxxxx
    
  6. ログイン確認
    「Console URL」のURLよりログインを可能かをテストします。
    スクリーンショット 2021-03-30 0.21.26.png

    私の場合は「gitlab-1」をクリックして、Gitlabとアカウント連携を実施してログインしました。

2021/04/15追記

IDPの準備ができない方は rosa create admin -c <cluster_name> を利用することでadminのユーザを作ることが
可能です!

$ rosa create admin -c <cluster_name>
W: It is recommended to add an identity provider to login to this cluster. See 'rosa create idp --help' for more information.
I: Admin account has been added to cluster 'xxx'.
I: Please securely store this generated password. If you lose this password you can delete and recreate the cluster admin user.
I: To login, run the following command:

   oc login https://api.xxx.agpp.p1.openshiftapps.com:6443 --username cluster-admin --password <パスワードが表示される>

まとめ

IDPの設定は少し手こずりましたが、その他は比較的簡単に動作させることができました。デフォルトだと単一AZへのデプロイとなっていますので、マルチAZでのデプロイなども試してみたいと思います。また、Gitlab外のIDPの設定にもチャレンジしてみよかと思いました。
かなりざっくりたテストでしたが、ROSAについて雰囲気だけでも伝われば幸いです。
少し長くなりましたが、今後ROSAをしっかり使っていこうかと思います!!!!

間違っている点や気になる点があればお気軽にご質問ください。

8
3
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
8
3