Skip to content

Commit 8f3c535

Browse files
nammnSimonBaeumer
andauthored
CLOUDP-315293 - migration guide MCO to MCK (#39)
# Summary This pull request introduces a detailed migration guide to help users transition from the MongoDB Community Operator (MCO) to the MongoDB Kubernetes Operator (MCK). The guide ensures a smooth migration process by preserving CRDs, avoiding service interruptions, and properly handing over reconciliation responsibilities. ### Key Changes in the Migration Guide: #### Migration Steps and Instructions: * Added step-by-step instructions for upgrading the MCO chart with `keep` annotations to ensure CRDs are not deleted during the migration. * Included detailed guidance on renaming and updating environment variables to align with MCK expectations, with a mapping table for clarity. * Provided instructions for scaling down the MCO deployment to prevent conflicts with the MCK operator during installation. * Documented the process for installing the MCK Helm chart and ensuring it uses a different release name to avoid RBAC conflicts. #### Post-Migration and Cleanup: * Added steps to verify that MCK has successfully taken over existing resources, including monitoring pod and resource health. * Finalized the migration guide with instructions for uninstalling the MCO chart and verifying that CRDs and other resources remain intact. ## Proof of Work <!-- Enter your proof that it works here.--> ## Checklist - [x] Have you linked a jira ticket and/or is the ticket in the title? - [x] Have you checked whether your jira ticket required DOCSP changes? - [x] Have you checked for release_note changes? ## Reminder (Please remove this when merging) - Please try to Approve or Reject Changes the PR, keep PRs in review as short as possible - Our Short Guide for PRs: [Link](https://docs.google.com/document/d/1T93KUtdvONq43vfTfUt8l92uo4e4SEEvFbIEKOxGr44/edit?tab=t.0) - Remember the following Communication Standards - use comment prefixes for clarity: * **blocking**: Must be addressed before approval. * **follow-up**: Can be addressed in a later PR or ticket. * **q**: Clarifying question. * **nit**: Non-blocking suggestions. * **note**: Side-note, non-actionable. Example: Praise * --> no prefix is considered a question --------- Co-authored-by: Simon Bäumer <[email protected]>
1 parent 5fe46cf commit 8f3c535

File tree

1 file changed

+141
-0
lines changed

1 file changed

+141
-0
lines changed
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
2+
# Migration Guide: MongoDB Community Operator (MCO) to MongoDB Kubernetes Operator (MCK)
3+
4+
This guide walks you through the complete process of migrating from the MongoDB Community Operator (MCO) to the MongoDB Kubernetes Operator (MCK). It ensures CRDs are preserved, services remain uninterrupted, and reconciliation is correctly handed over.
5+
This guide ensures the CRDs are retained using Helm's keep annotation and transitions smoothly to MCK. We have a codified guide as well - [Link](https://github.com/mongodb/mongodb-kubernetes/blob/f0050b8942545701e8cb9e42d54d14f0cb58ee6a/mongodb-community-operator/test/e2e/replica_set_operator_upgrade/replica_set_operator_upgrade_test.go#L28).
6+
7+
---
8+
9+
## 📋 Prerequisites
10+
11+
- Kubernetes cluster access with admin permissions.
12+
- Helm installed and configured.
13+
- Upgrade your MCO Helm chart to at least version `0.13.0` before proceeding, as this version introduced the critical CRD keep annotations (`"helm.sh/resource-policy": keep`).
14+
15+
---
16+
17+
## 🚀 Migration Steps
18+
19+
### 1. Upgrade to the Latest MCO Chart
20+
21+
```bash
22+
helm repo add mongodb https://mongodb.github.io/helm-charts
23+
helm repo update
24+
helm upgrade --install mongodb-community-operator mongodb/community-operator
25+
```
26+
27+
✅ Verify that Community CRD have the keep annotation:
28+
29+
```bash
30+
kubectl get crds | grep mongodb
31+
kubectl get crd mongodbcommunity.mongodbcommunity.mongodb.com -o yaml | grep 'helm.sh/resource-policy'
32+
```
33+
34+
You should see:
35+
```yaml
36+
helm.sh/resource-policy: keep
37+
```
38+
39+
---
40+
41+
### 2. Environment Variables
42+
**Note:** If you're using Helm (as recommended in this guide), these environment variables will be automatically set through the `values.yaml` configuration described in step 3. Manual environment variable updates are only needed for non-Helm deployments.
43+
44+
The MongoDB Kubernetes Operator (MCK) uses different environment variables than the MongoDB Community Operator (MCO):
45+
46+
| MCO Variable | MCK Variable |
47+
|----------------------------|----------------------------------|
48+
| `MONGODB_REPO_URL` | `MDB_COMMUNITY_REPO_URL` |
49+
| `MDB_IMAGE_TYPE` | `MDB_COMMUNITY_IMAGE_TYPE` |
50+
| `MONGODB_IMAGE` | `MDB_COMMUNITY_IMAGE` |
51+
| `AGENT_IMAGE` | `MDB_COMMUNITY_AGENT_IMAGE` |
52+
53+
54+
---
55+
56+
### 3. Update community specific Helm Settings
57+
58+
All of the above environment variables can be configured in the values.yaml file.
59+
They are all namespaced under `community`.
60+
61+
---
62+
63+
### 4. Scale Down the MCO Operator Deployment
64+
65+
To prevent a split-brain between the MCO and MCK operator we scale down the MCO deployment:
66+
67+
```bash
68+
kubectl scale deployment mongodb-community-operator --replicas=0
69+
```
70+
71+
---
72+
73+
### 5. Install the MCK Operator
74+
75+
Deploy the new MCK Helm release with your updated values:
76+
77+
```bash
78+
helm install mongodb-kubernetes-operator mongodb/enterprise-operator -f values.yaml
79+
```
80+
81+
⚠️ Warning: Ensure the MCK chart is installed with a different release name than the prior community operator chart. By default, the new MCK chart uses a different `operator.name`, which differs from the community operator.
82+
If you've modified the community operator's name/release name, ensure the MCK's `operator.name` value is different
83+
to avoid RBAC conflicts, since service accounts, roles, and other resources are based on this name.
84+
85+
---
86+
87+
### 6. Let MCK Reconcile the Existing Resources
88+
89+
After installation:
90+
91+
- MCK will take control of existing MongoDB CRs.
92+
- It will apply updated container images, RBAC settings, and other resources.
93+
- A rolling restart will occur as service account names are updated among other things (e.g. to `mongodb-kubernetes-appdb`).
94+
95+
---
96+
97+
### 7. Wait for All Resources to Become Healthy
98+
99+
Monitor the cluster:
100+
101+
```bash
102+
kubectl get pods
103+
kubectl get mdbc -A
104+
```
105+
106+
Wait until:
107+
108+
- All pods are running
109+
- All MongoDB resources are reconciled
110+
- No errors are shown in the MCK operator logs
111+
112+
---
113+
114+
### 8. Uninstall the MCO Chart
115+
116+
Once MCK has taken over, remove the MCO chart:
117+
118+
```bash
119+
helm uninstall mongodb-community-operator
120+
```
121+
122+
- Helm will retain the CRDs due to the `keep` annotation
123+
- Old RBAC resources will be removed, but are no longer needed since we've installed new ones to use
124+
125+
---
126+
127+
## ✅ Final Verification
128+
129+
1. Check CRDs still exist after uninstalling the MCO chart:
130+
131+
```bash
132+
kubectl get crds | grep mongodb
133+
```
134+
135+
2. Ensure MCK logs show successful reconciliation.
136+
137+
---
138+
139+
## 💬 Support
140+
141+
For questions or issues during the migration, refer to the [official MCK repository](https://github.com/mongodb/mongodb-kubernetes) or contact your support representative.

0 commit comments

Comments
 (0)