Managed Resources
デフォルトでは、サンプルアプリケーションのCartsコンポーネントは、EKSクラスタ内でポッドとして実行されているcarts-dynamodbという名前のDynamoDB localインスタンスを使用しています。このラボのセクションでは、Crossplaneマネージドリソースを使用してアプリケーション用のAmazon DynamoDBクラウ ドベースのテーブルをプロビジョニングし、Cartsデプロイメントを設定して、ローカルコピーの代わりに新しくプロビジョニングされたDynamoDBテーブルを使用するようにします。

Crossplaneマネージドリソースマニフェストを使用してDynamoDBテーブルを作成する方法を見てみましょう:
apiVersion: dynamodb.aws.upbound.io/v1beta1
kind: Table
metadata:
name: "${EKS_CLUSTER_NAME}-carts-crossplane"
labels:
testing.upbound.io/example-name: dynamodb
annotations:
crossplane.io/external-name: "${EKS_CLUSTER_NAME}-carts-crossplane"
spec:
forProvider:
attribute:
- name: id
type: S
- name: customerId
type: S
hashKey: id
billingMode: PAY_PER_REQUEST
globalSecondaryIndex:
- hashKey: customerId
name: idx_global_customerId
projectionType: ALL
region: ""
tags:
namespace: carts
providerConfigRef:
name: aws-provider-config
Upboundの AWS DynamoDB プロバイダーを使用
DynamoDB テーブルリソースを作成
クラスタ接頭辞付きの名前と外部名アノテーションを持つKubernetesオブジェクトを指定
idとcustomerIdを文字列(S)タイプの属性として定義
idをプライマリパーティションキーとして設定
オンデマンド価格モデルを指定
customerIdにグローバルセカンダリインデックスを作成し、すべての属性をプロジェクション
認証のためのAWSプロバイダー設定を参照
では、dynamodb.aws.upbound.ioリソースを使用してDynamoDBテーブルの設定を作成しましょう。
table.dynamodb.aws.upbound.io/eks-workshop-carts-crossplane created
AWSマネージ ドサービスのプロビジョニングには時間がかかります。DynamoDBの場合、最大2分かかることがあります。Crossplaneは、Kubernetesカスタムリソースのstatusフィールドに調整の状態を報告します。
NAME READY SYNCED EXTERNAL-NAME AGE
eks-workshop-carts-crossplane True True eks-workshop-carts-crossplane 6s
この設定を適用すると、CrossplaneはAWSにDynamoDBテーブルを作成し、アプリケーションで使用できるようになります。次のセクションでは、アプリケーションを更 新して、この新しく作成されたテーブルを使用するようにします。