|
| 1 | +.. _ak8so-independent-crd: |
| 2 | + |
| 3 | +======================================= |
| 4 | +Independent Custom Resource Definitions |
| 5 | +======================================= |
| 6 | + |
| 7 | +.. default-domain:: mongodb |
| 8 | + |
| 9 | +.. contents:: On this page |
| 10 | + :local: |
| 11 | + :backlinks: none |
| 12 | + :depth: 1 |
| 13 | + :class: singlecol |
| 14 | + |
| 15 | +You can use |ak8so| to manage resources in an |service| project |
| 16 | +without using |ak8so| to manage the project itself. In this |
| 17 | +independent custom resource definition ("independent CRD") model, you |
| 18 | +associate resources such as :ref:`atlasdeployment-custom-resource` and |
| 19 | +:ref:`atlasdatabaseuser-custom-resource` with an |service| project |
| 20 | +directly by its |service| :atlas:`ID <project-id>`. |
| 21 | + |
| 22 | +Independent CRDs allow you to use different programmatic |
| 23 | +infrastructure management systems for your projects, while you use |
| 24 | +|ak8so| to manage more frequently-altered resources such as database |
| 25 | +users or individual deployments. |
| 26 | + |
| 27 | +By separating the management of the |service| project from the |
| 28 | +management of subresources such as users and deployments, independent |
| 29 | +CRDs allow you to allocate these responsibilities to different |
| 30 | +personnel or different teams within your organization as suits your |
| 31 | +needs. |
| 32 | + |
| 33 | +.. _ak8so-independent-crd-considerations: |
| 34 | + |
| 35 | +Considerations |
| 36 | +-------------- |
| 37 | + |
| 38 | +When you use |ak8so| to manage a project, you can either configure |
| 39 | +{+atlas-admin-api+} authentication using the |
| 40 | +``spec.connectionSecretRef.name`` parameter of the ``atlasProject`` |
| 41 | +resource, or leave this parameter unset to default to global |service| |
| 42 | +:ref:`credentials <ak8so-secrets>`. When using independent CRDs, you |
| 43 | +can specify a ``spec.connectionSecret.name`` for each resource. This |
| 44 | +parameter, if set, takes precedence over |
| 45 | +``spec.connectionSecretRef.name`` or global |service| |
| 46 | +credentials. |
| 47 | + |
| 48 | +Setting this parameter is required for any resource whose parent |
| 49 | +resource is referenced using an |service| :atlas:`project ID |
| 50 | +<project-id>`, and optional otherwise. |
| 51 | + |
| 52 | +.. example:: |
| 53 | + |
| 54 | + You define an ``atlasDeployment`` CRD that references its parent |
| 55 | + project by |service| ID instead of an ``atlasProject`` |
| 56 | + ``spec.name`` parameter. You must define a |
| 57 | + ``spec.connectSecret.name`` for the ``atlasDeployment`` |
| 58 | + resource, as in the following: |
| 59 | + |
| 60 | + .. code-block:: |
| 61 | + |
| 62 | + apiVersion: atlas.mongodb.com/v1 |
| 63 | + kind: AtlasDeployment |
| 64 | + metadata: |
| 65 | + name: test-cluster-name |
| 66 | + namespace: mongodb-atlas-system |
| 67 | + spec: |
| 68 | + externalProjectRef: |
| 69 | + id: 671998971c8520583f24f411 |
| 70 | + connectionSecret: |
| 71 | + name: my-atlas-key |
| 72 | + deploymentSpec: |
| 73 | + clusterType: REPLICASET |
| 74 | + name: service-name |
| 75 | + tags: |
| 76 | + - key: "environment" |
| 77 | + value: "production" |
| 78 | + backupEnabled: true |
| 79 | + replicationSpecs: |
| 80 | + - zoneName: US-Zone |
| 81 | + numShards: 3 |
| 82 | + regionConfigs: |
| 83 | + - regionName: CENTRAL_US |
| 84 | + providerName: GCP |
| 85 | + backingProviderName: GCP |
| 86 | + priority: 7 |
| 87 | + electableSpecs: |
| 88 | + instanceSize: M10 |
| 89 | + nodeCount: 3 |
| 90 | + |
| 91 | +.. _ak8so-independent-crd-migrate: |
| 92 | + |
| 93 | +Migration to Independent CRD |
| 94 | +---------------------------- |
| 95 | + |
| 96 | +To migrate existing CRDs from ``atlasProject``-level management to |
| 97 | +independent management: |
| 98 | + |
| 99 | +.. procedure:: |
| 100 | + :style: normal |
| 101 | + |
| 102 | + .. step:: Disable project reconciliation and edit subresource |
| 103 | + references |
| 104 | + |
| 105 | + 1. Add the ``mongodb.com/atlas-reconciliation-policy: "skip"`` |
| 106 | + annotation to the parent resource's ``metadata``. This |
| 107 | + prevents |ak8so| from attempting to reconcile the parent |
| 108 | + resource and its subresources. Consider the following: |
| 109 | + |
| 110 | + .. code-block:: |
| 111 | + :emphasize-lines: 5-6 |
| 112 | + |
| 113 | + apiVersion: atlas.mongodb.com/v1 |
| 114 | + kind: AtlasProject |
| 115 | + metadata: |
| 116 | + name: my-project |
| 117 | + annotations: |
| 118 | + mongodb.com/atlas-reconciliation-policy: "skip" |
| 119 | + spec: |
| 120 | + name: Test project |
| 121 | + connectionSecretRef: |
| 122 | + name: my-atlas-key |
| 123 | + projectIpAccessList: |
| 124 | + - cidrBlock: "203.0.113.0/24" |
| 125 | + comment: "CIDR block for Application Server B - D" |
| 126 | + |
| 127 | + .. warning:: |
| 128 | + |
| 129 | + If you do not apply this annotation, |ak8so| will continue |
| 130 | + to attempt reconciliation as you modify your other |
| 131 | + resources. For users with :ref:`<deletion-protection>` |
| 132 | + disabled, this can result in |ak8so| removing the |
| 133 | + |service| project when you remove the ``atlasProject`` |
| 134 | + resource, or entering a blocked state attempting to remove |
| 135 | + a project with active subresources such as database users |
| 136 | + or deployments. |
| 137 | + |
| 138 | + #. Modify the project reference to point to an |service| |
| 139 | + :atlas:`project ID <project-id>` instead of an |
| 140 | + ``atlasProject`` name. |
| 141 | + |
| 142 | + For example, to decouple an ``atlasDatabaseUser`` resource: |
| 143 | + |
| 144 | + .. code-block:: |
| 145 | + :emphasize-lines: 9-10 |
| 146 | + |
| 147 | + apiVersion: atlas.mongodb.com/v1 |
| 148 | + kind: AtlasDatabaseUser |
| 149 | + metadata: |
| 150 | + name: my-database-user |
| 151 | + spec: |
| 152 | + roles: |
| 153 | + - roleName: readWriteAnyDatabase |
| 154 | + databaseName: admin |
| 155 | + externalProjectRef: |
| 156 | + id: 671998971c8520583f24f411 |
| 157 | + username: theuser |
| 158 | + passwordSecretRef: |
| 159 | + name: the-user-password |
| 160 | + |
| 161 | + .. step:: Wait for |ak8so| to sync the new resource status. |
| 162 | + |
| 163 | + .. step:: (Conditional) Remove the ``atlasProject`` CRD. |
| 164 | + |
| 165 | + To stop managing your project with |ak8so|, you can now remove |
| 166 | + the ``atlasProject`` CRD. To continue managing your project and |
| 167 | + attached subresources with |ak8so|, skip to the next step. |
| 168 | + |
| 169 | + .. step:: (Conditional) Remove the reconciliation policy annotation |
| 170 | + |
| 171 | + If you want to continue managing your project with |ak8so|, as in |
| 172 | + a scenario where you still have resources subordinate to your |
| 173 | + ``atlasProject``, reactivate reconciliation by removing the |
| 174 | + reconciliation policy annotation from the ``atlasProject`` CRD. |
0 commit comments