AWSとAzure 上で、テンプレートを利用して簡単にOpenShiftがデプロイできるようになったので、その方法を2回に分けてご紹介します。
BYOL を利用するメリット
OpenShift DedicatedのようなマネージドなOpenShift環境では、管理せずに利用することができるので、すぐに使いたいというニーズにあっています。一方で、インフラ管理面などは管理者に依存する部分もあるので、インフラを自由に構成することが難しいという点もあります。
インフラ構成や管理は自分たちでできるけど、構築の手間はかけずにすぐに環境が欲しいという場合には非常に有効な方法です。
作業の流れは、AWS、Azureのいずれの場合も 1. クラウドアクセスの登録 2. テンプレートを選択してデプロイ
まず、1回目はAzureへのデプロイ方法をご紹介します。
Azureでのインフラ構成
Azureでは3種類の構成が選択できるようになっています。
Small
シングルマスター構成の小さな環境です。まずは、ちょっと使ってみようという場合に手軽に利用できる環境です。
種別 | ノード数 |
---|---|
Master | 1 |
Infranode | 1 |
Application Node | 2 |
Bastion Host | 1 |
合計 | 5インスタンス, 10core |
Medium
HA構成の小さな環境です。HA構成で使ってみようという場合に手軽に利用できる環境です。
種別 | ノード数 |
---|---|
Master | 3 |
Infranode | 2 |
Application Node | 4 |
Bastion Host | 1 |
合計 | 10インスタンス、38core |
Large
HA構成で中くらいの環境です。HA構成である程度の数のアプリケーションを実行するために利用できる環境です。
種別 | ノード数 |
---|---|
Master | 3 |
Infranode | 2 |
Application Node | 6 |
Bastion Host | 1 |
合計 | 12インスタンス、70core |
OpenShiftの構成
ユーザ認証
認証方式はhtpasswdになっており、ファイルはMasterサーバの/etc/orign/master/htpasswd
ファイルです。 初期状態では、clusteradminというユーザにウィザードの3ステップ目で指定したOpenShift Admin User Passwordが設定されています。 OpenShiftの管理コンソールへログインするためのユーザ認証は、HTTDPassword方式になってoインストール直後はclusteradminユーザにウィザードで設定したパスワードが設定されています。マスターサーバのホスト名
Masterサーバにはクライアントからアクセスするためのパブリックなホスト名とIPアドレスが付与されています。 命名規則はmasterdns<暗号みたいな文字列>.<データセンターのリージョン名>.cloudapp.azure.com
となっています。アプリケーションのサブドメイン名
<マスターサーバのIPアドレス>.nip.io
Persistent Storage
Persistent Storageは作成されていないので、必要に応じて別途準備する必要があります。
構成などなどがわかったところで、BYOL(Bring Your Own License)のテンプレートを使ってAzureにOpenShiftをデプロイしていきましょう。
デプロイの準備
Red Hat Cloud Access への登録や、BYOLでのデプロイ途中で必要な情報を取得しておきます。
AzureのSubscription
Azure PortalにログインしてSubscriptionsを参照して、自分のSUBSCRIPTION IDをチェックします。
Red HatのSubscription
Subscriptionが割り当てられている Account と PoolID を確認します。
デプロイの作業
BYOLを利用してデプロイするには、2つのリソースグループを利用します。 一つはkeyvaultを登録しておくもの、もう一つはOpenShiftのクラスタを構築するものです。
Red Hat Cloud Accessの登録
Red Hat Cloud Access のサイトから登録します。
# | パラメータ名 | 値 | 備考 |
---|---|---|---|
1 | Cloud Provider | Microsoft Azure | プルダウンメニューから選択 |
2 | Microsoft Subscription Number/s | Azure Portalで確認したSubscriptionIDを入力 | |
3 | Product Name | 割り当てらているOpenShiftのサブスクリプションを選択 | |
4 | Quantity | 必要な本数を設定。Azureの場合は、2coreモデルのサブスクリプションが適用されるので、必要な Core数の満たす分を登録。smallならばApplicationNodeは2core x 2ノードなので2です。ただし、検証用Subscriptionの場合には、Master/Infranode分が含まれていませんので、Small の場合 10core / 2 = 5本となります。 |
登録が完了すると証明書のような画面が表示されます。
Azureでのデプロイ
Keyvaultの作成
OpenShiftのインストールにはansibleを利用します。bationサーバからMaster/Nodeに鍵認証でアクセスするため、事前にkeyvaultを作成します。
- RSA の鍵作成
% ssh-keygen
- 作成した鍵を使って Secret 登録
% az group create --name examplegroup --location 'South Central US’ % az keyvault create \ --name myvault \ --resource-group examplegroup\ --location 'South Central US' \ --enabled-for-template-deployment true % az keyvault secret set --vault-name myvault --name mysecret --file ./id_rsa
OpenShiftのデプロイ
Market PlaceからBYOLのテンプレートの選択 検索キーワードに"OpenShift"を入力して検索し、「Red Hat OpenShift Container Platform (BYOL)」を選択します。
ウィザード開始 テンプレートの詳細を確認し、画面下部の"Create"ボタンをクリックしてウィザードを開始します。
パラメータ入力
1 Basic Configure basic settings
以下のパラメータを入力します。
# | パラメータ名 | 値 | 備考 |
---|---|---|---|
1 | VM Admin UserName | clusteradmin | 仮想サーバへSSHでログインするためのユーザを指定 |
2 | SSH Public Key for VM Admin User | 仮想サーバへSSHでログインするための公開鍵を指定 | |
3 | Subscription | 利用可能なAzureのサブスクリプションをプルダウンメニューから選択 | |
4 | Resource group | OpenShiftをデプロイするResource Groupを指定。keyvaultとは異なるResource Groupを指定 | |
5 | Location | VMをデプロイするリージョンを指定 |
2 Infrastructure Settings Confgure Infrastructure settings
以下のパラメータを入力します。
# | パラメータ名 | 値 | 備考 |
---|---|---|---|
1 | OCP Cluster Name Prefix | ocpcluster | |
2 | OpenShift Cluster Size | Small | Small, Medium, Large からクラスタサイズを選択 |
3 | Key Vault Resource Group Name | Keyvaultを作成したResource Groupを指定 | |
4 | Secret Name | Keyvaultに登録したSecret名を指定 |
3 OpenShift Container Platform Configure OpenShift Container Plartform
# | パラメータ名 | 値 | 備考 |
---|---|---|---|
1 | OpenShift Admin User Password | OpenShiftの管理コンソールへログインするユーザ(system:admin権限を保持)のパスワードを指定する) | |
2 | Confirm OpenShift Admin User Password | 上記のパスワードと同じものを入力 | |
3 | Red Hat Subscription Manager User Name or Activation Key | Red Hat Customer Portalへのログインに利用するユーザ名またはActivationKey | |
4 | Red Hat Subscription Manager User Password or Org ID | Red Hat Customer Portalへのログインに利用するパスワードまたはOrg ID | |
5 | Red Hat Subscription Manager Pool ID | Subscriptionに紐づけられたPoolID | |
6 | Default Router Subdomain | アプリケーションのRouterに利用するサブドメンをプルダウンから指定 |
4 Summary
内容を確認して"OK"ボタンをクリックしてデプロイを開始します。
デプロイが完了すると、Bastionノード、Masterサーバ、InfranodeサーバとNodeサーバが2台います。
おまけ
basion サーバには、OpenShiftのインストール時に利用するインベントリファイルが保存されています。内容はこんな感じです。 IPアドレスは 00.00.00.00 に書き換えています。
# Create an OSEv3 group that contains the masters and nodes groups [OSEv3:children] masters nodes master0 new_nodes # Set variables common for all OSEv3 hosts [OSEv3:vars] ansible_ssh_user=clusteradmin ansible_become=yes openshift_install_examples=true deployment_type=openshift-enterprise openshift_release=v3.6 docker_udev_workaround=True openshift_use_dnsmasq=True openshift_master_default_subdomain=00.00.00.00.nip.io openshift_override_hostname_check=true #osm_use_cockpit=false os_sdn_network_plugin_name='redhat/openshift-ovs-multitenant' console_port=443 openshift_cloudprovider_kind=azure osm_default_node_selector='type=app' openshift_disable_check=memory_availability,docker_image_availability # default selectors for router and registry services openshift_router_selector='type=infra' openshift_registry_selector='type=infra' openshift_master_cluster_hostname=masterdnszwtikzua45vga.koreacentral.cloudapp.azure.com openshift_master_cluster_public_hostname=masterdnszwtikzua45vga.koreacentral.cloudapp.azure.com openshift_master_cluster_public_vip=00.00.00.00 # Enable HTPasswdPasswordIdentityProvider openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true', 'challenge': 'true', 'kind': 'HTPasswdPasswordIdentityProvider', 'filename': '/etc/origin/master/htpasswd'}] # Setup metrics openshift_hosted_metrics_deploy=false #openshift_metrics_cassandra_storage_type=dynamic openshift_metrics_start_cluster=true openshift_metrics_hawkular_nodeselector={"type":"infra"} openshift_metrics_cassandra_nodeselector={"type":"infra"} openshift_metrics_heapster_nodeselector={"type":"infra"} openshift_hosted_metrics_public_url=https://metrics.00.00.00.00.nip.io/hawkular/metrics # Setup logging openshift_hosted_logging_deploy=false #openshift_hosted_logging_storage_kind=dynamic openshift_logging_fluentd_nodeselector={"logging":"true"} openshift_logging_es_nodeselector={"type":"infra"} openshift_logging_kibana_nodeselector={"type":"infra"} openshift_logging_curator_nodeselector={"type":"infra"} openshift_master_logging_public_url=https://kibana.00.00.00.00.nip.io # host group for masters [masters] ocpcluster-master-0 [master0] ocpcluster-master-0 # host group for nodes [nodes] ocpcluster-master-0 openshift_node_labels="{'type': 'master', 'zone': 'default'}" openshift_hostname=ocpcluster-master-0 ocpcluster-infra-0 openshift_node_labels="{'type': 'infra', 'zone': 'default'}" openshift_hostname=ocpcluster-infra-0 ocpcluster-node-0 openshift_node_labels="{'type': 'app', 'zone': 'default'}" openshift_hostname=ocpcluster-node-0 ocpcluster-node-1 openshift_node_labels="{'type': 'app', 'zone': 'default'}" openshift_hostname=ocpcluster-node-1 # host group for adding new nodes [new_nodes]