IBM Cloud pak for Watson AIOps. 4.1.0をデプロイする

下記のドキュメントを参考にIBM Cloud Pak for Watson AIOpsの構築を行う。
現在の最新バージョンは4.1.0
3.7.xのインストールはこちらを参照。

https://qiita.com/kurosaway/items/e3dc2c73e76f0b5e3fcd


前回の3.7のデプロイ記事と大まかな流れは変わらないです。
しかしながらyamlファイルの指定バージョンを4.1に変える所以外にも変更がすこしあるので注意してください。

なお、前回のデプロイ記事同様、検証環境をデプロイすることを前提とした記事なのであしからず。

↓　参考とするドキュメント　↓

https://www.ibm.com/docs/en/cloud-paks/cloud-pak-watson-aiops/4.1.0?topic=aiops-starter-installation


# 前提条件(前回と同じままなので要編集)

- Watson AIOpsをインストールするOpenshift Container Platformがインストールできている

- 最低限Worker合計でリソースの余裕がある

    - vCPU:56
    - Memory:140GB
    - CoreoOS root disk 360GB

- Worker個々で以下のリソースがある(最低3worker必要)
    - vCPU:8
    - memory:12GB
    - Local disk Storage 120

- その他スループットなど細かいrequirementは下記を参照

https://www.ibm.com/docs/en/cloud-paks/cloud-pak-watson-aiops/3.7.2?topic=requirements-hardware

# インストール作業
## namespace 作成
    oc create namespace cp4waiops

## Operator Group作成
    cat << EOF | oc apply -f -
    apiVersion: operators.coreos.com/v1
    kind: OperatorGroup
    metadata:
      name: cp4waiops-operator-group
      namespace: cp4waiops
    spec:
      targetNamespaces:
        - cp4waiops
    EOF

## pullsecretを作成

コンテナイメージを引っ張ってくるためのパスワードとしてENTITLEMENT_KEYが必要。
$YOUR_ENTITLEMENT_KEYは
https://myibm.ibm.com/products-services/containerlibrary
より取得してください。

    oc create secret docker-registry ibm-entitlement-key \
        --docker-username=cp\
        --docker-password=$YOUR_ENTITLEMENT_KEY \
        --docker-server=cp.icr.io \
        --namespace=cp4waiops




## AI Managerの外向け通信を許可
    if [ $(oc get ingresscontroller default -n openshift-ingress-operator -o jsonpath='{.status.endpointPublishingStrategy.type}') = "HostNetwork" ]; then oc patch namespace default --type=json -p '[{"op":"add","path":"/metadata/labels","value":{"network.openshift.io/policy-group":"ingress"}}]'; fi


## カタログソース作成
    cat << EOF | oc apply -f -
    apiVersion: operators.coreos.com/v1alpha1
    kind: CatalogSource
    metadata:
      name: ibm-operator-catalog
      namespace: openshift-marketplace
    spec:
      displayName: ibm-operator-catalog
      publisher: IBM Content
      sourceType: grpc
      image: icr.io/cpopen/ibm-operator-catalog:latest
      updateStrategy:
        registryPoll:
          interval: 45m
    EOF


## 前提条件のチェック
ツールでインストールの前提条件が満たされているか確認を行う
チェック内容はOCPのバージョン、CPU、メモリなどのリソース状況やStorage classが所望のものができているかなどをチェックしてくれる。

https://github.com/IBM/cp4waiops-samples/tree/main/prereq-checker/4.1

    git clone https://github.com/IBM/cp4waiops-samples
    cd cp4waiops-samples/prereq-checker/4.1
    oc project cp4waiops
    ./prereq.sh

