Import Atlas Projects into Atlas Kubernetes Operator
On this page
If you have existing Kubernetes deployments and wish to start using Atlas Kubernetes Operator,
you can use the Atlas CLI atlas kubernetes config generate
or
atlas kubernetes config apply
commands to export Atlas
projects, deployments, and database users.
Both commands allow you to export your configuration in an
Atlas Kubernetes Operator-compatible format for use in the Kubernetes or Openshift cluster on
which Atlas Kubernetes Operator runs. The atlas kubernetes config generate
command
achieves this by outputting a
YAML-formatted configuration to
your terminal's stdout
, while the atlas kubernetes config apply
command stores the configuration in memory and sends it directly to a
target Kubernetes cluster.
Overview
Both commands generate a .yaml
-formatted configuration
which includes the following Atlas Kubernetes Operator resources:
Parameters
The command takes the following parameters:
Parameter | Description | Necessity |
---|---|---|
--projectId | Unique 24-digit hexadecimal string that identifies your
project. If omitted, defaults to the projectId value in
your atlascli configuration file. | Required. |
--clusterName | A comma-separated list of human-readable labels that
identify the clusters to export. These must be clusters in
the project specified in the projectId parameter. If
omitted, the command exports all clusters in the specified
project. | Optional. |
--includeSecrets | Flag that populates an entry in the configuration file for an Atlas
credentials secret. If omitted, the
command creates a secret, but doesn't populate it with data.
The secret is rendered as plain text. | Optional. |
--targetNamespace | Kubernetes namespace to export the resources to. The command
fills the metadata.namespace field of each exported Atlas
entity with the value of this parameter. | Required. |
--operatorVersion | Version of Atlas Kubernetes Operator for which to export your files. If
omitted, the command exports files compatible with Atlas Kubernetes Operator
v1.5.1. | Optional. |
The command takes the following parameters:
Parameter | Description | Necessity |
---|---|---|
--projectId | Unique 24-digit hexadecimal string that identifies your
project. If omitted, defaults to the projectId value in
your atlascli configuration file. | Required. |
--orgId | Unique 24-digit hexadecimal string that identifies the
Atlas organization to register the project with. If
omitted, defaults to the orgId value in your
atlascli configuration file or your ORGID
environment variable. | Optional. |
--clusterName | A comma-separated list of human-readable labels that
identify clusters to export. These must be clusters in the
project specified in the projectId parameter. If
omitted, the command exports all clusters in the specified
project. | Optional. |
--targetNamespace | Kubernetes namespace to export the resources to. The command
fills the metadata.namespace field of each exported Atlas
entity with the value of this parameter. | Required. |
--operatorVersion | Version of Atlas Kubernetes Operator for which to export your files. If
omitted, the command exports files compatible with Atlas Kubernetes Operator
v1.5.1. | Optional. |
--kubeContext | Kubeconfig context to use for connecting to the cluster. | Required |
--kubeconfig | Path to your kubeconfig file. | Required |
Compatibility
atlascli
exports configurations from Atlas in a format that is
version-dependent on Atlas Kubernetes Operator. The following table describes which
versions of atlascli
support which versions of Atlas Kubernetes Operator:
atlascli version | Atlas Kubernetes Operator versions |
---|---|
1.4.0 | 1.5.0 |
Examples
The following examples assume a project named sampleProject
,
with clusters named sample1
, sample2
, and sample3
, a
Project ID of 63500d1139dd494b92fe4376
, and a target namespace of
sampleNamespace
.
To export the entire project, including all Atlas deployments and secrets with credentials, run the following command:
atlas kubernetes config generate --projectId=63500d1139dd494b92fe4376 \ --includeSecrets --targetNamespace=sampleNamespace
To export two specific Atlas deployments from the project without secret credentials, run the following command:
atlas kubernetes config generate --projectId=63500d1139dd494b92fe4376 \ --clusterName=sample1,sample2 --targetNamespace=sampleNamespace
In the preceding command examples, you can apply the generated
configuration to your Kubernetes or Openshift cluster by piping
the output into the kubectl apply
command. The following
command example illustrates this:
atlas kubernetes config generate --projectId=63500d1139dd494b92fe4376 \ --clusterName=sample1,sample2 --targetNamespace=sampleNamespace \ | kubectl apply -f -
Alternatively, you can save the generated configuration by
redirecting stdout
to a .yaml
file. The following command
imports a single Atlas deployment from the project without
secret credentials and saves the output to
myAtlasProject.yaml
.
atlas kubernetes config generate --projectId=63500d1139dd494b92fe4376 \ --clusterName=sample3 --targetNamespace=sampleNamespace \ myAtlasProject.yaml
Applying the Configuration
To apply the generated configuration to your Kubernetes or Openshift
cluster in this scenario, pass the .yaml
file as an argument to
the kubectl apply
command.
kubectl apply -f myAtlasProject.yaml
To export the entire project, run the following command:
atlas kubernetes config apply --projectId=63500d1139dd494b92fe4376 \ --targetNamespace=sampleNamespace
To export two specific Atlas deployments from the project, run the following command:
atlas kubernetes config apply --projectId=63500d1139dd494b92fe4376 \ --clusterName=sample1,sample2 --targetNamespace=sampleNamespace In contrast to ``atlas kubernetes config generate``, this command directly applies the generated configuration without any further manual operation on your part.