The /deploy/crds
directory contains example MongoDB resources that you can modify and deploy.
To deploy your first replica set:
- Invoke the following
kubectl
command:kubectl apply -f deploy/crds/mongodb.com_v1_mongodb_cr.yaml --namespace <my-namespace>
- Verify that the MongoDB resource deployed:
kubectl get mongodb --namespace <my-namespace>
- Connect clients to the MongoDB replica set:
mongodb://<metadata.name of the MongoDB resource>-svc.<namespace>.svc.cluster.local:27017/?replicaSet=<replica set name>
You can upgrade the major, minor, and/or feature compatibility versions of your MongoDB resource. These settings are configured in your resource definition YAML file.
-
To upgrade your resource's major and/or minor versions, set the
spec.version
setting to the desired MongoDB version. -
To modify your resource's feature compatibility version, set the
spec.featureCompatibilityVersion
setting to the desired version.
If you update spec.version
to a later version, consider setting spec.featureCompatibilityVersion
to the current working MongoDB version to give yourself the option to downgrade if necessary. To learn more about feature compatibility, see setFeatureCompatibilityVersion
in the MongoDB Manual.
If you want to deploy the operator on OpenShift you will have to provide the environment variable MANAGED_SECURITY_CONTEXT
set to true
for both the mongodb and mongodb agent containers, as well as the operator deployment.
See here for an example of how to provide the required configuration for a MongoDB ReplicaSet.
See here for an example of how to configure the Operator deployment.
Consider the following example MongoDB resource definition:
apiVersion: mongodb.com/v1
kind: MongoDB
metadata:
name: example-mongodb
spec:
members: 3
type: ReplicaSet
version: "4.0.6"
To upgrade this resource from 4.0.6
to 4.2.7
:
-
Edit the resource definition.
a. Update
spec.version
to4.2.7
.b. Update
spec.featureCompatibilityVersion
to4.0
.apiVersion: mongodb.com/v1 kind: MongoDB metadata: name: example-mongodb spec: members: 3 type: ReplicaSet version: "4.2.7" featureCompatibilityVersion: "4.0"
NOTE: Setting
featureCompatibilityVersion
to4.0
disables 4.2 features incompatible with MongoDB 4.0. -
Reapply the configuration to Kubernetes:
kubectl apply -f <example>.yaml --namespace <my-namespace>