Atlas 默认会对所有集群存储和快照卷进行静态加密。您可以将云提供商的 KMS 与 MongoDB 加密存储引擎结合使用,增加另一层安全性。
您可以使用以下一个或多个客户KMS提供商在 Atlas 中进行静态加密:
注意
密钥管理提供商无需与集群云服务提供商匹配。
要了解有关将KMS与 Atlas 结合使用的更多信息,请参阅:
要使用 Atlas Kubernetes Operator 管理您的 KMS 加密,您可以指定并更新 spec.encryptionAtRestAtlasProject 自定义资源 的参数。每次更改任何支持的自定义资源中的 spec 字段时,Atlas Kubernetes Operator 都会创建或更新相应的 Atlas 配置。
先决条件
要使用Amazon Web ServicesKMS 中的Atlas Kubernetes Operator 配置静态静态加密,您需要:
The
Project OwnerorOrganization Ownerrole in Atlas.有效的密钥管理凭证和 AWS KMS的加密密钥。要学习;了解更多信息,请参阅使用 AWS 启用客户托管密钥的先决条件。
An assumed IAM role for your Atlas account. To set up an assumed IAM role with the Atlas Kubernetes Operator, see Set Up Unified Cloud Provider Integrations. To learn more about role-based access for an AWS encryption key, see Manage Customer Keys with AWS KMS.
重要
如果将加密密钥切换为基于角色的访问权限,就无法撤销基于角色的访问权限配置,也无法恢复该项目上基于档案的加密密钥访问权限。
要在Atlas Kubernetes Operator中使用Azure Key Vault 配置静态静态加密,您需要:
The
Project OwnerorOrganization Ownerrole in Atlas.有效的密钥管理凭证和Azure Key Vault的加密密钥。要学习;了解详情,请参阅使用Azure启用客户托管密钥的先决条件。
要在 中使用Google Cloud PlatformKMS Atlas Kubernetes Operator配置静态静态加密,您需要:
The
Project OwnerorOrganization Ownerrole in Atlas.有效的密钥管理凭证和Google Cloud Platform KMS的加密密钥。要学习;了解更多信息,请参阅使用Google Cloud Platform启用客户托管密钥的先决条件。
步骤
通过以下步骤,使用客户托管的密钥加密您的 Atlas 数据:
使用您的 AWS凭证创建密钥。
使用以下参数的值创建密钥:
Parameter | 说明 |
|---|---|
| 唯一的字母数字字符串,用于标识您用于加密和解密 MongoDB 主密钥的Amazon Web Services客户主密钥。 |
| 唯一的Amazon Web Services ARN ,用于标识有权管理客户主密钥的Amazon Web Services IAMAmazon Web Services角色。 要查找该值,请执行以下操作:
AWS 在 Summary 部分中显示 ARN。 |
要创建并标记密钥,请使用您的Amazon Web Services凭证运行以下命令:
kubectl create secret generic aws-ear-creds \ --from-literal="CustomerMasterKeyID=<customer-master-key>" \ --from-literal="RoleID=<aws-arn>" \ -n mongodb-atlas-system
kubectl label secret aws-ear-creds atlas.mongodb.com/type=credentials -n mongodb-atlas-system
指定 spec.encryptionAtRest.awsKms 参数。
将 spec.encryptionAtRest.awsKms 对象添加到 spec.encryptionAtRest
AtlasProject自定义资源中的数组,包括以下参数:Parameter说明spec.encryptionAtRest.awsKms.enabled指示此项目是否使用 AWS KMS 对静态数据进行加密的标志。要使用 Amazon Web Services KMS 启用静态加密,请将此参数设置为
true。要使用 Amazon Web Services KMS 禁用静态加密,请将此参数设置为false。如果您使用 Amazon Web Services KMS 禁用静态加密,Atlas Kubernetes Operator 将删除配置详情。spec.encryptionAtRest.awsKms.regionLabel that indicates the AWS region where the customer master key exists.
spec.encryptionAtRest.awsKms.secretRef.name包含Amazon Web Services凭证的密钥名称。
spec.encryptionAtRest.awsKms.secretRef.namespace包含您的Amazon Web Services凭证的命名空间。如果未指定,此参数默认为
AtlasProject自定义资源的命名空间。您必须使用包含
AccessKeyID、SecretAccessKey、CustomerMasterKeyID和RoleID值的密钥。运行以下命令:
cat <<EOF | kubectl apply -f - apiVersion: atlas.mongodb.com/v1 kind: AtlasProject metadata: name: my-project spec: name: Test Atlas Operator Project encryptionAtRest: awsKms: enabled: true region: US_EAST_1 secretRef: name: aws-ear-creds namespace: mongodb-atlas-system EOF
使用客户管理的密钥为集群启用静态加密。
使用客户托管的密钥为项目启用静态加密后,必须在集群级别启用静态加密才能加密数据。
运行以下命令,将 spec.deploymentSpec.encryptionAtRestProvider 添加到 AtlasDeployment 自定义资源,从而使用您的 AWS 密钥为此集群启用静态加密:
cat <<EOF | kubectl apply -f - apiVersion: atlas.mongodb.com/v1 kind: AtlasDeployment metadata: name: my-cluster spec: name: Test Atlas Operator Cluster DeploymentSpec: encryptionAtRestProvider: "AWS" EOF
使用您的Azure凭证创建密钥。
使用以下参数的值创建密钥:
Parameter | 说明 |
|---|---|
| 带有标识Azure Key Vault 的唯一密钥的解决。 |
| stringAzure标识包含密钥的 Key Vault 的唯一 。 |
| 与您在 |
| 唯一的 36-十六进制string ,用于标识您的Azure订阅。 Azure在订阅的详细信息页面上显示订阅ID 。 |
要创建并标记密钥,请使用您的Azure凭证运行命令:
kubectl create secret generic azure-ear-creds \ --from-literal="KeyIdentifier=<web-address>" \ --from-literal="KeyVaultName=<key-vault>" \ --from-literal="Secret=<secret>" \ --from-literal="SubscriptionID=<subscription>" \ -n mongodb-atlas-system
kubectl label secret azure-ear-creds atlas.mongodb.com/type=credentials -n mongodb-atlas-system
指定 spec.encryptionAtRest.azureKeyVault 参数。
添加 spec.encryptionAtRest.azureKeyVault对象的 spec.encryptionAtRest
AtlasProject自定义资源中的数组,包括以下参数:Parameter说明spec.encryptionAtRest.azureKeyVault.azureEnvironmentAzure 部署位置,其中存储着 Azure 账户凭证。有效值包括
AZURE、AZURE_CHINA和AZURE_GERMANY。spec.encryptionAtRest.azureKeyVault.clientID唯一的 36-十六进制string,用于标识您的 Azure 应用程序。
spec.encryptionAtRest.azureKeyVault.enabled指示此项目是否使用 Azure Key Vault 加密静态数据的标志。要使用 `Azure Key Vault` 启用静态加密,请将此参数设置为
true。要使用 Azure Key Vault 禁用静态加密,请将此参数设置为false。如果使用 Azure Key Vault 禁用静态加密,Atlas Kubernetes Operator 将删除配置详情。spec.encryptionAtRest.azureKeyVault.resourceGroupName用于标识包含 Azure Key Vault 的 Azure 资源组的标签。Azure在资源组的详细信息页面显示资源组名称。
spec.encryptionAtRest.azureKeyVault.secretRef.name包含Azure的密钥名称。
spec.encryptionAtRest.azureKeyVault.secretRef.namespace包含您的 Azure 凭证的命名空间。如果未指定,此参数默认为
AtlasProject自定义资源的命名空间。spec.encryptionAtRest.azureKeyVault.tenantID唯一的 36-十六进制string,用于标识Azure订阅中的Azure Active Directory 租户。Azure在租户属性页面上显示租户ID 。
您必须使用包含
KeyVaultName、KeyIdentifier、Secret和SubscriptionID值的密钥。运行以下命令:
cat <<EOF | kubectl apply -f - apiVersion: atlas.mongodb.com/v1 kind: AtlasProject metadata: name: my-project spec: name: Test Atlas Operator Project encryptionAtRest: azureKeyVault: azureEnvironment: AZURE clientID: "12345678-90ab-cdef-1234-567890abcdef" enabled: true resourceGroupName: "myResourceGroup" tenantID: "e8e4b6ba-ff32-4c88-a9af-EXAMPLEID" secretRef: name: azure-ear-creds namespace: mongodb-atlas-system EOF
使用客户管理的密钥为集群启用静态加密。
使用客户托管的密钥为项目启用静态加密后,必须在集群级别启用静态加密才能加密数据。
运行以下命令,将 spec.deploymentSpec.encryptionAtRestProvider 添加到您的 AtlasDeployment 自定义资源 中,从而使用您的 Azure 密钥为此集群启用静态加密:
cat <<EOF | kubectl apply -f - apiVersion: atlas.mongodb.com/v1 kind: AtlasDeployment metadata: name: my-cluster spec: name: Test Atlas Operator Cluster DeploymentSpec: encryptionAtRestProvider: "AZURE" EOF
使用您的 Google Cloud凭证创建密钥。
使用以下参数的值创建密钥:
Parameter | 说明 |
|---|---|
| 显示 的密钥版本资源ID Google Cloud PlatformKMS的唯一资源路径。 |
| JSON文件,其中包含Google Cloud PlatformKMS 帐户的Google Cloud Platform 凭证。 重要提示:您必须正确设置JSON对象的格式。 确保文件中的凭证字段正确缩进。 |
以下示例显示了ServiceAccountKey JSON文件的内容:
{ "type": "service_account", "project_id": "my-project-common-0", "private_key_id": "e120598ea4f88249469fcdd75a9a785c1bb3\", "private_key": "-----BEGIN PRIVATE KEY-----\\nMIIEuwIBA(truncated)SfecnS0mT94D9\\n-----END PRIVATE KEY-----\\n\", "client_email": "my-email-kms-0@my-project-common-0.iam.gserviceaccount.com\", "client_id": "10180967717292066", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://accounts.google.com/o/oauth2/token", "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/my-email-kms-0%40my-project-common-0.iam.gserviceaccount.com" "universe_domain": "googleapis.com" }
要创建并标记密钥,请使用您的Google Cloud Platform凭证运行以下命令:
kubectl create secret generic azure-ear-creds \ --from-literal="KeyVersionResourceID=<resource-id>" \ --from-file="ServiceAccountKey=<your-service-account-key-files.json>" \ -n mongodb-atlas-system
kubectl label secret gcp-ear-creds atlas.mongodb.com/type=credentials -n mongodb-atlas-system
指定 spec.encryptionAtRest.googleCloudKms 参数。
添加 spec.encryptionAtRest.googleCloudKms对象的 spec.encryptionAtRest
AtlasProject自定义资源中的数组,包括以下参数:Parameter说明spec.encryptionAtRest.googleCloudKms.enabled标志,指示此项目是否使用 Google Cloud Platform KMS 对静态数据进行加密。要使用 Google Cloud KMS 实现静态加密,请将此参数设置为
true。要使用 Google Cloud KMS 禁用静态加密,请将此参数设置为false。如果使用 Google Cloud Platform KMS 禁用静态加密,Atlas Kubernetes Operator 则删除配置详情。spec.encryptionAtRest.googleCloudKms.secretRef.name包含Google Cloud Platform凭证的密钥名称。
spec.encryptionAtRest.googleCloudKms.secretRef.namespace包含您的 Google Cloud Platform 档案的命名空间。如果未指定,此参数默认为
AtlasProject自定义资源的命名空间。您必须使用包含
KeyVersionResourceID和ServiceAccountKey值的密钥。运行以下命令:
cat <<EOF | kubectl apply -f - apiVersion: atlas.mongodb.com/v1 kind: AtlasProject metadata: name: my-project spec: name: Test Atlas Operator Project encryptionAtRest: googleCloudKms: enabled: true secretRef: name: gcp-ear-creds namespace: mongodb-atlas-system EOF
使用客户管理的密钥为集群启用静态加密。
使用客户托管的密钥为项目启用静态加密后,必须在集群级别启用静态加密才能加密数据。
运行以下命令,将 spec.deploymentSpec.encryptionAtRestProvider 添加到您的 AtlasDeployment 自定义资源中,从而使用您的 Google Cloud 密钥为此集群启用静态加密:
cat <<EOF | kubectl apply -f - apiVersion: atlas.mongodb.com/v1 kind: AtlasDeployment metadata: name: my-cluster spec: name: Test Atlas Operator Cluster DeploymentSpec: encryptionAtRestProvider: "GCP" EOF