Quantcast
Channel: MongoDB | Blog
Viewing all articles
Browse latest Browse all 2423

Introducing: Atlas Operator for Kubernetes

$
0
0

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.

  1. 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.

  2. Deploy the Atlas Operator

kubectl apply -f \
https://raw.githubusercontent.com/mongodb/mongodb-atlas-kubernetes/main/deploy/all-in-one.yaml

  1. 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 \&NewLine;  --from-literal="orgId=<the_atlas_organization_id>" \&NewLine;  --from-literal="publicApiKey=<the_atlas_api_public_key>" \&NewLine;  --from-literal="privateApiKey=<the_atlas_api_private_key>" \&NewLine;  -n mongodb-atlas-system&NewLine;
  1. Create AtlasProject Custom Resource:
cat <<EOF | kubectl apply -f -  &NewLine;apiVersion: atlas.mongodb.com/v1  &NewLine;kind: AtlasProject  &NewLine;metadata:  &NewLine;  name: my-project  &NewLine;spec:  &NewLine;  name: Test Atlas Operator Project  &NewLine;  projectIpAccessList:  &NewLine;  - ipAddress: "0.0.0.0/0"  &NewLine;    comment: "Allowing access to database from everywhere (only for Demo!)"  &NewLine;EOF&NewLine;
  1. Create AtlasCluster Custom Resource
cat <<EOF | kubectl apply -f -&NewLine;apiVersion: atlas.mongodb.com/v1&NewLine;kind: AtlasCluster&NewLine;metadata:&NewLine;  name: my-atlas-cluster&NewLine;spec:&NewLine;  name: "Test-cluster"&NewLine;  projectRef:&NewLine;    name: my-project&NewLine;  providerSettings:&NewLine;    instanceSizeName: M10&NewLine;    providerName: AWS&NewLine;    regionName: US_EAST_1&NewLine;EOF&NewLine;

(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}'  &NewLine;&NewLine;True&NewLine;
  1. Create a Secret for the password that will be used to log into Atlas Cluster Database
kubectl create secret generic the-user-password \&NewLine;--from-literal="password=P@@sword%"&NewLine;
  1. Create AtlasDatabaseUser Custom Resource (references the password Secret)
cat <<EOF | kubectl apply -f -  &NewLine;apiVersion: atlas.mongodb.com/v1&NewLine;kind: AtlasDatabaseUser&NewLine;metadata:&NewLine;  name: my-database-user&NewLine;spec:&NewLine;  roles:&NewLine;    - roleName: "readWriteAnyDatabase"&NewLine;      databaseName: "admin"&NewLine;  projectRef:&NewLine;    name: my-project&NewLine;  username: theuser&NewLine;  passwordSecretRef:&NewLine;    name: the-user-password  &NewLine;EOF&NewLine;
  1. 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 \&NewLine;-o=jsonpath="{.data.connectionString.standardSrv}} | base64 -d  &NewLine;&NewLine;mongodb+srv://theuser:P%40%40sword%25@test-cluster.peqtm.mongodb.net&NewLine;

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.


Viewing all articles
Browse latest Browse all 2423

Trending Articles