メインコンテンツまでスキップ

ストレージ

  • データの永続化に利用できるディレクトリ構造を持ったファイルシステムストレージです。SideApp, Trigger, PipelineのFunctionから書き込み/読み込みが可能です。
  • Circuit上のリソースはCanvasをデプロイするとリセットされて消えてしまいますが、ストレージはそのまま維持されます。

ライフサイクル

  • CanvasからデプロイされたリソースであるCircuitはデプロイごとにリフレッシュされます
  • StorageはStudioAppのプロジェクトレベルに存在しており、プロジェクトやそれ以下のレイヤーのコンポーネントを消さない限り永続化させることができます lifecycle

仕様

仕組みの概要

  • Kubernetesの永続ボリュームを利用しており、Amazon EBS上に保存されます。
  • 各ノード上で稼働するコンテナにストレージボリュームがマウントされます

対応ノード

  • SideApp
  • Trigger

容量

  • プロジェクト(ネームスペース)ごとに最大100GB
  • クラスターレベルで設定されているディスクスペースに容量上限の影響を受ける場合があります

ノードとストレージのマッピング

  • Storageサービスはnamespace-id, workspace-id, およびノードのidを用いて各ノードと紐付けられます
  • workspace-idやノードのidを変更すると正しくマッピングされなくなりますのでご注意ください
  • Storageに紐付けられているノードがあるWorkspaceやノードそのものを削除してしまっても、namespace-id, workspace-id, ノードのidが同じものであれば再度紐づけることが可能です。
制限事項

現在提供しているStorage機能は初期版として基本的な機能のみを有しており、制限事項があります。 今後の開発で対応をしていく予定です。

  • ほかのノードから接続して読み書きをすることはできません
  • 作成されたStorageの削除はできません
  • 使用量を確認することはできません
  • バックアップ機能は提供していません。必要な場合はAWS S3などの外部ストレージに書き出すなどの対応をお願いしています

利用方法

ストレージボリュームの追加

  • SideAppとTriggerを選択し、画面右側のメニューから''+''をクリックすることでボリュームを追加することができます。 how-to-setup

Pathの設定

  • コンテナイメージにマウントするため、任意のパスを指定することができます

サンプル

  • サンプルCanvas
    • *リンクを右クリックしてファイルをダウンロードしてください
  • このサンプルではPythonが実行できるコンテナイメージをSideAppノードで実行し、ストレージボリュームをマウントしています
  • このコンテナは以下のような構成になっており、Canvas上でStorageのパスを/tmpと指定しているため以下のようにマウントされます。
/
├── app
│   ├── data
│   ├── output
│   ├── req
│   └── src
├── tmp // Storageによって追加されたフォルダ
...
  • StorageのInjection機能を利用して以下のPythonコードを実行しています。
  • 以下のコードはStorageで設定したtmpフォルダにtest-file.jsonを作成し、jsonファイル内の数字に1を足す処理を行っています。
  • Storageのボリュームが正しく設定されていれば、デプロイするたびに1ずつ数字が増えていくことがわかります。
import os
import json

# Define the file path
json_path = '/tmp/test-file.json'

# Check if the JSON file already exists and has content
# If not, write the initial data into the JSON file
if not os.path.exists(json_path) or os.stat(json_path).st_size == 0:
with open(json_path, 'w') as outputfile:
json.dump({"data": 0}, outputfile)

# Read and print the contents of the JSON file
with open(json_path, 'r') as outputfile:
json_object = json.load(outputfile)
print(json_object)

# Increment each value in the JSON object by 1
incremented_json_object = {k: v+1 for k, v in json_object.items() if isinstance(v, int)}
- StorageのInjection機能を利用して以下のPythonコードを実行しています。
- 以下のコードはStorageで設定した``tmp``フォルダに``test-file.json``を作成し、jsonファイル内の数字に1を足す処理を行っています。
- Storageのボリュームが正しく設定されていれば、デプロイするたびに1ずつ数字が増えていくことがわかります。

```python
import os
import json

# Define the file path
json_path = '/tmp/test-file.json'

# Check if the JSON file already exists and has content
# If not, write the initial data into the JSON file
if not os.path.exists(json_path) or os.stat(json_path).st_size == 0:
with open(json_path, 'w') as outputfile:
json.dump({"data": 0}, outputfile)

# Read and print the contents of the JSON file
with open(json_path, 'r') as outputfile:
json_object = json.load(outputfile)
print(json_object)

# Increment each value in the JSON object by 1
incremented_json_object = {k: v+1 for k, v in json_object.items() if isinstance(v, int)}

# Write the modified JSON object back to the file
with open(json_path , "w") as outputfile:
json.dump(incremented_json_object, outputfile)

# Read and print the contents of the JSON file again to see the changes
with open(json_path, 'r') as outputfile:
incremented_json_object = json.load(outputfile)
print(incremented_json_object)