### 出力結果(長いので注意)

    [root@itz-664002upfl-0kba 4.1]# ./prereq.sh
    Using project "cp4waiops" on server "https://api.ocp-664002upfl-gwy5.cloud.techzone.ibm.com:6443".
    
    Starting IBM Cloud Pak for Watson AIOps AI Manager prerequisite checker v4.1... 
    
    
    [INFO] =================================Openshift Container Platform Version Check=================================
    [INFO] Checking OCP Version. Compatible Versions of OCP are v4.10.46+ and v4.12.x 
    [INFO] OCP version 4.12.22 is compaitble
    [INFO] =================================Openshift Container Platform Version Check=================================
    
    [INFO] =================================Entitlement Pull Secret=================================
    [INFO] Checking whether the Entitlement secret or Global pull secret is configured correctly.
    [INFO] Checking if the job 'cp4waiops-entitlement-key-test-job' already exists.
    [INFO] The job with name 'cp4waiops-entitlement-key-test-job' was not found, so moving ahead and creating it.
    [INFO] Creating the job 'cp4waiops-entitlement-key-test-job' 
    job.batch/cp4waiops-entitlement-key-test-job created
    [INFO] Verifying if the job 'cp4waiops-entitlement-key-test-job' completed successfully..
    [INFO] SUCCESS! Entitlement secret is configured correctly.
    job.batch "cp4waiops-entitlement-key-test-job" deleted
    [INFO] =================================Entitlement Pull Secret=================================
    
    [INFO] =================================Storage Provider=================================
    [INFO] Checking storage providers
    [INFO] No IBM Storage Fusion Found... Skipping configuration check.
    
    [INFO] No Portworx StorageClusters found with "Running" or "Online" status. Skipping configuration check for Portworx.
    [INFO] Openshift Data Foundation found.
    [INFO] No IBM Cloud Storage found... Skipping configuration check for IBM Cloud Storage Check.
    
    Checking Openshift Data Foundation Configuration...
    Verifying if Red Hat Openshift Data Foundation pods are in "Running" or "Completed" status
    [INFO] Pods in openshift-storage project are "Running" or "Completed"
    [INFO] ocs-storagecluster-ceph-rbd exists.
    [INFO] ocs-storagecluster-cephfs exists.
    [INFO] No warnings or failures found when checking for Storage Providers.
    [INFO] =================================Storage Provider=================================
    
    [INFO] =================================Network Policy=================================
    [INFO] Checking Network Policy configuration
    [INFO] Namespace default has expected metadata label. Network policy configured correctly.
    [INFO] =================================Network Policy=================================
    
    [INFO] =================================Small or Large Profile Install Resources=================================
    [INFO] Checking for cluster resources
    
    [INFO] ==================================Resource Summary=====================================================
    [INFO]                                       Nodes   |      vCPU      |     Memory(GB)
    [INFO] Small profile(available/required)  [  5 / 3 ]   [  185 / 56 ]       [  708 / 140 ]
    [INFO] Large profile(available/required)  [  5 / 10 ]   [  185 / 156 ]       [  708 / 360 ]
    [INFO] ==================================Resource Summary=====================================================
    [INFO] Cluster currently has resources available to create a small profile of Cloud Pak for Watson AIOps AI Manager
    
    [INFO] =================================Small or Large Profile Install Resources=================================
    
    
    [INFO] =================================Prerequisite Checker Tool Summary=================================
          [  PASS  ] Openshift Container Platform Version Check 
          [  PASS  ] Entitlement Pull Secret
          [  PASS  ] Storage Provider
          [  PASS  ] Network Policy
          [  PASS  ] Small or Large Profile Install Resources
    [INFO] =================================Prerequisite Checker Tool Summary=================================



## AI Ops Operatorのインストールを行う
    
    
    cat << EOF | oc apply -f -
    apiVersion: operators.coreos.com/v1alpha1
    kind: Subscription
    metadata:
      name: ibm-aiops-orchestrator
      namespace: cp4waiops
    spec:
      channel: v4.1
      installPlanApproval: Automatic
      name: ibm-aiops-orchestrator
      source: ibm-operator-catalog
      sourceNamespace: openshift-marketplace
    EOF


### Operatorのインストール確認
下記コマンドでOperatorのインストールが上手くいっているかどうかが分かる.大体数分でインストールは終了します

    oc get csv -n cp4waiops | egrep "ibm-aiops-orchestrator|ibm-automation|ibm-common-service"


