Skip to content
Jörg Eichhorn edited this page Nov 30, 2021 · 1 revision

k8s-sidecar

A dead simple kubernetes sidecar container for downloading configmaps and secrets as files.

Usage examples

Common usage scenarios.

Auto-Provisioning Dashboards for Grafana

That’s the most popular use-case. It relies on Grafanas provisioning feature.

Make sure to configure a dashboard provider pointing to a folder for example /tmp/sidecar-boards:

apiVersion: 1

providers:
  - name: 'k8s-sidecar'
    # <string> name of the dashboard folder.
    folder: ''
    type: file
    disableDeletion: false
    updateIntervalSeconds: 10
    allowUiUpdates: false
    options:
      path: '/tmp/sidecar-boards'
      foldersFromFilesStructure: true

Now embed the k8s-sidecar in the pod as a sidecar container with the following environment configuration:

Variable Value Note

LABEL

dashboard

Label your configmaps with this label key with and arbitrary label value

FOLDER

/tmp/sidecar-boards

Matches the file provisioner configuration above

Now a config map like this:

apiVersion: v1
kind: ConfigMap
metadata:
  name: my-grafana-dashboard
  labels:
    dashboard: "1"
  annotations:
    k8s-sidecar-target-directory: "test"
data:
  my-grafana-dashboard.json:  "..." # snip

Is going to be downloaded by the sidecar and placed in the filesystem as /tmp/sidecar-boards/test/my-grafana-dashboard.json. After at most 10s the provisioner should detect the file and place the dashboard in the folder test because it’s configured to re-use the folder structure.

Clone this wiki locally