> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ankra.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Clone Stacks Between Clusters & Organisations

> Learn how to clone one or multiple stacks from one cluster to another - including across organisations - for consistent deployments across environments

<Note>
  Cloning stacks allows you to replicate your infrastructure configurations across multiple clusters - even across different organisations. You can clone a single stack or select multiple stacks at once. Cloned stacks are created as drafts, giving you the opportunity to review and customize them before deployment.
</Note>

<Frame caption="Cloning a Stack Between Clusters">
  <video controls autoPlay muted loop playsInline className="w-full aspect-video rounded-xl" src="https://fsn1.your-objectstorage.com/ankra-vod/docs/clone-stack.mp4" />
</Frame>

<Card title="AI Prompts" icon="wand-magic-sparkles" href="#ai-prompts">
  Use these prompts with the AI Assistant (`Cmd+J`) to clone stacks with natural language.
</Card>

***

## Overview

Stack cloning is useful when you want to:

| Use Case                      | Example                                                            |
| ----------------------------- | ------------------------------------------------------------------ |
| **Promote configurations**    | Clone a tested stack from staging to production                    |
| **Standardize environments**  | Replicate your monitoring stack across all clusters                |
| **Create templates**          | Use a well-configured stack as a starting point for new clusters   |
| **Disaster recovery**         | Quickly replicate infrastructure to a backup cluster               |
| **Cross-org sharing**         | Clone a stack from a development org to a client or production org |
| **Replicate entire clusters** | Select all stacks and clone them to a new cluster in one operation |

<Warning>
  **Security Note:** Encrypted values (secrets) are not transferred during cloning for security reasons. You'll need to reconfigure them in the target cluster. This includes passwords, API keys, and any values encrypted with SOPS.
</Warning>

***

## Prerequisites

* At least two clusters imported into Ankra (can be in different organisations)
* A deployed stack in the source cluster that you want to clone
* Access to both the source and target clusters
* For cross-org cloning: membership in both the source and target organisations

***

## Clone Using the Dashboard

<Steps>
  <Step title="Navigate to Source Stack">
    Go to your source cluster and navigate to **Stacks**. Find the stack you want to clone.
  </Step>

  <Step title="Open Clone Dialog">
    Click the menu icon (three dots) on the stack card and select **Clone to Cluster**.
  </Step>

  <Step title="Select Target Cluster">
    In the dialog that appears:

    1. If you belong to multiple organisations, select the **target organisation** from the dropdown. The cluster list updates to show clusters in that organisation.
    2. Choose the **destination cluster** from the cluster dropdown
    3. Optionally modify the stack name
    4. Choose whether to include addon configurations
  </Step>

  <Step title="Review Warnings">
    If your stack contains encrypted values, you'll see a warning. These values will need to be reconfigured after cloning.

    For **cross-organisation** clones, an additional banner explains that you'll be switched to the target organisation after cloning. Credentials and secrets may need to be reconfigured for the new organisation context.
  </Step>

  <Step title="Clone the Stack">
    Click **Clone Stack**. You'll be redirected to the draft in the target cluster. If you cloned to a different organisation, Ankra automatically switches your active organisation.
  </Step>

  <Step title="Configure and Deploy">
    In the target cluster:

    1. Review the cloned configuration
    2. Add any missing secrets or encrypted values
    3. Adjust cluster-specific settings if needed
    4. Click **Deploy** when ready
  </Step>
</Steps>

***

## Clone Multiple Stacks at Once

You can select multiple stacks and clone them all to another cluster in a single operation. Each stack is created as a separate draft on the target cluster.

<Steps>
  <Step title="Select Stacks">
    On the **Stacks** page, click any stack card's avatar (the colored circle) to start selecting. Click additional avatars to add more stacks to your selection.

    Alternatively, click the **Clone Stacks** button to the left of the search bar - this selects all stacks on the page.
  </Step>

  <Step title="Open the Clone Dialog">
    With stacks selected, a floating action bar appears at the bottom of the screen showing the count. Click **Clone to Cluster** in the bar, or click the **Clone N Stacks** button next to the search bar.
  </Step>

  <Step title="Choose a Target">
    In the dialog:

    1. Select the **target organisation** (if you belong to multiple)
    2. Choose the **destination cluster**
    3. Toggle whether to include addon configurations

    The dialog shows a list of all selected stacks as tags.
  </Step>

  <Step title="Clone">
    Click **Clone N Stacks**. Each stack is cloned sequentially - you'll see a progress bar and each stack tag turns green on success. Name conflicts are auto-resolved with suffixes (e.g. `-copy`).
  </Step>

  <Step title="Navigate to Target">
    After completion, click **Go to Target Cluster** to review the cloned drafts. Configure any missing secrets and deploy when ready.
  </Step>
