# Configuration & Environment Overrides

> Overrides for Apache Superset, covering configuration properties, environment variables and Pod specs per role or role group.

The cluster definition also supports overriding configuration properties and environment variables, either per role or per role group, where the more specific override (role group) has precedence over the less specific one (role).

> **Important:** Overriding certain properties which are set by the operator (such as the `STATS_LOGGER`) can interfere with the operator and can lead to problems.

## Configuration Properties

For a role or role group, at the same level of `config`, you can specify `configOverrides` for the `superset_config.py`. For example, if you want to set the CSV export encoding and the preferred databases adapt the `nodes` section of the cluster resource as follows:

```yaml
nodes:
  roleGroups:
    default:
      config: {}
      configOverrides:
        superset_config.py:
          CSV_EXPORT: "{'encoding': 'utf-8'}"
          PREFERRED_DATABASES: |-
            [
                'PostgreSQL',
                'Presto',
                'MySQL',
                'SQLite',
                # etc.
            ]
```

Just as for the `config`, it is possible to specify this at the role level as well:

```yaml
nodes:
  configOverrides:
    superset_config.py:
      CSV_EXPORT: "{'encoding': 'utf-8'}"
      PREFERRED_DATABASES: |-
        [
            'PostgreSQL',
            'Presto',
            'MySQL',
            'SQLite',
            # etc.
        ]
  roleGroups:
    default:
      config: {}
```

All override property values must be strings. They are treated as Python expressions. So care must be taken to produce a valid configuration.

For a full list of configuration options we refer to the [main config file for Superset](https://github.com/apache/superset/blob/master/superset/config.py).

As Superset can be configured with python code too, arbitrary code can be added to the `superset_conf.py`. You can use either `FILE_HEADER` to add code to the top or `FILE_FOOTER` to add to the bottom.

> **Important:** This is an experimental feature

```yaml
nodes:
  configOverrides:
    superset_config.py:
      CSV_EXPORT: "{'encoding': 'utf-8'}"
      FILE_HEADER: |
        from modules.my_module import my_class
      FILE_FOOTER: |
        import logging
        from superset.security import SupersetSecurityManager

        class myCustomSecurityManger(SupersetSecurityManager):
          def __init__():
            init()

        CUSTOM_SECURITY_MANAGER = myCustomSecurityManger
  roleGroups:
    default:
      config: {}
```

## Environment Variables

In a similar fashion, environment variables can be (over)written. For example per role group:

```yaml
nodes:
  roleGroups:
    default:
      config: {}
      envOverrides:
        FLASK_ENV: development
```

or per role:

```yaml
nodes:
  envOverrides:
    FLASK_ENV: development
  roleGroups:
    default:
      config: {}
```

## Pod overrides

The Superset operator also supports Pod overrides, allowing you to override any property that you can set on a Kubernetes Pod. Read the [Pod overrides documentation](https://docs.stackable.tech/home/stable/concepts/overrides/index.md) to learn more about this feature.
