Navigation

Configure an Ops Manager Resource to use Remote Mode

In a default configuration, the MongoDB Agents and Backup Daemons access MongoDB installation archives over the Internet from MongoDB, Inc.

You can configure Ops Manager to run in Remote Mode with the Kubernetes Operator if the nodes in your Kubernetes cluster don’t have access to the Internet. The Backup Daemons and managed MongoDB resources download installation archives only from Ops Manager, which proxies download requests to an HTTP endpoint on a local web server or S3-compatible store deployed to your Kubernetes cluster.

This procedure covers deploying an Nginx HTTP server to your Kubernetes cluster to host the MongoDB installation archives.

Prerequisites and Considerations

Deploy an Ops Manager Resource. The following procedure shows you how to update your Ops Manager Kubernetes object to enable Remote Mode.

Note

You can enable Remote Mode only on Ops Manager 4.4 or later.

Procedure

1

Configure kubectl to default to your namespace.

If you have not already, run the following command to execute all kubectl commands in the namespace you created:

kubectl config set-context $(kubectl config current-context) --namespace=<namespace>
2

Create a ConfigMap for Nginx.

The ConfigMap in this tutorial configures Nginx to:

  • Run an HTTP server named localhost listening on port 80 on a node in your Kubernetes cluster, and
  • Route HTTP requests for specific resources to locations that serve the the MongoDB Server and MongoDB Database Tools installation archives.
  1. Paste the following example Nginx ConfigMap into a text editor:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    ---
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: nginx-conf
    data:
      nginx.conf: |
        events {}
        http {
          server {
            server_name localhost;
            listen 80;
            location /linux/ {
              alias /mongodb-ops-manager/mongodb-releases/linux/;
            }
            location /tools/ {
              alias /tools/;
            }
          }
        }
    ...
    
  2. Save this file with a .yaml file extension.

  3. Create the Nginx ConfigMap by invoking the following kubectl command on the ConfigMap file you created:

    kubectl apply -f <nginix-configmap>.yaml
    
3

Deploy Nginx to your Kubernetes cluster.