</Steps>

<Tip>
  Multi-stack cloning is useful for replicating an entire cluster's configuration. Select all stacks, clone to a new cluster, then review and deploy each draft individually.
</Tip>

***

## Clone Using the CLI

The Ankra CLI provides a `clone` command for scripting and automation.

### Basic Usage

```bash theme={null}
# Select the source cluster first
ankra cluster select my-source-cluster

# Clone a stack to another cluster
ankra cluster stacks clone monitoring-stack --to production-cluster
```

### Command Options

| Flag               | Short | Description                                            |
| ------------------ | ----- | ------------------------------------------------------ |
| `--to`             | `-t`  | Target cluster name or ID (required)                   |
| `--name`           | `-n`  | Custom name for the cloned stack                       |
| `--org`            |       | Target organisation name or ID (for cross-org cloning) |
| `--include-config` |       | Include addon configurations (default: true)           |

### Examples

**Clone with a custom name:**

```bash theme={null}
ankra cluster stacks clone my-stack --to production --name my-stack-prod
```

**Clone to a cluster in another organisation:**

```bash theme={null}
ankra cluster stacks clone my-stack --to client-cluster --org client-org
```

**Clone without addon configurations:**

```bash theme={null}
ankra cluster stacks clone my-stack --to production --include-config=false
```

**Clone using cluster IDs:**

```bash theme={null}
ankra cluster stacks clone monitoring-stack --to 550e8400-e29b-41d4-a716-446655440000
```

### CLI Output

```
Cloning stack 'monitoring-stack' to cluster 'production'...

Stack cloned successfully!
  Draft ID:    a1b2c3d4-e5f6-7890-abcd-ef1234567890
  Stack Name:  monitoring-stack
  Addons:      3
  Manifests:   2

Warnings:
  - Addon 'grafana' had encrypted configuration that needs to be reconfigured.

The stack has been created as a draft. Open the Ankra dashboard to review and deploy.
```

***

## What Gets Cloned

| Component                |  Cloned  | Notes                                   |
| ------------------------ | :------: | --------------------------------------- |
| Stack name & description |    Yes   | Can be renamed during clone             |
| Stack variables          |    Yes   | Transferred as-is                       |
| Manifests                |    Yes   | YAML content (encrypted values cleared) |
| Addons                   |    Yes   | Chart references and versions           |
| Addon configurations     | Optional | Use `--include-config` flag             |
| Encrypted secrets        |    No    | Must be reconfigured                    |
| Deployment state         |    No    | Created as draft                        |
| Resource positions       |    No    | Auto-layouted in target                 |
| Dependencies             |    Yes   | Parent relationships preserved by name  |

***

## Cloning Between Organisations

Ankra supports cloning stacks to clusters that belong to a different organisation. This is useful for sharing configurations with clients, replicating setups from a template org to a production org, or migrating workloads.

### How it works

1. You must be a **member of both** the source and target organisations.
2. In the clone dialog, an **Organisation** dropdown appears when you belong to more than one org. Select the target organisation to see its clusters.
3. With the CLI, pass the `--org` flag to specify the target organisation.
4. After a cross-org clone, the dashboard **switches your active organisation** to the target automatically.

### What to keep in mind

<Warning>
  **Credentials and secrets don't transfer across organisations.** Each organisation has its own SOPS keys, registry credentials, and secrets. After a cross-org clone you must reconfigure:

  * Encrypted values in manifests and addon configs
  * Registry credentials if images are in private registries
  * Any organisation-specific variables referenced by the stack
</Warning>

<Tip>
  Organisation variables are scoped to each org. If the cloned stack references variables (e.g. `${ORG_DOMAIN}`), make sure equivalent variables exist in the target organisation or override them at the cluster/stack level.
</Tip>

***

## Handling Encrypted Values

When you clone a stack that contains encrypted values:

1. **Manifests:** Encrypted fields are replaced with placeholder values
2. **Addon configurations:** Values containing encrypted paths are cleared
3. **Warnings:** You'll see specific warnings about which resources need attention

<AccordionGroup>
  <Accordion title="Re-encrypting Secrets After Clone">
    After cloning, you'll need to re-encrypt secrets for the target cluster:

    1. Open the cloned draft in the target cluster
    2. Navigate to each manifest or addon that had encrypted values
    3. Enter the new secret values
    4. Use the SOPS button to encrypt them with the target cluster's key
    5. Save and deploy

    <Tip>
      Each cluster has its own SOPS encryption key. Values encrypted in one cluster cannot be decrypted in another - this is by design for security.
    </Tip>
  </Accordion>

  <Accordion title="Automating Secret Configuration">
    For automated deployments, consider:

    * Using external secrets management (e.g., Vault, AWS Secrets Manager)
    * Storing secrets in environment-specific configuration
    * Using Kubernetes ExternalSecrets operator
  </Accordion>
