> For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt

<!--
Tab options on this page. Append to the .md URL to filter:
  ?tabs=<id,...>   select specific tabs (e.g. ?tabs=nodejs,shell)
  ?allTabs=true    include every tab
  (no param)       default: one tab per tabset

Available tabs:
  other tabs: generate-params, apply-params, generate-example, apply-example
-->

# Import Atlas Projects into Atlas Kubernetes Operator

Atlas Kubernetes Operator doesn't support Atlas Infinite Database clusters in public preview. To learn which features Atlas Infinite Database supports in public preview, see [Atlas Infinite Database Edition](https://www.mongodb.com/docs/atlas/infinite/atlas-infinite-landing/). To learn more about preview features, see [Preview Features](https://www.mongodb.com/docs/preview-features/).

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 (Yet Another Markup Lanugage)-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:

- An [`AtlasDeployment` Custom Resource](https://www.mongodb.com/docs/atlas/operator/current/atlasdeployment-custom-resource.md#std-label-atlasdeployment-custom-resource)

- An [`AtlasBackupSchedule` Custom Resource](https://www.mongodb.com/docs/atlas/operator/current/atlasbackupschedule-custom-resource.md#std-label-atlasbackupschedule-custom-resource)

- An [`AtlasBackupPolicy` Custom Resource](https://www.mongodb.com/docs/atlas/operator/current/atlasbackuppolicy-custom-resource.md#std-label-atlasbackuppolicy-custom-resource)

- An [`AtlasProject` Custom Resource](https://www.mongodb.com/docs/atlas/operator/current/atlasproject-custom-resource.md#std-label-atlasproject-custom-resource)

- An [`AtlasDatabaseUser` Custom Resource](https://www.mongodb.com/docs/atlas/operator/current/atlasdatabaseuser-custom-resource.md#std-label-atlasdatabaseuser-custom-resource)

- An [`AtlasTeam` Custom Resource](https://www.mongodb.com/docs/atlas/operator/current/atlasteam-custom-resource.md#std-label-atlasteam-custom-resource)

### Parameters

### Config Generate

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

## 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`.

### Config Generate

To export the entire project, including all Atlas deployments and secrets with credentials, run the following command:

```sh
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:

```sh
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:

```sh
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`.

```sh
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.

```sh
kubectl apply -f myAtlasProject.yaml
```
