# Using Object Stores

Blobstores aka Objectstores have a REST Interface that you can upload your Payload to and receive an ID for it. They are normally structured into *Buckets* or *Containers* to privide
some sort of pooling payload within the store.

The *nscale Server Storage Layer* supports multiple brands of objectstores, the most popular being Amazon S3 and Microsoft Azure Blobstore.

In order to use them, you need to 
- get an account for the store
- configure the *nstl* with the url, credentials etc.
- Add firewall rules to access to store

Have a look at the sample files

- s3-env.yaml  
  for Amazon S3 compatible storage, and
- azureblob.yaml  
  for Azure Blobstore

For S3 compatible storage, there are multiple S3 flavours available.



# Custom Environment Variables

There are multiple ways of how to set custom environment variables in addition to the named values, you set in helm:

## Using `env`

Please have a look at `s3-env.yaml` to see how custom environment variables can be injected into a component:

```
nstl:
  env:
    # Archivtyp
    NSTL_ARCHIVETYPE_900_NAME: "S3"
    NSTL_ARCHIVETYPE_900_ID: "900"
    NSTL_ARCHIVETYPE_900_LOCALMIGRATION: "0"
    NSTL_ARCHIVETYPE_900_LOCALMIGRATIONTYPE: "NONE"
    NSTL_ARCHIVETYPE_900_S3MIGRATION: "1"
```

This will set the environment variables in the storage layer to add an archive type with id 900.


## Using `envMap` and `envSecret`

Alternatively to the standard `env`setting, you can also use configmaps and secrets for additional environment variables.

The file `s3-envres.yaml` creates a configmap and a secret with the same variables as used in the `s3-env.yaml` sample. `s3-envfrom.yaml` shows how to import them. 

Please be aware, that data in secrets need to be base64 encoded:

```
echo "xxx" | base64
```

So in order to use the envFrom mechanism,

- prepare the resources (as in `s3-envres.yaml`)
- upload the resources to your cluster
  ```
  kubectl apply -f s3-envres.yaml
  ```
- add it to your configuration
  ```
  nstl:
    # These resources are set in the s3-envres.yaml sample file
    # you can set single values (envMap or envSecret) or lists (envMaps or envSecrets)
    envMaps:
      - env-sample-archivetype
      - env-sample-device
    envSecret: env-sample-device-secret
  ```