</AccordionGroup>

***

## Common Workflows

<AccordionGroup>
  <Accordion title="Staging to Production Promotion">
    ```bash theme={null}
    # Test in staging first
    ankra cluster select staging
    ankra cluster stacks list

    # Clone to production when ready
    ankra cluster stacks clone my-app-stack --to production

    # Switch to production and configure secrets
    ankra cluster select production
    # ... configure in dashboard
    ```
  </Accordion>

  <Accordion title="Standardizing Multiple Clusters">
    Clone your standard monitoring stack to all clusters:

    ```bash theme={null}
    ankra cluster select template-cluster

    for cluster in dev staging production; do
      ankra cluster stacks clone observability --to $cluster --name observability
      echo "Cloned to $cluster"
    done
    ```
  </Accordion>

  <Accordion title="Creating a Backup Configuration">
    ```bash theme={null}
    # Clone critical stacks to a DR cluster
    ankra cluster select primary
    ankra cluster stacks clone core-services --to dr-cluster
    ankra cluster stacks clone monitoring --to dr-cluster
    ankra cluster stacks clone ingress --to dr-cluster
    ```
  </Accordion>

  <Accordion title="Replicate All Stacks to a New Cluster">
    In the dashboard:

    1. Go to **Stacks** in your source cluster
    2. Click the **Clone Stacks** button next to the search bar - all stacks are selected
    3. Click **Clone to Cluster** in the floating action bar
    4. Choose your target cluster and click **Clone**
    5. All stacks are created as drafts on the target - review and deploy each one

    With the CLI:

    ```bash theme={null}
    ankra cluster select source-cluster

    # Clone each stack to the new cluster
    for stack in $(ankra cluster stacks list --names); do
      ankra cluster stacks clone "$stack" --to new-cluster
    done
    ```
  </Accordion>

  <Accordion title="Sharing a Stack with Another Organisation">
    Clone a well-tested stack to a client or partner organisation:

    ```bash theme={null}
    # From your template org, clone to the client's cluster
    ankra cluster select template-cluster
    ankra cluster stacks clone saas-platform --to client-production --org acme-corp

    # The client can then review the draft and add their secrets
    ```

    In the dashboard, select the target organisation from the dropdown in the clone dialog. After cloning, Ankra switches you to the target org automatically.
  </Accordion>
</AccordionGroup>

***

## Troubleshooting

<AccordionGroup>
  <Accordion title="Clone Failed: Stack Not Found">
    Ensure the source stack is deployed (not just a draft) and you have the correct stack name:

    ```bash theme={null}
    ankra cluster stacks list
    ```
  </Accordion>

  <Accordion title="Clone Failed: Access Denied">
    Verify you have access to both the source and target clusters. You must be a member of both clusters' organizations.
  </Accordion>

  <Accordion title="Clone Failed: Target Cluster Unavailable">
    The clone operation only creates a draft in the database - it doesn't require the target cluster to be online. Check your network connection to the Ankra API.
  </Accordion>

  <Accordion title="Missing Resources After Clone">
    If addons or manifests are missing:

    1. Check if the source stack had resources in a `deleting` or `deleted` state
    2. Verify the clone included addon configurations (`--include-config=true`)
    3. Check the warnings for any resources that couldn't be cloned
  </Accordion>
</AccordionGroup>

***

## AI Prompts

Press `Cmd+J` to open the AI Assistant and use these prompts:

<AccordionGroup>
  <Accordion title="Clone Stack">
    ```
    Clone the monitoring stack to my production cluster
    ```
  </Accordion>

  <Accordion title="Duplicate and Modify">
    ```
    Clone the ingress stack from staging to production and rename it to prod-ingress
    ```
  </Accordion>

  <Accordion title="Replicate to Multiple Clusters">
    ```
    Help me clone my observability stack to all my clusters
    ```
  </Accordion>
</AccordionGroup>

***

## Next Steps

<CardGroup cols={2}>
  <Card title="SOPS Encryption" icon="lock" href="/guides/sops">
    Learn how to encrypt secrets in your stacks.
  </Card>

  <Card title="GitOps Sync" icon="git-alt" href="/concepts/gitops">
    Sync your stack configurations to a Git repository.
  </Card>

  <Card title="Ankra CLI" icon="terminal" href="/integrations/ankra-cli">
    Learn more CLI commands for stack management.
  </Card>
</CardGroup>
