> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-trino-dialect.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# BYOC GCP プライベートネットワーク設定

> GCP 上の BYOC で VPC Peering または Private Service Connect を設定する

export const Image = ({img, alt, size = "lg", background}) => {
  const normalizedSize = ["sm", "md", "lg"].includes(size) ? size : "lg";
  const backgroundColor = background === "white" ? "white" : background === "black" ? "rgb(31 31 28)" : undefined;
  return <div className={`ch-image-${normalizedSize}`}>
      <Frame>
        <img src={img} alt={alt} style={{
    backgroundColor
  }} />
      </Frame>
    </div>;
};

GCP 上の ClickHouse BYOC は、VPC Peering と PSC (Private Service Connect) という 2 つのプライベート接続オプションをサポートしています。

<div id="common-prerequisites">
  ## 前提条件
</div>

VPC ピアリング と PSC の両方に共通して必要な手順です。

<div id="step-enable-private-load-balancer-for-clickhouse-byoc">
  ### ClickHouse BYOC のプライベートロードバランサーを有効にする
</div>

ClickHouse Cloud console で、BYOC インフラストラクチャの **プライベートロードバランサー** を有効にします。

<Image img="https://mintcdn.com/private-7c7dfe99-trino-dialect/wrAOYL3DquclMwbQ/images/cloud/reference/byoc-private-load-balancer.webp?fit=max&auto=format&n=wrAOYL3DquclMwbQ&q=85&s=c2d79269321210679ad00c0afe098632" size="md" alt="BYOC プライベートロードバランサーを有効にする" border width="2438" height="1724" data-path="images/cloud/reference/byoc-private-load-balancer.webp" />

<div id="gcp-vpc-peering">
  ## VPC ピアリングを設定する
</div>

