- Deploy MongoDB Resources on Multiple Kubernetes Clusters (Beta) >
- Multi-Kubernetes-Cluster Quick Start >
- Quick Start Procedure
Quick Start Procedure¶
On this page
Before you begin:
- Learn about multi-Kubernetes-cluster deployments
- Review the list of multi-Kubernetes-cluster services and CLI used in this quick start
- Complete the prerequisites
Note
The following procedures scope your multi-Kubernetes-cluster deployment to a single
namespace named mongodb
. You can configure your multi-Kubernetes-cluster deployment to
watch resources in multiple namespaces
or all namespaces.
Deploy a MongoDBMulti Resource¶
Select the appropriate tab based on whether you want to encrypt replica set connections in your multi-Kubernetes-cluster deployments using TLS certificates.
- With TLS-Encrypted Connections
- With Non-Encrypted Connections
You can use the following procedures in this TLS-Encrypted Connections tab:
- Deploy a
MongoDBMulti
Resource - Renew TLS Certificates for a
MongoDBMulti
Resource
These procedures establish TLS-encrypted connections between MongoDB hosts in a replica set, and between client applications and MongoDB deployments.
Before you begin, you must have valid certificates for TLS encryption.
Deploy 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-deployment
and you set the
prefix to mdb
, you must name the TLS secret for the
client TLS communications mdb-my-deployment-cert
. Also,
you must name the TLS secret for internal cluster authentication
(if enabled) mdb-my-deployment-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 ConfigMap to link your CA with your MongoDBMulti
custom resource.¶
Run the kubectl
command to link your CA to your MongoDBMulti
custom resource:
Run the multi-cluster CLI
.¶
By default, the Kubernetes Operator is scoped to the mongodb
namespace.
The following command creates one central cluster, three member clusters,
and a namespace labeled mongodb
in each of the clusters.
Change to the directory to which you cloned the Kubernetes Operator repository, and then to the directory that contains the Multi-cluster CLI.
Run the multi-cluster CLI:
Set the Istio injection webhook in each member cluster.¶
Run the following command on the central cluster, specifying the context
for each of the member clusters in the deployment. These commands add
the istio-injection=enabled
label to the mongodb
namespace on
each member cluster. This label configures Istio’s injection webhook
which enables adding a sidecar to any Pods that you create in this
namespace. To learn more, see Automatic sidecar injection
in the Istio documentation.
Configure kubectl
to use the central cluster’s namespace.¶
If you have not done so already, run the following commands to run
all kubectl
commands on the central cluster in the default
namespace. In the following steps, you install the Kubernetes Operator
into this namespace.
Add the MongoDB Helm Charts for Kubernetes repository to Helm.¶
Install the MongoDB Enterprise Kubernetes Operator in the central cluster.¶
Use the MongoDB Helm Charts for Kubernetes for multi-Kubernetes-cluster deployments to install Kubernetes Operator for managing your multi-Kubernetes-cluster deployment:
Deploy the MongoDB resource.¶
Create a secret so that the Kubernetes Operator can create and update objects in your Ops Manager project. To learn more, see Create Credentials for the Kubernetes Operator.
Create a ConfigMap to link the Kubernetes Operator to your Ops Manager project. To learn more, see Create One Project using a ConfigMap.
Configure the required service accounts for each member cluster:
Set
spec.credentials
,spec.opsManagerconfigMapRef.name
, and security settings and deploy the MongoDB resource. In the following code sample,duplicateServiceObjects
is set totrue
to enable DNS proxying in Istio.Note
To enable the cross-cluster DNS resolution by the Istio service mesh, this tutorial creates service objects with a single ClusterIP address per each Kubernetes Pod.
The Kubernetes Operator copies the ConfigMap with the CA that you created in step 2 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 TLS Certificates for a MongoDBMulti Resource
Renew your TLS certificates periodically using the following procedure.
This procedure doesn’t encrypt connections between MongoDB hosts in a replica set, and between client applications and MongoDB deployments.
Deploy a MongoDBMulti Resource
Run the multi-cluster CLI
.¶
By default, the Kubernetes Operator is scoped to the mongodb
namespace.
The following command creates one central cluster, three member clusters,
and a namespace labeled mongodb
in each of the clusters.
Change to the directory to which you cloned the Kubernetes Operator repository, and then to the directory that contains the Multi-cluster CLI.
Run the multi-cluster CLI:
Set the Istio injection webhook in each member cluster.¶
Run the following command on the central cluster, specifying the context
for each of the member clusters in the deployment. These commands add
the istio-injection=enabled
label to the mongodb
namespace on
each member cluster. This label configures Istio’s injection webhook
which enables adding a sidecar to any Pods that you create in this
namespace. To learn more, see Automatic sidecar injection
in the Istio documentation.
Configure kubectl
to use the central cluster’s namespace.¶
If you have not done so already, run the following commands to run
all kubectl
commands on the central cluster in the default
namespace. In the following steps, you install the Kubernetes Operator
into this namespace.
Add the MongoDB Helm Charts for Kubernetes repository to Helm.¶
Install the MongoDB Enterprise Kubernetes Operator in the central cluster.¶
Use the MongoDB Helm Charts for Kubernetes for multi-Kubernetes-cluster deployments to install Kubernetes Operator for managing your multi-Kubernetes-cluster deployment:
Deploy the MongoDB resource.¶
On the central cluster, create a secret so that the Kubernetes Operator can create and update objects in your Ops Manager project. To learn more, see Create Credentials for the Kubernetes Operator.
On the central cluster, create a ConfigMap to link the Kubernetes Operator to your Ops Manager project. To learn more, see Create One Project using a ConfigMap.
On the central cluster, configure the required service accounts for each member cluster:
Set
spec.credentials
andspec.opsManager.configMapRef.name
and deploy the MongoDB resource. In the following code sample,duplicateServiceObjects
is set totrue
to enable DNS proxying in Istio.Note
To enable the cross-cluster DNS resolution by the Istio service mesh, this tutorial creates service objects with a single ClusterIP address per each Kubernetes Pod.
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: