# YAML configuration mapping for Aerospike on Kubernetes

## Mapping between YAML and Aerospike configuration

Kubernetes uses YAML configuration files and the Aerospike database uses its own format for configuration. The database configurations are stored in `aerospike.conf`. AKO translates between the two.

## Translation conventions

AKO uses the following conventions to translate its YAML configurations to the Aerospike server’s `aerospike.conf` format.

### Simple key and values

Most simple key-value pairs translate directly, with the exception of storage sizes.

#### YAML

```yaml
replication-factor: 2
```

#### aerospike.conf

```plaintext
replication-factor 2
```

### Storage Sizes

File and device sizes in the YAML format are integers and must be specified as number of bytes. In `aerospike.conf` you may provide an integer byte unit as in YAML or provide a string with `G` or `M` to denote gigabytes or megabytes.

#### YAML

```yaml
filesize: 4294967296 # 4 gigabytes
```

#### aerospike.conf

```plaintext
filesize 4G
```

### Lists of Simple Values

YAML uses a key’s plural form when there are a list of values (and it uses a list type).

Lists of simple values are written in Aerospike by repeating the same configuration key multiple times.

#### YAML

```yaml
addresses:

  - 192.168.1.1

  - 192.168.5.1

files:

  - /opt/aerospike/ns1.dat

  - /opt/aerospike/ns2.dat
```

#### aerospike.conf

```plaintext
address 192.168.1.1

address 192.168.5.1

file /opt/aerospike/ns1.dat

file /opt/aerospike/ns2.dat
```

### Fixed sections

The Aerospike configuration groups parts of the configuration into sections. The YAML forms of these are represented as maps.

#### YAML

```yaml
service:

  service-threads: 4

  proto-fd-max: 15000
```

#### aerospike.conf

```plaintext
service {

  service-threads 4

  proto-fd-max 15000

}
```

### Named sections

Named sections, which can have multiple named entries in `aerospike.conf` such as `namespace`, `dc`, or `datacenter`, are translated to a named list of maps in YAML.

The name of the list will be the plural form of the `aerospike.conf` section.

#### YAML

```yaml
namespaces:

  - name: test

    replication-factor: 2

    storage-engine:

      type: memory

      files:

        - /opt/aerospike/data/test1.dat

        - /opt/aerospike/data/test2.dat

      filesize: 4294967296

  - name: bar

    replication-factor: 2

    storage-engine:

      type: memory

      data-size: 4294967296
```

#### aerospike.conf

```plaintext
namespace test {

    replication-factor 2

    storage-engine memory {

            file /opt/aerospike/data/test1.dat

            file /opt/aerospike/data/test2.dat

            filesize 4G

    }

}

namespace bar {

    replication-factor 2

    data-size 4G

    storage-engine memory

}
```

### Typed sections

Typed sections have a fixed enum type associated with them in `aerospike.conf` such as `storage-engine` and `index-type`. These are translated to map with additional property `type` in YAML. The valid values for the type are the same as the valid enum values for the section.

#### YAML

```yaml
namespaces:

  - name: test

    .

    .

    storage-engine:

      type: memory

      files:

        - /opt/aerospike/data/test1.dat

        - /opt/aerospike/data/test2.dat

      filesize: 4294967296
```

#### aerospike.conf

```plaintext
namespace test {

    .

    .

    storage-engine memory {

            file /opt/aerospike/data/test1.dat

            file /opt/aerospike/data/test2.dat

            filesize 4G

    }

}
```

### Aerospike logging section

Aerospike offers three types of log sinks in the YAML logging section: file, console, and syslog (introduced in server 6.3). The log sink type is specified by the `name` field in the YAML file, which can have the values `console`, `syslog`, or the actual file name if the sink type is `file`. You can define the logging context and log level for the log sink as `key: value` pairs. For more information, see [Aerospike logging documentation](https://aerospike.com/docs/database/manage/logging/logs).

#### YAML

```yaml
logging:

  - name: console

    any: info

  - name: /var/log/aerospike/aerospike.log

    any: info

    tls: debug

  - name: syslog

    audit: info

    facility: local0

    tag: aerospike-audit

    path: /dev/log
```

#### aerospike.conf

```plaintext
logging {

    console {

        context any info

    }

    file /var/log/aerospike/aerospike.log {

        context any info

        context tls debug

    }

    syslog {

        context audit info

        facility local0

        tag aerospike-audit

        path /dev/log

    }

}
```

## Complete example

#### YAML

```yaml
service:

  proto-fd-max: 15000

security: {}

logging:

  - name: console

    any: info

  - name: /var/log/aerospike/aerospike.log

    any: info

xdr:

    dcs:

        - name: dc1

          node-address-ports:

              - aeroclusterdst-0-0 3000

          auth-user: admin

          auth-password-file: /etc/aerospike/secret/password_DC1.txt

          auth-mode: internal

          namespaces:

              - name: test

namespaces:

    - name: test

      replication-factor: 2

      storage-engine:

          type: memory # Store data in memory in addition to file.

          files:

              - /opt/aerospike/data/test.dat

          filesize: 4294967296

mod-lua:

  user-path: /opt/aerospike/usr/udf/lua
```

#### aerospike.conf

```plaintext
service {                # Tuning parameters and process owner

    proto-fd-max 15000

}

security {               # (Optional, Enterprise Edition only) to enable

                         # ACL on the cluster

}

logging {               # Logging configuration

    console {

        context any info

    }

    file /var/log/aerospike/aerospike.log {

        context any info

    }

}

xdr {

    dc REMOTE_DC_1 {

        auth-mode    internal

        auth-password-file    /etc/aerospike/secret/password_DC1.txt

        auth-user    admin

        node-address-port    172.68.17.123 3000

        namespace test {

        }

    }

}

namespace test {       # Define namespace record policies and storage engine

    replication-factor 2

    storage-engine memory { # Store data in memory in addition to file.

            file /opt/aerospike/data/test.dat

            filesize 4G

    }

}

mod-lua {                # location of UDF modules

    user-path /opt/aerospike/usr/udf/lua

}
```