The Nginx resource configuration in this tutorial:

  • Deploys one Nginx replica,
  • Creates volume mounts to store MongoDB Server and MongoDB Database Tools installation archives, and
  • Defines init containers that use curl commands to download the installation archives that Nginx serves to MongoDB Database resources you deploy in your Kubernetes cluster.
  1. Paste the following example Nginx resource configuration into a text editor:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: nginx-deployment
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: nginx
      template:
        metadata:
          labels:
            app: nginx
        spec:
          containers:
            - image: nginx:1.14.2
              imagePullPolicy: IfNotPresent
              name: nginx
              ports:
                - containerPort: 80
              volumeMounts:
                - mountPath: /mongodb-ops-manager/mongodb-releases/linux
                  name: mongodb-versions
                - mountPath: /tools/db/
                  name: mongodb-tools
                - name: nginx-conf
                  mountPath: /etc/nginx/nginx.conf
                  subPath: nginx.conf
          initContainers:
            - name: setting-up-ubuntu-mongodb
              image: curlimages/curl:latest
              command:
                - curl
                - -L
                - https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1604-4.2.0.tgz
                - -o
                - /mongodb-ops-manager/mongodb-releases/linux/mongodb-linux-x86_64-ubuntu1604-4.2.0.tgz
              volumeMounts:
                - name: mongodb-versions
                  mountPath: /mongodb-ops-manager/mongodb-releases/linux
            - name: setting-up-ubuntu-mongodb-tools
              image: curlimages/curl:latest
              command:
                - curl
                - -L
                - https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu1604-x86_64-100.1.0.tgz
                - -o
                - /tools/db/mongodb-database-tools-ubuntu1604-x86_64-100.1.0.tgz
              volumeMounts:
                - name: mongodb-tools
                  mountPath: /tools/db/
          restartPolicy: Always
          securityContext: {}
          terminationGracePeriodSeconds: 30
          volumes:
            - name: mongodb-versions
              emptyDir: {}
            - name: mongodb-tools
              emptyDir: {}
            - configMap:
                name: nginx-conf
              name: nginx-conf
    ...
    
  2. Modify the lines highlighted in the example to specify the MongoDB Server versions that you want to install.

    For example, to replace MongoDB version 4.0.2 with a different database version, update the following block:

            - name: setting-up-ubuntu-mongodb
              image: curlimages/curl:latest
              command:
                - curl
                - -L
                - https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1604-4.2.0.tgz
                - -o
                - /mongodb-ops-manager/mongodb-releases/linux/mongodb-linux-x86_64-ubuntu1604-4.2.0.tgz
    

    Update this block to modify the MongoDB Database Tools version:

            - name: setting-up-ubuntu-mongodb-tools
              image: curlimages/curl:latest
              command:
                - curl
                - -L
                - https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu1604-x86_64-100.1.0.tgz
                - -o
                - /tools/db/mongodb-database-tools-ubuntu1604-x86_64-100.1.0.tgz
    
  3. To load multiple versions, append curl commands

    to the appropriate initContainer for each version you want Nginx to serve.

    For example, to configure Nginx to serve MongoDB 4.2.0 and 4.4.0:

    - name: setting-up-ubuntu-mongodb
      image: curlimages/curl:latest
      command:
        - curl
        - -L
        - https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1604-4.2.0.tgz
        - -o
        - /mongodb-ops-manager/mongodb-releases/linux/mongodb-linux-x86_64-ubuntu1604-4.2.0.tgz
        - &&
        - curl
        - -L
        - https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1604-4.4.0.tgz
        - -o
        - /mongodb-ops-manager/mongodb-releases/linux/mongodb-linux-x86_64-ubuntu1604-4.4.0.tgz
    
  4. Save this file with a .yaml file extension.

  5. Deploy Nginx by invoking the following kubectl command on the Nginx resource file you created:

    kubectl apply -f <nginix>.yaml
    
  1. Paste the following example Nginx resource configuration into a text editor:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: nginx-deployment
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: nginx
      template:
        metadata:
          labels:
            app: nginx
        spec:
          containers:
            - image: nginx:1.14.2
              imagePullPolicy: IfNotPresent
              name: nginx
              ports:
                - containerPort: 80
              volumeMounts:
                - mountPath: /mongodb-ops-manager/mongodb-releases/linux
                  name: mongodb-versions
                - mountPath: /tools/db/
                  name: mongodb-tools
                - name: nginx-conf
                  mountPath: /etc/nginx/nginx.conf
                  subPath: nginx.conf
          initContainers:
            - name: setting-up-rhel-mongodb
              image: curlimages/curl:latest
              command:
                - curl
                - -L
                - https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.2.0.tgz
                - -o
                - /mongodb-ops-manager/mongodb-releases/linux/mongodb-linux-x86_64-rhel70-4.2.0.tgz
              volumeMounts:
                - name: mongodb-versions
                  mountPath: /mongodb-ops-manager/mongodb-releases/linux
            - name: setting-up-rhel-mongodb-tools
              image: curlimages/curl:latest
              command:
                - curl
                - -L
                - https://fastdl.mongodb.org/tools/db/mongodb-database-tools-rhel70-x86_64-100.1.0.tgz
                - -o
                - /tools/db/mongodb-database-tools-rhel70-x86_64-100.1.0.tgz
              volumeMounts:
                - name: mongodb-tools
                  mountPath: /tools/db/
          restartPolicy: Always
          securityContext: {}
          terminationGracePeriodSeconds: 30
          volumes:
            - name: mongodb-versions
              emptyDir: {}
            - name: mongodb-tools
              emptyDir: {}
            - configMap:
                name: nginx-conf
              name: nginx-conf
    ...
    
  2. Modify the lines highlighted in the example to specify the MongoDB Server versions that you want to install.

    For example, to replace MongoDB version 4.0.2 with a different database version, update the following block:

            - name: setting-up-rhel-mongodb
              image: curlimages/curl:latest
              command:
                - curl
                - -L
                - https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.2.0.tgz
                - -o
                - /mongodb-ops-manager/mongodb-releases/linux/mongodb-linux-x86_64-rhel70-4.2.0.tgz
    

    Update this block to modify the MongoDB Database Tools version:

            - name: setting-up-rhel-mongodb-tools
              image: curlimages/curl:latest
              command:
                - curl
                - -L
                - https://fastdl.mongodb.org/tools/db/mongodb-database-tools-rhel70-x86_64-100.1.0.tgz
                - -o
                - /tools/db/mongodb-database-tools-rhel70-x86_64-100.1.0.tgz
    
  3. To load multiple versions, append curl commands to the appropriate initContainer for each version you want Nginx to serve.

    For example, to configure Nginx to serve MongoDB 4.2.0 and 4.4.0:

    initContainers:
      - name: setting-up-rhel-mongodb
        image: curlimages/curl:latest
        command:
          - curl
          - -L
          - https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.2.0.tgz
          - -o
          - /mongodb-ops-manager/mongodb-releases/linux/mongodb-linux-x86_64-rhel70-4.2.0.tgz
          - &&
          - curl
          - -L
          - https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.4.0.tgz
          - -o
          - /mongodb-ops-manager/mongodb-releases/linux/mongodb-linux-x86_64-rhel70-4.4.0.tgz
    
  4. Save this file with a .yaml file extension.

  5. Deploy Nginx by invoking the following oc command on the Nginx resource file you created:

    oc apply -f <nginix>.yaml
    