### 出力例
ドキュメントに記載があるのですが、この段階ではIBM Elasticのインストールがfailします。ですが、気にせずAI Managerのインストールに進んでください。AI ManagerをインストールするとIBM ElasticのインストールもSucceededになります。

    [root@itz-664002upfl-0kba ~]# oc get csv -n cp4waiops | egrep "ibm-aiops-orchestrator|ibm-automation|ibm-common-service"
    
    ibm-aiops-orchestrator.v4.1.0         IBM Cloud Pak for Watson AIOps AI Manager          4.1.0                                        Succeeded
    ibm-automation-elastic.v1.3.13        IBM Elastic                                        1.3.13    ibm-automation-elastic.v1.3.12     Succeeded
    ibm-automation-flink.v1.3.13          IBM Automation Foundation Flink                    1.3.13    ibm-automation-flink.v1.3.12       Succeeded
    ibm-common-service-operator.v3.23.4   IBM Cloud Pak foundational services                3.23.4                                       Succeeded

## AI Managerをインストールする
変数である'storage_class_name'と
'large_block_storage_class_name'
は下記ドキュメントの'Table 2. Supported storage providers'
を参照。Storage providerにより値が変わります.


https://www.ibm.com/docs/en/cloud-paks/cloud-pak-watson-aiops/4.1.0?topic=planning-storage-requirements


    cat << EOF | oc apply -f -
    apiVersion: orchestrator.aiops.ibm.com/v1alpha1
    kind: Installation
    metadata:
      name: ibm-cp-watson-aiops
      namespace: cp4waiops
    spec:
      imagePullSecret: ibm-entitlement-key
      license:
        accept: true
      pakModules:
      - name: aiopsFoundation
        enabled: true
      - name: applicationManager
        enabled: true
      - name: aiManager
        enabled: true
      - name: connection
        enabled: false
      size: small
      storageClass: <storage_class_name>
      storageClassLargeBlock: <large_block_storage_class_name>
      topologyModel: application
    EOF


私の環境ではODFを使っており、下記のように書き換えを行いました。
ODFの場合

    storage_class_name =　ocs-storagecluster-cephfs
	
    large_block_storage_class_name = ocs-storagecluster-ceph-rbd

なので、下記のように書き換えます。
    
    cat << EOF | oc apply -f -
    apiVersion: orchestrator.aiops.ibm.com/v1alpha1
    kind: Installation
    metadata:
      name: ibm-cp-watson-aiops
      namespace: cp4waiops
    spec:
      imagePullSecret: ibm-entitlement-key
      license:
        accept: true
      pakModules:
      - name: aiopsFoundation
        enabled: true
      - name: applicationManager
        enabled: true
      - name: aiManager
        enabled: true
      - name: connection
        enabled: false
      size: small
      storageClass: ocs-storagecluster-cephfs
      storageClassLargeBlock: ocs-storagecluster-ceph-rbd
      topologyModel: application
    EOF


インストールには60-90分かかるらしいのでしばらく待ちます。


### AI Manager のインストール確認
しばらく寝かせておいたあとにインストールの確認コマンドを打ちます

    oc get installations.orchestrator.aiops.ibm.com -n cp4waiops

### 出力結果
    [root@itz-664002upfl-0kba ~]# oc get installations.orchestrator.aiops.ibm.com -n cp4waiops
    NAME                  PHASE     LICENSE    STORAGECLASS                STORAGECLASSLARGEBLOCK        AGE
    ibm-cp-watson-aiops   Running   Accepted   ocs-storagecluster-cephfs   ocs-storagecluster-ceph-rbd   31h


## URL取得
ログインURLを取得します

    oc get route -n cp4waiops cpd -o jsonpath='{.spec.host}'

### 出力結果

     [root@itz-664002upfl-0kba ~]# oc get route -n cp4waiops cpd -o jsonpath='{.spec.host}'
    youraiopsurlist.com

## パスワード取得
adminパスワードを取得します

    oc -n ibm-common-services get secret platform-auth-idp-credentials -o jsonpath='{.data.admin_password}' | base64 -d

#### 出力結果

    [root@kurosaway ~]# oc -n ibm-common-services get secret platform-auth-idp-credentials -o jsonpath='{.data.admin_password}' | base64 -d
    yourpasswordishogehoge

## ログインする

URLにWebブラウザでアクセス後、
admin/yourpasswordでログイン

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/293016/99540eb3-4ce9-4453-68cc-02cc49c99296.png)

お疲れ様でした。