Introducing: Atlas Operator for Kubernetes
The
MongoDB Enterprise Operator
serves to automate and manage MongoDB clusters on self-managed infrastructure. While this integration has provided complete control over self-managed MongoDB deployments from a single Kubernetes control plane, we’re taking it a step further by extending this functionality to our fully-managed database—MongoDB Atlas. We’re excited to introduce the trial version of the Atlas Operator for Kubernetes.
The Atlas Operator will allow you to manage all your
MongoDB Atlas
clusters without ever having to leave Kubernetes. Keep your workflow as seamless and optimized as possible by managing the lifecycle of your cloud-native applications from where you want most. With the trial version of this Atlas Operator, you can provision and deploy fully-managed MongoDB Atlas clusters on the cloud provider of your choice through Kubernetes.
This provider is especially important for those seeking to unlock the power of multi-cloud with unique tools and services native to AWS, Google Cloud, and Azure without any added complexity to the data management experience. With this new Atlas Operator, you get the best of all clouds with
multi-cloud clusters on Atlas
, coupled with the freedom to run your entire stack anywhere, all while managed in one central location.
The “trial version” simply means it has all the core functionality to provision fully-managed Atlas clusters, but the bells and whistles are yet to come. In addition to encapsulating core Atlas functionality, it ensures Kubernetes Secrets are created for each database user which allows for easier management of sensitive data. The Atlas Operator also allows you to create IP Bindings so your applications can securely access clusters.
If you’re interested in using the trial version of the Atlas Operator today, follow our quickstart guide below to get started!
Quickstart
Below you’ll find the steps to create your first cluster in Atlas using the Atlas Operator. Note that you need to have a running Kubernetes cluster before deploying the Atlas Operator.
Register/Login to Atlas
and
create API Keys
for your Organization. This information together with the Organization ID will be used to configure the Atlas Operator access to Atlas.
Deploy the Atlas Operator
kubectl apply -f \
https://raw.githubusercontent.com/mongodb/mongodb-atlas-kubernetes/main/deploy/all-in-one.yaml
Create a Secret containing connection information from step one. This Secret will be used by the Atlas Operator to connect to Atlas:
kubectl create secret generic mongodb-atlas-operator-api-key \
--from-literal="orgId=<the_atlas_organization_id>" \
--from-literal="publicApiKey=<the_atlas_api_public_key>" \
--from-literal="privateApiKey=<the_atlas_api_private_key>" \
-n mongodb-atlas-system
Create AtlasProject Custom Resource:
cat <<EOF | kubectl apply -f -
apiVersion: atlas.mongodb.com/v1
kind: AtlasProject
metadata:
name: my-project
spec:
name: Test Atlas Operator Project
projectIpAccessList:
- ipAddress: "0.0.0.0/0"
comment: "Allowing access to database from everywhere (only for Demo!)"
EOF
Create AtlasCluster Custom Resource
cat <<EOF | kubectl apply -f -
apiVersion: atlas.mongodb.com/v1
kind: AtlasCluster
metadata:
name: my-atlas-cluster
spec:
name: "Test-cluster"
projectRef:
name: my-project
providerSettings:
instanceSizeName: M10
providerName: AWS
regionName: US_EAST_1
EOF
(You'll have to wait until the cluster is ready - "status" field shows "ready:true":)
kubectl get atlasclusters my-atlas-cluster -o=jsonpath='{.status.conditions[?(@.type=="Ready")].status}'
True
Create a Secret for the password that will be used to log into Atlas Cluster Database
kubectl create secret generic the-user-password \
--from-literal="password=P@@sword%"
Create AtlasDatabaseUser Custom Resource (references the password Secret)
cat <<EOF | kubectl apply -f -
apiVersion: atlas.mongodb.com/v1
kind: AtlasDatabaseUser
metadata:
name: my-database-user
spec:
roles:
- roleName: "readWriteAnyDatabase"
databaseName: "admin"
projectRef:
name: my-project
username: theuser
passwordSecretRef:
name: the-user-password
EOF
Shortly the Secret will be created by the Atlas Operator containing the data necessary to connect to the Atlas Cluster. You can mount it into your application Pod and read the connection strings from the file or from the environment variable.
kubectl get secrets/test-atlas-operator-project-test-cluster-theuser \
-o=jsonpath="{.data.connectionString.standardSrv}} | base64 -d
mongodb+srv://theuser:P%40%40sword%25@test-cluster.peqtm.mongodb.net
Stay Tuned for More
Be on the lookout for updates in future blog posts! The trial version of the
MongoDB Atlas Operator
is currently available on multiple marketplaces, but we’ll be looking to make enhancements in the near future. For more information, check out our MongoDB Atlas & Kubernetes
GitHub page
and our
documentation
.
April 8, 2021