4

Create a Kubernetes service to make Nginx accessible from other pods in your cluster.

The service in this tutorial exposes Nginx to traffic from other nodes in your Kubernetes cluster over port 80. This allows the MongoDB Database resource pods you deploy using the Kubernetes Operator to download the installation archives from Nginx.

Run the following command to create a service your Nginx deployment:

  1. Paste the following example service into a text editor:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    ---
    apiVersion: v1
    kind: Service
    metadata:
     name: nginx-svc
     labels:
       app: nginx
    spec:
     ports:
     - port: 80
       protocol: TCP
     selector:
       app: nginx
    ...
    
  2. Save this file with a .yaml file extension.

  3. Create the service by invoking the following kubectl command on the service file you created:

    kubectl apply -f <nginix-service>.yaml
    
5

Copy and update the highlighted fields of this Ops Manager resource.

The highlighted section uses the following Ops Manager configuration settings:

  • automation.versions.source: remote in spec.configuration to enable Remote Mode.

  • automation.versions.download.baseUrl in spec.configuration to provide the base URL of the HTTP resources that serve the MongoDB installation archives.

    Update this line to replace <namespace> with the namespace to which you deploy resources with the Kubernetes Operator.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
---
apiVersion: mongodb.com/v1
kind: MongoDBOpsManager
metadata:
 name: ops-manager-localmode
spec:
 replicas: 1
 version: 4.4.0-rc1
 adminCredentials: ops-manager-admin-secret
 configuration:
   # this enables local mode in Ops Manager
   automation.versions.source: remote
   automation.versions.download.baseUrl: "http://nginx-svc.<namespace>.svc.cluster.local:80"

 backup:
   enabled: false

 applicationDatabase:
   members: 3
   persistent: true
...
6

Paste the copied example section into your existing Ops Manager resource.

Open your preferred text editor and paste the object specification into the appropriate location in your resource file.

7

Save your Ops Manager config file.

8

Apply changes to your Ops Manager deployment.

Invoke the following kubectl command on the filename of the Ops Manager resource definition:

kubectl apply -f <opsmgr-resource>.yaml
9

Track the status of your Ops Manager instance.

To check the status of your Ops Manager resource, invoke the following command:

kubectl get om -o yaml -w

See Troubleshooting the Kubernetes Operator for information about the resource deployment statuses.

After the Ops Manager resource completes the Reconciling phase, the command returns output similar to the following:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
status:
  applicationDatabase:
    lastTransition: "2020-05-15T16:20:22Z"
    members: 3
    phase: Running
    type: ReplicaSet
    version: 4.2.2-ent
  backup:
    phase: ""
  opsManager:
    lastTransition: "2020-05-15T16:20:26Z"
    phase: Running
    replicas: 1
    url: http://ops-manager-localmode-svc.mongodb.svc.cluster.local:8080
    version: 4.2.12

Copy the value of the status.opsManager.url field, which states the resource’s connection URL. You use this value when you create a ConfigMap later in the procedure.

10

Deploy a MongoDB Database Resource.

  1. If you have not done so already, complete the following prerequisites:
  2. Deploy a MongoDB Database resource in the same namespace to which you deployed Ops Manager. Ensure that you:
    1. Match the spec.opsManager.configMapRef.name of the resource to the metadata.name of your ConfigMap.
    2. Match the spec.credentials of the resource to the name of the secret you created that contains an Ops Manager programmatic API key pair.

MongoDB Agents running in MongoDB database resource containers that you create with the Kubernetes Operator download the installation archives from Ops Manager via Nginx instead of from the Internet.