# Add a Stack

## Motivation

If your company or clients have multiple similar setups or reference architectures, making them readily available to all employees or clients could make sense. All product versions are pinned in the custom-defined stack, so you can easily spin up a stack containing the identical versions as your production setup. You can use your defined stack to give it to colleagues or potential customers to show the overall architecture of the Data Platform you will build.

Please keep in mind that a stack requires a release to run on. In most cases, the stackable provided release should work fine, but you can also look at the chapter [Add a Release](https://docs.stackable.tech/management/stable/stackablectl/customization/add-release/index.md) on creating your release.

## 1\. Create a stacks.yaml

For a custom stack you need to create a `mycorp-stacks.yaml` containing stacks according to the format defined by [the Stackable provided stacks](https://github.com/stackabletech/demos/blob/main/stacks/stacks-v2.yaml).

As of writing a `stacks.yaml` file could look as follows:

```yaml
stacks:
  mycorp-warehouse:
    description: Internal stack we use to build our warehouses
    stackableRelease: 25.7 # or use your custom release mycorp-release1
    stackableOperators:
      - commons
      - listener
      - secret
      - trino
      - superset
    labels:
      - mycorp
      - warehouse
    manifests:
      # We have Superset in our Stack, which needs a postgresql instance
      # So let's install that first
      - helmChart: https://my.corp/stacks/mycorp-warehouse/postgresql.yaml
      - plainYaml: https://my.corp/stacks/mycorp-warehouse/trino.yaml
      - plainYaml: https://my.corp/stacks/mycorp-warehouse/superset.yaml
```

The referenced `helmChart` file above could look like the following:

```yaml
releaseName: postgresql-superset
name: postgresql
repo:
    name: bitnami
    url: https://charts.bitnami.com/bitnami/
version: 16.7.21
options:
  global:
    security:
      allowInsecureImages: true
  image:
    repository: bitnamilegacy/postgresql
  volumePermissions:
    image:
      repository: bitnamilegacy/os-shell
  metrics:
    image:
      repository: bitnamilegacy/postgres-exporter
  auth:
    username: superset
    password: superset
    database: superset
```

## 2\. Using the Custom `stacks.yaml` File

After creating the `mycorp-stacks.yaml` file, it can be added to the available stacks in `stackablectl` via the CLI argument `--stack-file mycorp-demos.yaml`.

The argument to `--stack-file` can be a path to a file on the local filesystem or a URL. For example, the demo file can be put into a central Git repository and referenced by all teams or clients. Multiple "\`--stack-file\` flags can be specified to include multiple stack files.

Additionally, the custom file can be provided using an environment variable. The variable can be defined by `export` in the shell or a `.env` file.

```ini
STACKABLECTL_STACK_FILES=stacks1.yml,stacks2.yml
```

Every additional stack will be added to the already existing stacks in `stackablectl`, so all the available stack files will be merged.
