0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Runtime FabricでPersistenceオブジェクトストア

Last updated at Posted at 2022-01-20

#Runtime FabricでPersistenceオブジェクトストアを利用する方法

Anypoint PlatformのCloudHub導入では、Object StoreでPersistenceオプションを利用することが出来ます。

↓のPersistentに✔です。

Object Store Configuration
image.png

古いバージョンのRuntime Fabric(オンプレミス導入)では、Object Store機能自体を利用することは出来てもメモリー上のデータ保持となっており、アプリケーションのリスタートによりデータが失われていましたが、下記のRuntime Fabric 1.9.1のリリースノートにある通り、Persistence機能が追加されています。
これは、Runtime Fabric on VM / BareMetalでも、Runtime Fabric on Self-Managed k8sのどちらでも利用可能となっています。

Runtime Fabric 1.9.1 リリースノート
image.png

CloudHub含め、Anypoint Platformで利用可能なObject Storeについては、こちらの記事を参照ください。

##Persistence Gatewayの構成
Runtime Fabricで、Persistence Object Storeを利用するためには、Persistence GatewayというPodを構成する必要があり、また、データを保持しておく入れ物であるPostgreSQL(バージョン指定あり)を別途用意する必要がありますのでご注意ください。

具体的な手順はこちらに紹介されていますが、下記、簡単に説明します。

  1. Runtime FabricでSecretを作成する
    RTF on VM / BareMetalの場合は、Controllerノードからkubectlコマンドを実行していきます。
    kubectl create secret generic <Secret名> -n rtf --from-literal=persistence-gateway-creds='postgresql://<DBユーザー名>:<DBパスワード>@<DBホスト>:<DBポート>/<DB名>'
    DBのパスワードには、@や#等が混ざらないようにしてください。
    尚、エントリを削除する場合は、
    kubectl delete secret generic <Secret名> -n rtfです。

  2. Pod構成用yamlファイルを作成する(テンプレートは、こちらにあります。)

rtf.mulesoft.com/v1
kind: PersistenceGateway
metadata:
  name: default
  namespace: rtf
spec:
  objectStore:
    backendDriver: postgresql
    maxBackendConnectionPool: 20
    replicas: 2
    secretRef:
      name: <Secret名>
    resources:
      limits:
        cpu: 250m
        memory: 250Mi
      requests:
        cpu: 200m
        memory: 75Mi```

1. Persistence Gateway作成
次のコマンドで構成していきます。
```sudo kubectl create -f <Pod構成用yamlファイル名>```
尚、誤った設定などで実行してしまった場合は、createの部分をdeleteに置き換えて削除します。

1. 稼働の確認
次のコマンドを実行することで、RTF関連Podの一覧が得られます。
```sudo kubectl get pods -n rtf```
この中で、"persistence-gateway-xxxxxxxxxx-xxxxx"といったエントリがありますので、このIDを保存します。
そして、このIDを利用して、バックエンドのPostgreSQLデータベースへの接続に成功していることを確認します。
```kubectl logs -f persistence-gateway-xxxxxxxxxx-xxxxx -nrtf```

1. アプリケーションのデプロイ時に、Persistence Object Storeオプションに✔を入れて有効にします。

| RTFアプリケーションデプロイ |
|:-:|
|  ![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/615564/f916ac62-729a-f7af-9ac9-4109b855338e.png) |
0
0
1

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?