事前に [GCP VPC ピアリング 機能](https://docs.cloud.google.com/vpc/docs/vpc-peering)を確認し、VPC ピアリングの制限事項 (たとえば、ピアリングされた VPC ネットワーク間ではサブネットの IP 範囲を重複させることはできません) に注意してください。ClickHouse BYOC では、ピアリング経由で ClickHouseサービス へのネットワーク接続を可能にするために、プライベートロードバランサーを使用します。

ClickHouse BYOC の VPC ピアリングを作成または削除するには、次の手順に従ってください。

<Note>
  この手順例はシンプルなシナリオを対象としています。オンプレミス接続とのピアリングなど、より高度なシナリオでは調整が必要になる場合があります。
</Note>

<Steps>
  <Step title="ピアリング接続を作成する" id="step-1-create-a-peering-connection">
    この例では、BYOC VPC ネットワークと、既存の別の VPC ネットワークの間でピアリングを設定します。

    1. ClickHouse BYOC Google Cloud Project の "VPC Network" に移動します。
    2. "VPC network peering" を選択します。
    3. "Create connection" をクリックします。
    4. 要件に応じて必要なフィールドを入力します。以下は、同じ GCP project 内でピアリングを作成する場合のスクリーンショットです。

    <Image img="https://mintcdn.com/private-7c7dfe99-trino-dialect/wrAOYL3DquclMwbQ/images/cloud/reference/byoc-vpcpeering-gcp-1.webp?fit=max&auto=format&n=wrAOYL3DquclMwbQ&q=85&s=155bdd685e897ec94710136a0a854a25" size="md" alt="BYOC ピアリング接続の作成" border width="1552" height="1740" data-path="images/cloud/reference/byoc-vpcpeering-gcp-1.webp" />

    GCP VPC ピアリングを機能させるには、2 つのネットワーク間に 2 つの接続が必要です (つまり、BYOC ネットワークから既存の VPC ネットワークへの接続と、既存の VPC ネットワークから BYOC ネットワークへの接続) 。そのため、同様に逆方向でもう 1 つ接続を作成する必要があります。以下は、2 つ目のピアリング接続を作成する際のスクリーンショットです。

    <Image img="https://mintcdn.com/private-7c7dfe99-trino-dialect/wrAOYL3DquclMwbQ/images/cloud/reference/byoc-vpcpeering-gcp-2.webp?fit=max&auto=format&n=wrAOYL3DquclMwbQ&q=85&s=b05cc2c734703c8478000f6af4886913" size="md" alt="BYOC ピアリング接続の承認" border width="1560" height="1744" data-path="images/cloud/reference/byoc-vpcpeering-gcp-2.webp" />

    両方の接続を作成すると、Google Cloud Console の Web ページを更新したあと、2 つの接続のステータスは "Active" になるはずです。

    <Image img="https://mintcdn.com/private-7c7dfe99-trino-dialect/wrAOYL3DquclMwbQ/images/cloud/reference/byoc-vpcpeering-gcp-3.webp?fit=max&auto=format&n=wrAOYL3DquclMwbQ&q=85&s=592aa5fa952cc7c4a3cf90cce941a33b" size="lg" alt="BYOC ピアリング接続の承認" border width="3134" height="640" data-path="images/cloud/reference/byoc-vpcpeering-gcp-3.webp" />

    これで、ClickHouseサービス はピアリングされた VPC からアクセスできるようになります。
  </Step>

  <Step title="ピアリング接続経由で ClickHouseサービス にアクセスする" id="step-2-access-ch-service-via-peering">
    ClickHouse にプライベートにアクセスするため、ユーザーのピアリング済み VPC から安全に接続できるよう、プライベートロードバランサーとエンドポイントがプロビジョニングされます。プライベート エンドポイントは、公開エンドポイントの形式に `-private` 接尾辞を付けたものです。例:

    * **公開エンドポイント**: `h5ju65kv87.mhp0y4dmph.us-east1.gcp.clickhouse-byoc.com`
    * **プライベート エンドポイント**: `h5ju65kv87-private.mhp0y4dmph.us-east1.gcp.clickhouse-byoc.com`
  </Step>
</Steps>

<div id="setup-psc">
  ## PSC (Private Service Connect) を設定する
</div>

GCP PSC (Private Service Connect) を使用すると、VPC ピアリングやインターネットゲートウェイを介さずに、ClickHouse BYOC サービスへ安全なプライベート接続を確立できます。すべてのトラフィックは GCP ネットワーク内で処理されるため、パブリックインターネットを経由することはありません。

<Steps>
  <Step title="ClickHouse console でプライベートリンクを有効にする" id="step-1-enable-private-link">
    <Note>
      前提条件として、**プライベート ロード バランサー**が有効になっていることを確認してください。
    </Note>

    <Image img="https://mintcdn.com/private-7c7dfe99-trino-dialect/wrAOYL3DquclMwbQ/images/cloud/reference/byoc-privatelink.webp?fit=max&auto=format&n=wrAOYL3DquclMwbQ&q=85&s=0cce402678608f2f392274290212c7cb" size="md" alt="BYOC PrivateLink を有効にする" width="2800" height="1848" data-path="images/cloud/reference/byoc-privatelink.webp" />
  </Step>

  <Step title={<>エンドポイントの<code>Service name</code>を取得する</>} id="step-2-obtain-endpoint-service-name">
    1. ClickHouse Cloud console で、PSC 経由で接続するサービスの Settings ページに移動します。
    2. 「Set up private endpoint」をクリックします。
    3. 開いたフライアウトで、`Service name` と `DNS name` の値をコピーします。これらは次の手順で使用します。 (プライベートリンクを有効にしてから値が生成されるまで、しばらく時間がかかる場合があります。)
           <Image img="https://mintcdn.com/private-7c7dfe99-trino-dialect/1eeX3TpI5_hf7pMs/images/cloud/security/gcp-privatelink-pe-create.webp?fit=max&auto=format&n=1eeX3TpI5_hf7pMs&q=85&s=69067518eadb371baff190537f63e430" size="md" alt="プライベート エンドポイント" border width="1368" height="719" data-path="images/cloud/security/gcp-privatelink-pe-create.webp" />
  </Step>

  <Step title="ネットワーク内にエンドポイントを作成する" id="step-3-create-endpoint">
    1. **自身の GCP console** (クライアントアプリケーションが存在する GCP アカウント) を開き、Network Services → Private Service Connect → Connected Endpoints に移動します。

    2. 「Connect Endpoint」ボタンをクリックして、Private Service Connect の作成ダイアログを開きます。
           <Image img="https://mintcdn.com/private-7c7dfe99-trino-dialect/1eeX3TpI5_hf7pMs/images/cloud/security/gcp-psc-open.webp?fit=max&auto=format&n=1eeX3TpI5_hf7pMs&q=85&s=f4ae28bfa6d8ab4b217e56a28361370c" size="md" alt="Google Cloud console で Private Service Connect を開く" border width="1892" height="737" data-path="images/cloud/security/gcp-psc-open.webp" />

    3. 次のフィールドを入力します。
       * **Target**: `Published service` を選択します
       * **Target service**: 前の手順で取得した `Service name` を使用します
       * **Endpoint name**: 有効なエンドポイント名を入力します
       * **Network/Subnetwork**: 接続に使用するネットワークを選択します。これはクライアントアプリケーションが接続元として使用するネットワークです
       * **IP address**: エンドポイント用の新しい IP アドレスを選択または作成します。この IP アドレスは手順[エンドポイントのプライベート DNS 名を設定する](#step-5-set-private-dns-name-for-endpoint)で使用します
       * (任意) **Enable global access**: 任意のリージョンからエンドポイントにアクセスできるようにする場合は有効にします
           <Image img="https://mintcdn.com/private-7c7dfe99-trino-dialect/1eeX3TpI5_hf7pMs/images/cloud/security/gcp-psc-enable-global-access.webp?fit=max&auto=format&n=1eeX3TpI5_hf7pMs&q=85&s=a1f4b9a87ea78645d2a66285e2e49bac" size="md" alt="Private Service Connect のグローバルアクセスを有効にする" border width="545" height="660" data-path="images/cloud/security/gcp-psc-enable-global-access.webp" />
       * 「ADD ENDPOINT」ボタンをクリックしてエンドポイントを作成します。

    4. 接続が承認されると、Status カラムが Pending から Accepted に変わります。

    5. エンドポイントを作成したら、`PSC Connection ID` の値をコピーします。これは次の手順で使用します。
           <Image img="https://mintcdn.com/private-7c7dfe99-trino-dialect/1eeX3TpI5_hf7pMs/images/cloud/security/gcp-psc-copy-connection-id.webp?fit=max&auto=format&n=1eeX3TpI5_hf7pMs&q=85&s=bb533eebfa2d6123aeb5898cd0cd1413" size="md" alt="PSC Connection ID をコピーする" border width="1441" height="116" data-path="images/cloud/security/gcp-psc-copy-connection-id.webp" />
  </Step>

  <Step title={<>ClickHouse service allow list に<code>Endpoint ID</code>を追加する</>} id="step-4-add-endpoint-id-to-services-allow-list">
    1. ClickHouse Cloud console で、PSC 経由で接続するサービスの Settings ページに移動します。
    2. 「Set up private endpoint」をクリックします。
    3. 開いたフライアウトで、前の手順で取得した `PSC Connection ID` を、任意の説明とともに `Endpoint ID` フィールドに入力します。
    4. 「Create endpoint」をクリックします。

    <Note>
      既存の PSC 接続からのアクセスを許可する場合は、既存のエンドポイント用ドロップダウンメニューを使用します。
      ドロップダウンには、同じインフラストラクチャ内のサービスへの既存の PSC 接続が表示されます。
    </Note>

    <Image img="https://mintcdn.com/private-7c7dfe99-trino-dialect/1eeX3TpI5_hf7pMs/images/cloud/security/gcp-privatelink-pe-filters.webp?fit=max&auto=format&n=1eeX3TpI5_hf7pMs&q=85&s=441e6d16123cd4ced5761fd300281d22" size="md" alt="プライベート エンドポイントのフィルター" border width="1367" height="768" data-path="images/cloud/security/gcp-privatelink-pe-filters.webp" />
  </Step>

  <Step title="エンドポイントのプライベート DNS 名を設定する" id="step-5-set-private-dns-name-for-endpoint">
    <Note>
      DNS の設定方法は複数あります。用途に応じて DNS を設定してください。
    </Note>

    「DNS name」のすべてのサブドメイン (ワイルドカード) を GCP PSC エンドポイントの IP アドレスに向ける必要があります。これにより、VPC/Network 内のサービスやコンポーネントで適切に名前解決できるようになります。
  </Step>

  <Step title="PSC を使用してインスタンスにアクセスする" id="step-6-connect-via-psc">
    1. ClickHouse Cloud console で、サービスの Settings ページに移動します。
    2. 「Set up private endpoint」をクリックします。
    3. 開いたフライアウトで、`DNS name` をコピーします。
           <Image img="https://mintcdn.com/private-7c7dfe99-trino-dialect/1eeX3TpI5_hf7pMs/images/cloud/security/gcp-privatelink-pe-dns.webp?fit=max&auto=format&n=1eeX3TpI5_hf7pMs&q=85&s=0a877dd5746f9149c394c16d9de89916" size="md" alt="プライベート エンドポイントの DNS 名" border width="1367" height="768" data-path="images/cloud/security/gcp-privatelink-pe-dns.webp" />
           <Note>
             PSC 経由での ClickHouse サービスへのアクセスは、BYOC インフラストラクチャ内で ClickHouse が管理するサービスレベルの **Istio Authorization Policy** によって制御されます。
           </Note>
  </Step>
</Steps>
