- Deploy Multiple Clusters (Beta) >
- Secure Database Resources in Multi-Cluster Deployments >
- Secure Multi-Cluster Deployments with X.509
Secure Multi-Cluster Deployments with X.509¶
On this page
You can configure the Kubernetes Operator to use X.509 certificates to authenticate your client applications in a multi-cluster deployment.
To secure your multi-cluster deployment with X.509 certificates, you run all actions on the central cluster. The Kubernetes Operator propagates the X.509 configuration to each member cluster and updates the Kubernetes Operator configuration on each member cluster.
Prerequisites¶
Before you secure your multi-cluster deployment using TLS encryption, complete the following tasks:
- Follow the steps in the Multi-Cluster Quick Start Prerequisites.
- Deploy a multi-cluster using a Multi-Cluster Quick Start.
- Create credentials for the Kubernetes Operator for the Kubernetes Operator.
Enabling X.509 authentication at the project level configures all agents to use X.509 client authentication when communicating with MongoDB deployments.
X.509 client authentication requires one of the following:
- Cloud Manager
- Ops Manager 5.0.7 or later
To enable internal cluster authentication, create certificates for member clusters in the multi-cluster deployment.
Generate one TLS certificate covering the SANs of all the member clusters in the
MongoDBMulti
resource.For each Kubernetes service that the Kubernetes Operator generates corresponding to each Pod in each member cluster, add SANs to the certificate. In your TLS certificate, the SAN for each Kubernetes service must use the following format:
where
n
ranges from0
toclusterSpecList[member_cluster_index].members - 1
.Generate one TLS certificate for your project’s MongoDB Agents.
- For the MongoDB Agent TLS certificate:
- The Common Name in the TLS certificate must not be empty.
- The combined Organization and Organizational Unit in each TLS certificate must differ from the Organization and Organizational Unit in the TLS certificate for your replica set members.
- For the MongoDB Agent TLS certificate:
You must possess the CA certificate and the key that you used to sign your TLS certificates.
Important
For fresh Kubernetes Operator installations starting with version 1.13, the Kubernetes Operator uses kubernetes.io/tls secrets to store TLS certificates and private keys for Ops Manager and MongoDB resources.
Previous Kubernetes Operator versions required you to concatenate your TLS certificates and private keys into a PEM file and store this file in an Opaque secret.
To maintain backwards compatibility, the Kubernetes Operator continues to support storing PEM files in Opaque secrets. Support of this feature might be removed in a future release.
We recommend that you upgrade to Kubernetes Operator version 1.15.1 or later.
If you have a broken Application Database after upgrading to Kubernetes Operator version 1.14.0 or 1.15.0, see Ops Manager in Failed State.
Enable X.509 Authentication for a MongoDBMulti Resource¶
Create the secret for the TLS certificate of your MongoDBMulti
custom resource.¶
Run the kubectl
command to create a new secret that stores the
MongoDB multi-cluster resource’s certificate:
Note
You must prefix your secrets with <prefix>-<metadata.name>
.
Example
If you call your deployment my-replica-set
and you set the
prefix to mdb
, you must name the TLS secret for the
client TLS communications mdb-my-replica-set-cert
. Also,
you must name the TLS secret for internal cluster authentication
(if enabled) mdb-my-replica-set-clusterfile
.
If you’re using HashiCorp Vault as your secret storage tool, you can Create a Vault Secret instead.
To learn about your options for secret storage, see Configure Secret Storage.
Create the secret for your agent’s X.509 certificate of your MongoDBMulti
custom resource.¶
Run the kubectl
command to create a new secret that stores the agent’s X.509 certificate:
Create the ConfigMap to link your CA with your MongoDBMulti
custom resource.¶
Run the kubectl
command to link your CA to your MongoDBMulti
custom resource:
Update your MongoDBMulti
custom resource to enable X509 authentication.¶
Update your MongoDB multi-cluster resource with security settings from the Kubernetes Operator MongoDB resource specification. The resulting configuration should look as follows:
The Kubernetes Operator copies the ConfigMap with the CA created in the central cluster to each member cluster, generates a concatenated PEM secret, and distributes it to the member clusters.
Verify that the MDB resources are running.¶
For member clusters, run the following commands to verify that the MongoDB Pods are in the running state:
In the central cluster, run the following commands to verify that the
MongoDBMulti
custom resource is in the running state:
Renew X.509 Certificates for a MongoDBMulti Resource¶
If you have already created X.509 certificates, renew them periodically using the following procedure.
Renew the secret for your agent’s X.509 certificates.¶
Run the kubectl
command to renew an existing secret that stores
the MongoDBMulti
resource’s agent certificates: