注意
この機能は、次の配置では使用できません。
M0クラスターFlex クラスター
Atlas Kubernetes Operator は、次のプラットフォーム上の専有クラスターのプライベートエンドポイントの管理をサポートしています。
AWS は AWS PrivateLink 機能を使用しています。
Azure は Azure Private Link 機能を使用しています。
Google Cloud Platform で Private Service Connect 機能を使用。
開始する前に、「プライベートエンドポイントの管理 」を参照してください。
手順
クライアントがプライベートエンドポイントを使用して Atlas 専用クラスターに接続できるようにするには、次の手順に従います。
spec.privateEndpointsパラメータを指定します。
Specify the spec.privateEndpoints parameter for the AtlasProject Custom Resource. In the spec.privateEndpoints.provider field, specify AWS. Replace the placeholder {aws-region} with the AWS region information for your private endpoints and run the following command:
cat <<EOF | kubectl apply -f - apiVersion: atlas.mongodb.com/v1 kind: AtlasProject metadata: name: my-project spec: name: Test Atlas Operator Project privateEndpoints: - provider: "AWS" region: "{aws-region}" EOF
Atlas は選択したリージョンにVPCリソースを作成します。 これが完了するまでに数分かかる場合があります。
プライベートエンドポイントのサービス名を見つけます。
次のコマンドを実行します:
kubectl get atlasproject my-project -o yaml AtlasProjectカスタム リソース の stringフィールド内の各プライベートエンドポイントのサービス名の に注目してください。status.privateEndpoints.serviceName
Amazon Web Services CLIを使用して、各プライベートエンドポイントを設定します。
To create your application VPC interface endpoint:
次のコマンドをコピーします。
aws ec2 create-vpc-endpoint --vpc-id {your-application-vpc-id} --region {aws-region} --service-name {service-name-string} --vpc-endpoint-type Interface --subnet-ids {your-application-subnet-ids} 次のプレースホルダーをAmazon Web Services VPCの詳細に置き換えます。
your-application-vpc-idピア AWS VPCを識別する一意の文字列。この値は、AWS アカウントの VPC ダッシュボードで確認できます。
aws-regionプライベートエンドポイントのAmazon Web Servicesリージョンを識別するラベル。
service-name-stringプライベートエンドポイントのサービス名を識別する一意のstring 。 この値は、
AtlasProjectカスタム リソースのstatus.privateEndpoints.serviceNameフィールド内で見つけます。your-application-subnet-idsAWS VPCが使用するサブネットを識別する一意の string。各サブネットはスペースで区切ります。これらの値は、Subnet AWSアカウントの ダッシュボードで確認できます。
IMPORTANT: You must specify at least one subnet. If you don't, AWS won't provision a interface endpoint in your VPC. An interface endpoint is required for clients in your VPC to send traffic to the private endpoint.
Amazon Web Services CLI で コマンドを実行します。
出力の
VpcEndpointId値に注目してください。例
"VpcEndpoint": { "VpcEndpointId": "vpce-XXXXXX", "VpcEndpointType": "Interface", "VpcId": "vpc-XXXXX", "ServiceName": "com.amazonaws.vpce.{aws-region}.vpce-svc-XXXX", "State": "pendingAcceptance",
詳細については、 AWSドキュメントの「 インターフェイスエンドポイントの作成 」を参照してください。
spec.privateEndpoints パラメータを更新します。
Update the spec.privateEndpoints parameter for the AtlasProject Custom Resource. Specify the AWS region and replace vpce-id with the VpcEndpointId values for your private endpoints and run the following command:
注意
ピア の一意の識別子は、Amazon Web ServicesVPC アカウントのVPC Amazon Web Servicesダッシュボードで確認できます。
cat <<EOF | kubectl apply -f - apiVersion: atlas.mongodb.com/v1 kind: AtlasProject metadata: name: my-project spec: name: Test Atlas Operator Project privateEndpoints: - provider: "AWS" region: "{aws-region}" id: "{vpce-id}" EOF
Atlas Kubernetes Operator がクラスターに接続するために作成したシークレットを取得します。
次のコマンドをコピーします。
重要
次のコマンドには
jq1.6 以上が必要です。kubectl get secret {my-project}-{my-atlas-cluster}-{my-database-user} -o json | jq -r '.data | with_entries(.value |= @base64d)'; 次のプレースホルダーをカスタム リソースの詳細に置き換えます。
my-projectAtlasProjectカスタム リソースのmetadataフィールドの値を指定します。my-atlas-clusterAtlasDeploymentカスタム リソースのmetadataフィールドの値を指定します。my-database-userAtlasDatabaseUserカスタム リソースのmetadataフィールドの値を指定します。コマンドを実行します。
注意
接続文字列は次の例とは異なります。 複数のプライベートエンドポイントがある場合、シークレットには適切な数値サフィックスを持つ複数の
connectionStringPrivateフィールドとconnectionStringPrivateSvrフィールドが含まれます(例:connectionStringPrivate1、connectionStringPrivate2など)。{ "connectionStringPrivate": "mongodb://pl-0-eastus2.uzgh6.mongodb.net:1024,pl-0-eastus2.uzgh6.mongodb.net:1025,pl-0-eastus2.uzgh6.mongodb.net:1026/?ssl=truereplicaSet=atlas-18bndf-shard-0", "connectionStringPrivateSrv": "mongodb+srv://cluster0-pl-0.uzgh6.mongodb.net", "password": "P@@sword%", "username": "theuser" } このシークレットはアプリケーションで使用できます。
containers: - name: test-app env: - name: "CONNECTION_STRING" valueFrom: secretKeyRef: name: my-project-my-atlas-cluster-my-database-user key: connectionStringPrivate
spec.privateEndpointsパラメータを指定します。
Specify the spec.privateEndpoints parameter for the AtlasProject Custom Resource. In the spec.privateEndpoints.provider field, specify AZURE. Replace the placeholder {azure-region} with the Azure region information for your private endpoints and run the following command:
cat <<EOF | kubectl apply -f - apiVersion: atlas.mongodb.com/v1 kind: AtlasProject metadata: name: my-project spec: name: Test Atlas Operator Project privateEndpoints: - provider: "AZURE" region: "{azure-region}" EOF
Atlas は選択したリージョンに VNET リソースを作成します。 これが完了するまでに数分かかる場合があります。
プライベートエンドポイント ネットワーク ポリシーを無効にします。
Atlas はプライベートエンドポイントのネットワークポリシーをサポートしていません。
次のコマンドをコピーします。
az network vnet subnet update --resource-group {resource-group-name} --vnet-name {vnet-name} --name {subnet-name} --disable-private-endpoint-network-policies true 次のプレースホルダーをAzure VNet の詳細で置き換えます。
resource-group-nameAtlas への接続に使用する VNet を含むリソース グループの、人間が判読可能なラベル。 この値は、 AzureダッシュボードのResource Group Propertiesページで確認できます。
vnet-nameAtlas への接続に使用する VNet を識別する、人間が判読可能なラベル。 この値は、 AzureダッシュボードのVirtual Networkページで確認できます。
subnet-nameお使いの Azure VNet 内のサブネットを識別する、人間が判読できるラベル。この値は、あなたの Azure ダッシュボードの Virtual Network Subnets ページで確認できます。
Azure CLI で コマンドを実行します。
詳細については、プライベートエンドポイントのネットワーク ポリシーを管理するの Azure ドキュメントを参照してください。
プライベートエンドポイントのサービス ID と名前を見つけます。
次のコマンドを実行します:
kubectl get atlasproject my-project -o yaml カスタム
AtlasProjectリソース の フィールドと フィールド内の各プライベートエンドポイントのサービス リソース ID とサービス名をメモします。status.privateEndpoints.serviceResourceIdstatus.privateEndpoints.serviceName
Azure CLI を使用して、各プライベートエンドポイントを構成します。
プライベートエンドポイントを作成するには、次の手順に従います。
次のコマンドをコピーします。
az network private-endpoint create --resource-group {resource-group-name} --name {endpoint-name} --vnet-name {vnet-name} --subnet {subnet-name} --private-connection-resource-id {serviceResourceId} --connection-name {serviceName} --manual-request true 次のプレースホルダーをAzure VNet の詳細で置き換えます。
resource-group-nameAtlas への接続に使用する VNet を含むリソース グループの、人間が判読可能なラベル。 この値は、 AzureダッシュボードのResource Group Propertiesページで確認できます。
endpoint-nameプライベートエンドポイントを識別する、人間が判読可能なラベル。 これをここで指定します。
vnet-nameAtlas への接続に使用する VNet を識別する、人間が判読可能なラベル。 この値は、 AzureダッシュボードのVirtual Networkページで確認できます。
subnet-nameお使いの Azure VNet 内のサブネットを識別する、人間が判読できるラベル。この値は、あなたの Azure ダッシュボードの Virtual Network Subnets ページで確認できます。
serviceResourceIdプライベートエンドポイントのサービス リソースを識別する一意のstring 。 この値は、
AtlasProjectカスタム リソースのstatus.privateEndpoints.serviceResourceIdフィールド内で見つけます。serviceNameプライベートエンドポイントのサービス名を識別する一意のstring 。 この値は、
AtlasProjectカスタム リソースのstatus.privateEndpoints.serviceNameフィールド内で見つけます。Azure CLI で コマンドを実行します。
spec.privateEndpoints パラメータを更新します。
Update the spec.privateEndpoints parameter for the AtlasProject Custom Resource. Specify the the Azure region, Resource ID, and IP address information for your private endpoints and run the following command:
注意
あなたの Azure ダッシュボード上の Properties ページには、Resource ID フィールドで作成したプライベートエンドポイントの一意の識別子が表示されます。
お使いの Azure ダッシュボード上の Overview ページには、フィールド Private IP で作成したプライベートエンドポイント ネットワーク インターフェースのプライベート IP アドレスが表示されます。
cat <<EOF | kubectl apply -f - apiVersion: atlas.mongodb.com/v1 kind: AtlasProject metadata: name: my-project spec: name: Test Atlas Operator Project privateEndpoints: - provider: "Azure" region: "{azure-region}" id: "{resource-id}" ip: "{private-ip}" EOF
Atlas Kubernetes Operator がクラスターに接続するために作成したシークレットを取得します。
次のコマンドをコピーします。
重要
次のコマンドには
jq1.6 以上が必要です。kubectl get secret {my-project}-{my-atlas-cluster}-{my-database-user} -o json | jq -r '.data | with_entries(.value |= @base64d)'; 次のプレースホルダーをカスタム リソースの詳細に置き換えます。
my-projectAtlasProjectカスタム リソースのmetadataフィールドの値を指定します。my-atlas-clusterAtlasDeploymentカスタム リソースのmetadataフィールドの値を指定します。my-database-userAtlasDatabaseUserカスタム リソースのmetadataフィールドの値を指定します。コマンドを実行します。
注意
接続文字列は次の例とは異なります。 複数のプライベートエンドポイントがある場合、シークレットには適切な数値サフィックスを持つ複数の
connectionStringPrivateフィールドとconnectionStringPrivateSvrフィールドが含まれます(例:connectionStringPrivate1、connectionStringPrivate2など)。{ "connectionStringPrivate": "mongodb://pl-0-eastus2.uzgh6.mongodb.net:1024,pl-0-eastus2.uzgh6.mongodb.net:1025,pl-0-eastus2.uzgh6.mongodb.net:1026/?ssl=truereplicaSet=atlas-18bndf-shard-0", "connectionStringPrivateSrv": "mongodb+srv://cluster0-pl-0.uzgh6.mongodb.net", "password": "P@@sword%", "username": "theuser" } このシークレットはアプリケーションで使用できます。
containers: - name: test-app env: - name: "CONNECTION_STRING" valueFrom: secretKeyRef: name: my-project-my-atlas-cluster-my-database-user key: connectionStringPrivate
spec.privateEndpointsパラメータを指定します。
spec.privateEndpointsAtlasProjectカスタム リソース の パラメータを指定します。spec.privateEndpoints.providerフィールドにGCPを指定します。 プレースホルダー{gcp-region}をプライベートエンドポイントのGoogle Cloud Platform リージョン情報に置き換え、次のコマンドを実行します。
cat <<EOF | kubectl apply -f - apiVersion: atlas.mongodb.com/v1 kind: AtlasProject metadata: name: my-project spec: name: Test Atlas Operator Project privateEndpoints: - provider: "GCP" region: "{gcp-region}" EOF
Atlas は選択したリージョンにVPCリソースを作成します。 これが完了するまでに数分かかる場合があります。
プライベートエンドポイントの {unique-ID} を見つけます。
次のコマンドを実行します:
kubectl get atlasproject my-project -o yaml 各サービス アタッチメント名で、
projects/の後に続く{unique-id}に注意してください。 次の例の{unique-id}はp-ogyvk1plka2anycnzl6znr9pです。例
"serviceAttachmentNames": [ "projects/p-ogyvk1plka2anycnzl6znr9p/regions/us-east1/serviceAttachments/sa-us-east1-6274f45bcce0e51662a29b05-0", "projects/p-ogyvk1plka2anycnzl6znr9p/regions/us-east1/serviceAttachments/sa-us-east1-6274f45bcce0e51662a29b05-1", "projects/p-ogyvk1plka2anycnzl6znr9p/regions/us-east1/serviceAttachments/sa-us-east1-6274f45bcce0e51662a29b05-2", "projects/p-ogyvk1plka2anycnzl6znr9p/regions/us-east1/serviceAttachments/sa-us-east1-6274f45bcce0e51662a29b05-3", "projects/p-ogyvk1plka2anycnzl6znr9p/regions/us-east1/serviceAttachments/sa-us-east1-6274f45bcce0e51662a29b05-4", "projects/p-ogyvk1plka2anycnzl6znr9p/regions/us-east1/serviceAttachments/sa-us-east1-6274f45bcce0e51662a29b05-5" ]
プライベートエンドポイントを構成します。
To edit the private endpoints and generate the necessary script with the Atlas UI, see Configure Private Endpoints.
プライベートエンドポイントを手動で設定する方法
次の shell スクリプトをコピーします。
!/bin/bash gcloud config set project {google-cloud-project-id} for i in {0..5} do gcloud compute addresses create {private-service-connect-endpoint-prefix}-ip-$i --region={gcp-region} --subnet={subnet-name} done for i in {0..5} do if [ $(gcloud compute addresses describe {private-service-connect-endpoint-prefix}-ip-$i --region={gcp-region} --format="value(status)") != "RESERVED" ]; then echo "{private-service-connect-endpoint-prefix}-ip-$i is not RESERVED"; exit 1; fi done for i in {0..5} do gcloud compute forwarding-rules create {private-service-connect-endpoint-prefix}-$i --region={gcp-region} --network={vpc-name} --address={private-service-connect-endpoint-prefix}-ip-$i --target-service-attachment=projects/{unique-ID}/regions/{gcp-region}/serviceAttachments/sa-{gcp-region}-{org-id}-$i done if [ $(gcloud compute forwarding-rules list --regions={gcp-region} --format="csv[no-heading](name)" --filter="name:{private-service-connect-endpoint-prefix}" | wc -l) -gt 50 ]; then echo "Project has too many forwarding rules that match prefix {endpoint-name}. Either delete the competing resources or choose another endpoint prefix." exit 2; fi gcloud compute forwarding-rules list --regions={gcp-region} --format="json(IPAddress,name)" --filter="name:{private-service-connect-endpoint-prefix}" > atlasEndpoints-{endpoint-name}.json 次のプレースホルダーを、 Google Cloud Platform VPCの詳細に置き換えます。
google-cloud-project-idIDGoogle Cloud Platformプロジェクトを識別する一意の 。この値は、 Google Cloud Platformの Dashboard ページで確認できます。
private-service-connect-endpoint-prefix作成されたすべてのエンドポイントのプレフィックスを付け、エンドポイントグループを識別する、人間が判読可能なラベル。
gcp-regionLabel that identifies the Google Cloud Platform region of the private endpoint.
subnet-nameGoogle Cloud Platform の VPC 内のサブネットを識別する人間が判読できるラベル。この値は、Google Cloud ダッシュボードの VPC Networks ページで確認できます。
vpc-nameAtlas に接続するために使用したい VPC を識別する読みやすいラベル。この値は、Google Cloud ダッシュボードの VPC Networks ページで確認できます。
unique-idプロジェクトのステータスを返すときに記録した一意string 。
org-idUnique 24-digit hexadecimal string that identifies the Atlas organization.
shell ファイルを
setup_psc.shとして保存し、次のコマンドでファイルを保存したディレクトリからスクリプトを実行します。sh setup_psc.sh このスクリプトでは、IP アドレスと転送ルール名のリストを含む
atlasEndpoints-{endpoint-name}.json出力ファイルが作成されます。Atlas Kubernetes Operator の出力をフォーマットするには、次のコマンドを実行します。
yq e -P atlasEndpoints-{endpoint-name}.json > atlasEndpoints-user-private-endpoint.yaml awk 'sub("name","endpointName")sub("IPAddress","ipAddress")' atlasEndpoints-user-private-endpoint.yaml 出力は、次の例のようになります。
- ipAddress: 10.0.0.00 endpointName: {endpoint-name}-0 - ipAddress: 10.0.0.01 endpointName: {endpoint-name}-1 - ipAddress: 10.0.0.02 endpointName: {endpoint-name}-2 - ipAddress: 10.0.0.03 endpointName: {endpoint-name}-3 - ipAddress: 10.0.0.04 endpointName: {endpoint-name}-4 - ipAddress: 10.0.0.05 endpointName: {endpoint-name}-5
spec.privateEndpoints パラメータを更新します。
Update the spec.privateEndpoints parameter for the AtlasProject Custom Resource. Specify the Google Cloud Platform region, Google Cloud Project ID, Private Service Endpoint Prefix, your output information, and run the following command:
cat <<EOF | kubectl apply -f - apiVersion: atlas.mongodb.com/v1 kind: AtlasProject metadata: name: my-project spec: name: Test Atlas Operator Project privateEndpoints: - provider: "GCP" region: "{gcp-region}" gcpProjectId: "{project-id}" endpointGroupName: "{endpoint-name}" endpoints: - ipAddress: {ip-address} endpointName: {endpoint-name}-0 - ipAddress: {ip-address} endpointName: {endpoint-name}-1 - ipAddress: {ip-address} endpointName: {endpoint-name}-2 - ipAddress: {ip-address} endpointName: {endpoint-name}-3 - ipAddress: {ip-address} endpointName: {endpoint-name}-4 - ipAddress: {ip-address} endpointName: {endpoint-name}-5 EOF
Atlas Kubernetes Operator がクラスターに接続するために作成したシークレットを取得します。
次のコマンドをコピーします。
重要
次のコマンドには
jq1.6 以上が必要です。kubectl get secret {my-project}-{my-atlas-cluster}-{my-database-user} -o json | jq -r '.data | with_entries(.value |= @base64d)'; 次のプレースホルダーをカスタム リソースの詳細に置き換えます。
my-projectAtlasProjectカスタム リソースのmetadataフィールドの値を指定します。my-atlas-clusterAtlasDeploymentカスタム リソースのmetadataフィールドの値を指定します。my-database-userAtlasDatabaseUserカスタム リソースのmetadataフィールドの値を指定します。コマンドを実行します。
注意
接続文字列は次の例とは異なります。 複数のプライベートエンドポイントがある場合、シークレットには適切な数値サフィックスを持つ複数の
connectionStringPrivateフィールドとconnectionStringPrivateSvrフィールドが含まれます(例:connectionStringPrivate1、connectionStringPrivate2など)。{ "connectionStringPrivate": "mongodb://pl-0-eastus2.uzgh6.mongodb.net:1024,pl-0-eastus2.uzgh6.mongodb.net:1025,pl-0-eastus2.uzgh6.mongodb.net:1026/?ssl=truereplicaSet=atlas-18bndf-shard-0", "connectionStringPrivateSrv": "mongodb+srv://cluster0-pl-0.uzgh6.mongodb.net", "password": "P@@sword%", "username": "theuser" } このシークレットはアプリケーションで使用できます。
containers: - name: test-app env: - name: "CONNECTION_STRING" valueFrom: secretKeyRef: name: my-project-my-atlas-cluster-my-database-user key: connectionStringPrivate