Helm Charts Quick Start
On this page
You can use Atlas Kubernetes Operator to manage resources in Atlas without leaving Kubernetes. This tutorial demonstrates how to create your first cluster in Atlas from Helm Charts with Atlas Kubernetes Operator.
Prerequisites
This tutorial requires:
- A running Kubernetes cluster
You can access the Atlas Kubernetes Operator project on GitHub:
Procedure
Register for an Atlas account or log in.
Register a new Atlas Account or Login to Your Atlas Account.
Create API keys for your organization.
You need the following public API key, private API key, and the organization ID information to configure Atlas Kubernetes Operator access to Atlas.
Create an API Key in an Organization and configure the API Access List.
You need the following public API key, private API key, and the organization ID information to configure Atlas Kubernetes Operator access to Atlas.
If you want Atlas Kubernetes Operator to create a new Atlas project, Create an API Key in an Organization and configure the API Access List.
ImportantYou must assign the API key the Organization Project Creator organization role or higher.
If you want to work with an existing Atlas project, Create an API Key for a Project and configure the API Access List.
ImportantYou must assign the API key the Project Owner project role.
Deploy Atlas Kubernetes Operator.
Run one of the following sets of commands:
If you want Atlas Kubernetes Operator to watch all namespaces in the Kubernetes cluster, run the following commands:
helm repo add mongodb https://mongodb.github.io/helm-charts helm install atlas-operator --namespace=atlas-operator --create-namespace mongodb/mongodb-atlas-operator If you want Atlas Kubernetes Operator to watch only its own namespace, set the
--watchNamespaces
flag to its own namespace, and run the following command:Notehelm install atlas-operator --namespace=atlas-operator --set watchNamespaces=atlas-operator --create-namespace mongodb/mongodb-atlas-operator
Deploy the Atlas cluster.
The --set
flags in the following example override the
Values.yaml
file values with your Atlas project name,
organization ID, and API keys.
mongodb/atlas-cluster
references the name of a chart in the
repository.
Run the following command:
helm install atlas-cluster \ mongodb/atlas-cluster \ --namespace=my-cluster \ --create-namespace \ --set project.atlasProjectName='My Project' \ --set atlas.orgId='<orgid>' \ --set atlas.publicApiKey='<publicKey>' \ --set atlas.privateApiKey='<privateApiKey>'
Alternatively, you can clone the helm-charts project on GitHub, edit
the Values.yaml
file directly, and add your local directory with
the following command:
helm repo add mongodb <your-updated-helm-charts-directory>
To learn more about the available parameters, see
AtlasCluster
Custom Resource.
Check the status of your database user.
Run the following command until you recieve a True
response,
which indicates the database user is ready:
The AtlasDatabaseUser
Custom Resource waits until the
cluster is ready. Creating a new cluster can take up to 10 minutes.
kubectl get atlasdatabaseusers atlas-cluster-admin-user -o=jsonpath='{.status.conditions[?(@.type=="Ready")].status}'
Retrieve the secret that Atlas Kubernetes Operator created to connect to the cluster.
Run the following command:
The following command requires jq
1.6 or higher.
kubectl get secret my-project-atlas-atlas-cluster-admin-user -o json | jq -r '.data | with_entries(.value |= @base64d)';
Your connection strings will differ from the following example.
{ "connectionStringStandard": "mongodb://admin-user:%25SomeLong%25password$foradmin@atlas-cluster-shard-00-00.nlrvs.mongodb.net:27017,atlas-cluster-shard-00-01.nlrvs.mongodb.net:27017,atlas-cluster-shard-00-02.nlrvs.mongodb.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-11q9bn-shard-0", "connectionStringStandardSrv": "mongodb+srv://admin-user:%25SomeLong%25password$foradmin@atlas-cluster.nlrvs.mongodb.net", "password": "%SomeLong%password$foradmin", "username": "admin-user" }
You can use this secret in your application:
containers: - name: test-app env: - name: "CONNECTION_STRING" valueFrom: secretKeyRef: name: my-project-atlas-atlas-cluster-admin-user key: connectionStringStandardSrv