Articles in this section

How can I add my own ape.toml to the exporter sidecar when using AKO?

Context

When using the Aerospike Prometheus Exporter, there may be use cases where a custom ape.toml file should be specified. We can attach our own custom ape.toml to our exporter sidecar using a ConfigMap and then telling the Exporter to explicitly use our custom ape.toml rather than the default shipped with the image.

This will be our very simple ape.toml example inside the ConfigMap:
$ cat prom-export-configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: exporter-config
data:
  ape.toml: |
    [Agent]
    cert_file = ""
    key_file = ""
    root_ca = ""
    key_file_passphrase = ""

    labels = {}
    bind = ":9145"
    timeout = 10

    log_file = ""
    log_level = ""

    basic_auth_username=""
    basic_auth_password=""

    [Aerospike]
    db_host="aspod-0"
    db_port=3000

    root_ca=""
    cert_file=""
    key_file=""

    node_tls_name=""

    user="admin"
    password="admin"

    auth_mode=""
    timeout=5

Method

Once you have the ape.toml file configured in the way desired we can upload the ConfigMap to our Aerospike kubernetes namespace.
kubectl apply -f prom-export-configmap.yaml -naerospike

Let's open the CustomResource yaml for our AerospikeCluster and do the following:
$ vim aerospike_cluster.yaml

Inside the yaml we can reference the ConfigMap as a volume for our sidecar like so:
  storage:
    filesystemVolumePolicy:
      initMethod: deleteFiles
      cascadeDelete: true
    blockVolumePolicy:
      cascadeDelete: true
    volumes:
      - name: exporter-config
        sidecars:
          - containerName: aerospike-prometheus-exporter
            path: /opt/aerospike-prometheus-exporter/config/
        source:
          configMap:
            name: exporter-config

The reason we're mounting this to /opt/ instead of the default /etc/ is because there could be files in the future that the exporter may utilize in /etc/aerospike-prometheus-exporter/ and our mount would overwrite any of those files leading to unexpected behaviors.
Now we need to tell the exporter where our preferred ape.toml is. We can do this by specifying a command and args to our sidecar like so:
  podSpec:
    multiPodPerHost: false
    metadata:
      annotations:
    sidecars:
    - name: aerospike-prometheus-exporter
      image: aerospike/aerospike-prometheus-exporter:latest
      command: ["/bin/sh", "-c"]
      args:
        - aerospike-prometheus-exporter --config /opt/aerospike-prometheus-exporter/config/ape.toml
      ports:
        - containerPort: 9145
          name: exporter
      env:
        - name: "AS_AUTH_USER"
          value: "admin"
        - name: "AS_AUTH_PASSWORD"
          value: "admin123"
        - name: "AS_AUTH_MODE"
          value: "internal"

That's it! When applying the CustomResource yaml to the operator it will detect these values and mount our ConfigMap that contains the ape.toml into the directory /opt/aerospike-prometheus/exporter/config.
 
$ kubectl apply -f aerospike_cluster.yaml -naerospike

 

Notes

  •  In Aerospike Prometheus Exporter 1.12 a new file named gauge_stats_list.toml was added into /etc/aerospike-prometheus-exporter/. If we were to overwrite the directory from our volume mount then the exporter will fail to start because it cannot access the new toml file.

Applies To Latest Version

Current Version
Was this article helpful?
0 out of 0 found this helpful