Filestore エージェント ボリュームを設定する

ボリューム プールを作成したり、ボリュームをプロビジョニングする前に、Private Service Connect(PSC)を使用して Virtual Private Cloud(VPC)ネットワーキングを構成し、必要な API を有効にして、適切な IAM ロールを付与する必要があります。

プロジェクトを作成して API を有効にする

  1. Google Cloud アカウントにログインします。 Google Cloudを初めて使用する場合は、 アカウントを作成して、実際のシナリオでの Google プロダクトのパフォーマンスを評価してください。新規のお客様には、ワークロードの実行、テスト、デプロイができる無料クレジット $300 分を差し上げます。
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.

  4. Verify that billing is enabled for your Google Cloud project.

  5. Enable the Filestore APIs.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the APIs

  6. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  7. If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.

  8. Verify that billing is enabled for your Google Cloud project.

  9. Enable the Filestore APIs.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the APIs

必要なロール

Filestore エージェント ボリュームの設定に必要な権限を取得するには、プロジェクトに対する次の IAM ロールを付与するよう管理者に依頼してください。

  • サービス接続ポリシーと VPC ネットワーキングを構成する: Compute ネットワーク管理者 roles/compute.networkAdmin
  • Filestore インスタンスと関連リソース(ボリューム プールやエージェント ボリュームなど)を表示して管理する: Cloud Filestore 編集者 roles/file.editor

ロールの付与については、プロジェクト、フォルダ、組織へのアクセス権の管理をご覧ください。

必要な権限は、カスタムロールや他の事前定義ロールから取得することもできます。

サービス エージェントを初期化する

プロジェクトに Filestore インスタンスを作成していない場合は、次のコマンドを実行して Filestore サービス エージェントを初期化します。

gcloud beta services identity create \
    --service=file.googleapis.com \
    --project=PROJECT_ID

PROJECT_ID は、 Google Cloudプロジェクトの ID に置き換えます。

サービス エージェントに権限を付与する

Filestore エージェント ボリュームを設定するには、Filestore サービス エージェントに Cloud Filestore 編集者(roles/file.editor)ロールを付与します。

gcloud projects add-iam-policy-binding PROJECT_ID \
    --member="serviceAccount:service-PROJECT_NUMBER@cloud-filer.iam.iam.gserviceaccount.com" \
    --role="roles/file.editor"

次のように置き換えます。

  • PROJECT_ID: 実際の Google Cloud プロジェクト ID。
  • PROJECT_NUMBER:Google Cloud プロジェクトのプロジェクト番号。

Private Service Connect ネットワーキングを構成する

Filestore エージェント ボリュームは、Private Service Connect を使用して、マネージド ストレージ インフラストラクチャを VPC ネットワークに直接接続します。Private Service Connect は、パブリック IP アドレスや VPC ネットワーク ピアリング構成を必要とせずに、プライベートで高帯域幅、低レイテンシの通信を保証します。

サービス接続ポリシーを作成するには、次のコマンドを実行します。

gcloud network-connectivity service-connection-policies create POLICY_NAME \
    --project=PROJECT_ID \
    --region=REGION \
    --network=projects/PROJECT_ID/global/networks/VPC_NETWORK \
    --subnets=SUBNET_NAME \
    --service-class=google-cloud-filestore

次のように置き換えます。

  • POLICY_NAME: サービス接続ポリシーの名前(例: filestore-agent-psc-policy)。
  • PROJECT_ID: 実際の Google Cloud プロジェクト ID。
  • REGION: ボリューム プールとワークロードが配置されるリージョン(us-central1 など)。
  • VPC_NETWORK: 既存の VPC ネットワークの名前。
  • SUBNET_NAME: Private Service Connect エンドポイントの IP アドレスを割り当てる指定されたリージョンの通常の VPC サブネットの名前。たとえば、--purpose フラグが PRIVATE に設定されたデフォルトのサブネットなどです。

ボリューム プールと StorageClass を作成する

ボリューム プールは、エージェント ボリュームに共有ストレージ容量と IOPS を提供します。GKE のボリューム プールからボリュームを動的にプロビジョニングするには、ボリューム プールを作成してから、それを参照する Kubernetes StorageClass を定義します。

ボリューム プールを作成する

サンプル ボリューム プールを作成するには、volumePools.create エンドポイントに HTTP POST リクエストを送信します。

curl -X POST \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    -H "Content-Type: application/json; charset=utf-8" \
    -d '{
      "description": "Sample volume pool for agent volumes",
      "network": "projects/PROJECT_ID/global/networks/VPC_NETWORK",
      "defaultVolumeQuotaMib": 2048,
    }' \
    "https://file.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/volumePools?volumePoolId=VOLUME_POOL_ID"

次のように置き換えます。

  • PROJECT_ID: 実際の Google Cloud プロジェクト ID。
  • VPC_NETWORK: PSC 対応 VPC ネットワークの名前。
  • LOCATION: ボリューム プールがデプロイされているリージョン(us-central1 など)。
  • VOLUME_POOL_ID: ボリューム プールの識別子(my-volume-pool など)。

詳細については、ボリューム プールの作成と管理をご覧ください。

StorageClass を作成する

ボリューム プールを参照する volume-pool-sc.yaml という名前の StorageClass マニフェストを作成します。

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: volume-pool-sc
provisioner: filestore.csi.storage.gke.io
volumeBindingMode: Immediate
reclaimPolicy: Delete
allowVolumeExpansion: true
parameters:
  volume-pool: "projects/<var>PROJECT_ID</var>/locations/<var>LOCATION</var>/volumePools/<var>VOLUME_POOL_ID</var>"

次のように置き換えます。

  • PROJECT_ID: 実際の Google Cloud プロジェクト ID。
  • LOCATION: ボリューム プールがデプロイされているリージョン。
  • VOLUME_POOL_ID: ボリューム プールの識別子。

Filestore CSI ドライバがインストールされている既存の GKE クラスタがある場合は、StorageClass を適用します。

kubectl apply -f volume-pool-sc.yaml

それ以外の場合は、Filestore エージェント ボリューム用に GKE 環境を設定するでクラスタを設定した後に、このマニフェストを適用します。

次のステップ