|
| 1 | +# OpenShift MongoDB Enterprise Kubernetes Operator |
| 2 | +## Operator Service Catalog and Marketplace |
| 3 | + |
| 4 | +This installation document is a guide for deploying MongoDB Enterprise Kubernetes Operator, Ops Manager and first MongoDB DataBase using OpenShift Operator catalog or Marketplace. |
| 5 | + |
| 6 | +## Configuring required components |
| 7 | + |
| 8 | +Step 1: Create a namespace to install MongoDB |
| 9 | + |
| 10 | +``` |
| 11 | +oc create ns mongodb |
| 12 | +``` |
| 13 | + |
| 14 | +Step 2: Install the operator in the cluster in the namespace created above |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | +Step 3: Wait for the Operator to be deployed. |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | +Step 4: Deploy MongoDB Ops Manager. |
| 23 | + |
| 24 | +Ops Manager is an Enterprise Control Plane for all your MongoDB Clusters. It is a extensive application and may seem complicated. Please visit [Documentation](https://docs.mongodb.com/kubernetes-operator/stable/om-resources/) to plan and configure production deployments. |
| 25 | + |
| 26 | +*Only a single Ops Manager deployment is required for all MongoDB clusters in your organization. This step could be skipped if Ops Manager is already deployed. Alternatively [Cloud Manager](https://cloud.mongodb.com) - hosted Ops Manager could be used instead.* |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | +To deploy a very simple Ops Manager configuration two steps are required. |
| 32 | +1. Create Admin Credential Secret |
| 33 | +```bash |
| 34 | +create secret generic ops-manager-admin-secret \ |
| 35 | +--from-literal=Username="jane.doe@example.com" \ |
| 36 | +--from-literal=Password="Passw0rd." \ |
| 37 | +--from-literal=FirstName="Jane" \ |
| 38 | +--from-literal=LastName="Doe" -n mongodb |
| 39 | +``` |
| 40 | +2. Deploy Ops Manager instance with CRD |
| 41 | + |
| 42 | + |
| 43 | +With sample yaml CRD definition |
| 44 | + |
| 45 | +```yaml |
| 46 | +apiVersion: mongodb.com/v1 |
| 47 | +kind: MongoDBOpsManager |
| 48 | +metadata: |
| 49 | + name: ops-manager |
| 50 | + namespace: mongodb |
| 51 | +spec: |
| 52 | + # the version of Ops Manager to use |
| 53 | + version: 4.4.1 |
| 54 | + |
| 55 | + # the name of the secret containing admin user credentials. |
| 56 | + adminCredentials: ops-manager-admin-secret |
| 57 | + |
| 58 | + externalConnectivity: |
| 59 | + type: LoadBalancer |
| 60 | + |
| 61 | + # the Replica Set backing Ops Manager. |
| 62 | + # appDB has the SCRAM-SHA authentication mode always enabled |
| 63 | + applicationDatabase: |
| 64 | + members: 3 |
| 65 | +``` |
| 66 | +
|
| 67 | +Change the `adminCredentials` property to link to the name of the secret created previously. In this example it is ops-manager-admin. |
| 68 | + |
| 69 | +`Click create.` |
| 70 | + |
| 71 | +>For more detailed installation visit our blog post: https://www.mongodb.com/blog/post/running-mongodb-ops-manager-in-kubernetes |
| 72 | + |
| 73 | +Step 7: Verify MongoDB Ops Manager is successfully deployed. Verify Ops Manager resource and ensure that ops-manager resource reached Running state : |
| 74 | +`oc describe om ops-manager` |
| 75 | + |
| 76 | + |
| 77 | +>NOTE: Wait for the secret ops-manager-admin-key to be created. It contains Global Admin Programmatic API that will be required in the subsequent steps. We recommend to create new Programmatic API Key scoped to a single Ops Manager Organization https://docs.opsmanager.mongodb.com/rapid/tutorial/manage-programmatic-api-keys/#mms-prog-api-key |
| 78 | + |
| 79 | + |
| 80 | +Please note OpsManager URL exposed by LoadBalancer before moving to the next Section |
| 81 | + |
| 82 | +## Deploy MongoDB |
| 83 | + |
| 84 | +In order to create MongoDB Cluster three Kubernetes resources need to be deployed. https://docs.mongodb.com/kubernetes-operator/stable/mdb-resources/ |
| 85 | + |
| 86 | +1. Kubernetes ConfigMap that contain settings for Operator to connect to Ops Manager |
| 87 | + ```bash |
| 88 | + os create configmap <configmap-name> \ |
| 89 | + --from-literal="baseUrl=<OpsManagerURL>" \ |
| 90 | + --from-literal="projectName=<myOpsManagerProjectName>" \ #Optional |
| 91 | + --from-literal="orgId=<Ops Manager OrgID>" |
| 92 | + ``` |
| 93 | + >OpsManagerURL is an Ops Manager url including port (default 8080) noted in Step 7. |
| 94 | + |
| 95 | +>Documentation: https://docs.mongodb.com/kubernetes-operator/stable/tutorial/create-project-using-configmap/#create-k8s-project |
| 96 | + |
| 97 | + |
| 98 | +2. Kubernetes Secret containing Programmatic API Key to Operator to connect to Ops Manager. |
| 99 | +> ops-manager-admin-key secret could be used instead for none production deployments. |
| 100 | + |
| 101 | +``` |
| 102 | +oc -n <metadata.namespace> \ |
| 103 | + create secret generic <myCredentials> \ |
| 104 | + --from-literal="user=<publicKey>" \ |
| 105 | + --from-literal="publicApiKey=<privateKey>" |
| 106 | + ``` |
| 107 | +
|
| 108 | +For instructions on how to create Ops Manager Organization and Programmatic API Key please refer to documentation: https://docs.mongodb.com/kubernetes-operator/stable/tutorial/create-operator-credentials/#create-k8s-credentials |
| 109 | +
|
| 110 | +3. Deploy Ops Manager |
| 111 | + |
| 112 | +
|
| 113 | +Click on the first tile to create the MongoDB Deployment Instance |
| 114 | +
|
| 115 | + |
| 116 | +
|
| 117 | +* Choose a name for MongoDB cluster 'metadata.name` |
| 118 | +* Substitute the values `spec.OpsManager` with a reference to the config map `<configmap-name>` |
| 119 | +* Substitute the values `spec.credentials` with secret name `<myCredentials>`. |
| 120 | +
|
| 121 | +`Click Create. ` |
| 122 | +
|
| 123 | +>For comprehensive Documentation, please visit https://docs.mongodb.com/kubernetes-operator/stable/mdb-resources/ |
| 124 | +
|
| 125 | +### Verify MongoDB cluster is operational |
| 126 | +
|
| 127 | +Verify Status of MongoDB Resource reached ``Running`` state |
| 128 | +>Optionally monitor state of pods, sts and services linked to MongoDB CRD |
| 129 | + |
| 130 | +
|
| 131 | +>Note: MongoDB Enterprise Operator logs are the best source to start troubleshooting any issues with deployments |
| 132 | +
|
| 133 | +### Connect to MongoDB Cluster |
| 134 | +
|
| 135 | +MongoDB Enterprise Operator create Kubernetes Service For each MongoDB deployed using default port 27017. |
| 136 | +
|
| 137 | +` <mongodb-service-name>.<k8s-namespace>.svc.<cluster-name>` |
| 138 | +
|
| 139 | +MongoDB Connection String could be built using SRV record |
| 140 | +
|
| 141 | +` mongodb+srv://<mongodb-service-name>.<k8s-namespace>.svc.<cluster-name>` |
| 142 | +
|
| 143 | +***In order to connect to MongoDB from outside of OpenShift cluster an ingress route needs to be created manually. Operator does not create ingress or external services.*** |
| 144 | +
|
| 145 | +***MongoDB ReplicaSet External connectivity requires Split Horizon Configuration: [Connect to a MongoDB Database Resource from Outside Kubernetes](https://docs.mongodb.com/kubernetes-operator/stable/tutorial/connect-from-outside-k8s/)*** |
| 146 | +
|
| 147 | +>EXAMPLE |
| 148 | +To connect to a sharded cluster resource named shardedcluster, you might use the following connection string: <br/> ``mongo --host shardedcluster-mongos-0.shardedcluster-svc.mongodb.svc.cluster.local --port 27017`` |
| 149 | +
|
0 commit comments