Atlas 默认会对所有集群存储和快照卷进行静态加密。 您可以将云提供商的 KMS与MongoDB加密storage engine结合使用,从而再增加一个安全层。
您可以使用以下一个或多个客户KMS提供商在 Atlas 中进行静态加密:
注意
密钥管理提供商无需与集群云服务提供商匹配。
要了解有关将KMS与 Atlas 结合使用的更多信息,请参阅:
要使用Atlas Kubernetes Operator管理 KMS 加密,您可以为spec.encryptionAtRest
自定义资源AtlasProject
指定并更新 参数。每次更改任何支持的自定义资源中的spec
字段时, Atlas Kubernetes Operator都会创建或更新相应的Atlas配置。
先决条件
要使用Amazon Web ServicesKMS 中的Atlas Kubernetes Operator 配置静态静态加密,您需要:
Atlas 中的
Project Owner
或Organization Owner
角色。有效的密钥管理凭证和Amazon Web Services KMS的加密密钥。要学习;了解更多信息,请参阅使用Amazon Web Services启用客户托管密钥的先决条件。
您的Atlas账户的假定IAM角色。 要使用Atlas Kubernetes Operator设立假定的IAM角色,请参阅设置统一云提供商集成。 要学习;了解有关基于角色访问权限Amazon Web Services加密密钥的更多信息,请参阅使用Amazon Web Services KMS管理客户数密钥。
重要
如果将加密密钥切换为基于角色的访问权限,就无法撤销基于角色的访问权限配置,也无法恢复该项目上基于档案的加密密钥访问权限。
要在Atlas Kubernetes Operator中使用Azure Key Vault 配置静态静态加密,您需要:
Atlas 中的
Project Owner
或Organization Owner
角色。有效的密钥管理凭证和Azure Key Vault的加密密钥。要学习;了解详情,请参阅使用Azure启用客户托管密钥的先决条件。
要在 中使用Google Cloud PlatformKMS Atlas Kubernetes Operator配置静态静态加密,您需要:
Atlas 中的
Project Owner
或Organization Owner
角色。有效的密钥管理凭证和Google Cloud Platform KMS的加密密钥。要学习;了解更多信息,请参阅使用Google Cloud Platform启用客户托管密钥的先决条件。
步骤
通过以下步骤,使用客户托管的密钥加密您的 Atlas 数据:
使用您的Amazon Web Services凭证创建密钥。
使用以下参数的值创建密钥:
Parameter | 说明 |
---|---|
| 唯一的字母数字string Amazon Web Services,用于标识您用于加密和解密MongoDB 主密钥的 客户主密钥。 |
| 指示客户主密钥所在Amazon Web Services区域的标签。 |
| 唯一的Amazon Web Services ARN ,用于标识有权管理客户主密钥的Amazon Web Services IAMAmazon Web Services角色。 要查找该值,请执行以下操作:
Amazon Web Services在 Summary 部分中显示ARN 。 |
要创建并标记密钥,请使用您的Amazon Web Services凭证运行以下命令:
kubectl create secret generic aws-ear-creds \ --from-literal="customerMasterKeyID=<customer-master-key>" \ --from-literal="region=<aws-region>" \ --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
指示此项目是否使用Amazon Web Services KMS加密数据的标志。要使用Amazon Web Services KMS启用静态加密,请将此参数设置为
true
。要使用Amazon Web Services KMS禁用静态加密,请将此参数设置为false
。如果您使用Amazon Web Services KMS禁用静态加密,Atlas Kubernetes Operator 会删除配置详细信息。spec.encryptionAtRest.awsKms.secretRef.name
包含Amazon Web Services凭证的密钥名称。
spec.encryptionAtRest.awsKms.secretRef.namespace
包含Amazon Web Services的命名空间。如果未指定,此参数默认为
AtlasProject
自定义资源的命名空间。我们建议您使用包含
customerMasterKeyID
、region
和roleId
值的密钥,而不是以下参数:spec.encryptionAtRest.awsKms.customerMasterKeyID
spec.encryptionAtRest.awsKms.region
spec.encryptionAtRest.awsKms.roleId
运行以下命令:
cat <<EOF | kubectl apply -f - apiVersion: atlas.mongodb.com/v1 kind: AtlasProject metadata: name: my-project labels: app.kubernetes.io/version: 1.6.0 spec: name: Test Atlas Operator Project encryptionAtRest: awsKms: enabled: true secretRef: name: aws-ear-creds namespace: mongodb-atlas-system EOF
使用客户管理的密钥为集群启用静态加密。
使用客户托管的密钥为项目启用静态加密后,必须在集群级别启用静态加密才能加密数据。
运行以下命令,将spec.deploymentSpec.encryptionAtRestProvider
添加到您的AtlasDeployment
自定义资源中,从而使用您的Amazon Web Services密钥为此集群启用静态加密:
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 帐户凭据所在的 Azure 部署位置。有效值包括 |
| 唯一的 36 位十六进制字符串,用于标识Azure应用程序。 |
| 带有标识Azure Key Vault 的唯一密钥的解决。 |
| stringAzure标识包含密钥的 Key Vault 的唯一 。 |
| 用于标识包含 Azure Key Vault 的 Azure 资源组的标签。Azure在资源组的详细信息页面显示资源组名称。 |
| 唯一的 36-十六进制string ,用于标识您的Azure订阅。 Azure在订阅的详细信息页面上显示订阅ID 。 |
要创建并标记密钥,请使用您的Azure凭证运行命令:
kubectl create secret generic azure-ear-creds \ --from-literal="azureEnvironment=<deployment-locationy>" \ --from-literal="clientID=<azure-app>" \ --from-literal="keyIdentifier=<web-address>" \ --from-literal="keyVaultName=<key-vault>" \ --from-literal="resourceGroupName=<resource-group>" \ --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.
enabled
指示此项目是否使用Azure Key Vault 静态加密静态数据的标志。 要使用Azure Key Vault启用静态加密,请将此参数设立为
true
。 要禁用使用Azure Key Vault的静态加密,请将此参数设立为false
。 如果使用Azure Key Vault 禁用静态静态加密, Atlas Kubernetes Operator会删除配置详细信息。spec.encryptionAtRest.azureKeyVault.
secret
与在
spec.encryptionAtRest.azureKeyVault.tenantID
中指定的Azure Key Vault 租户关联的私有数据。spec.encryptionAtRest.azureKeyVault.
tenantID
唯一的 36 位十六进制字符串,用于标识 Azure 订阅中的 Azure Active 目录 租户。Azure在租户属性页面上显示租户 ID。
spec.encryptionAtRest.azureKeyVault.secretRef.name
包含Azure的密钥名称。
spec.encryptionAtRest.azureKeyVault.secretRef.namespace
包含Azure 档案的命名空间。 如果未指定,此参数默认为
AtlasProject
自定义资源的命名空间。我们建议您使用包含
azureEnvironment
、clientID
、keyIdentifier
、keyVaultName
、resourceGroupName
和subscriptionID
值的密钥,而不是以下参数:spec.encryptionAtRest.azureKeyVault.azureEnvironment
spec.encryptionAtRest.azureKeyVault.clientID
spec.encryptionAtRest.azureKeyVault.keyIdentifier
spec.encryptionAtRest.azureKeyVault.keyVaultName
spec.encryptionAtRest.azureKeyVault.resourceGroupName
spec.encryptionAtRest.azureKeyVault.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: enabled: true secret: "EXAMPLESECRET" 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 Platform凭证创建密钥。
使用以下参数的值创建密钥:
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 Platform KMS启用静态加密,请将此参数设置为
true
。要使用 Google Cloud Platform 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
值的密钥,而不是以下参数:spec.encryptionAtRest.googleCloudKms.keyVersionResourceID
spec.encryptionAtRest.googleCloudKms.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 Platform密钥为此集群启用静态加密:
cat <<EOF | kubectl apply -f - apiVersion: atlas.mongodb.com/v1 kind: AtlasDeployment metadata: name: my-cluster labels: app.kubernetes.io/version: 1.6.0 spec: name: Test Atlas Operator Cluster DeploymentSpec: encryptionAtRestProvider: "GCP" EOF