Skip to content

Instantly share code, notes, and snippets.

@taking
Last active July 7, 2022 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taking/91aba3cbb6c91290f2214497278954b1 to your computer and use it in GitHub Desktop.
Save taking/91aba3cbb6c91290f2214497278954b1 to your computer and use it in GitHub Desktop.

InfluxDB-Telegraf installation with Helm

  • InfluxDB, Telegraf on Kubernetes

helm Chart

Prerequisites

  • Kubernetes 1.19+
  • Helm 3.2.0+
  • A persistent storage resource and RW access to it
  • Kubernetes StorageClass for dynamic provisioning

Document

InfluxDB

helm update

helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update

Install

helm install influxdb bitnami/influxdb  \
  --create-namespace \
  --namespace telegraf \
  --set global.storageClass=ceph-block \
  --set auth.admin.username=admin \
  --set auth.admin.password=password \
  --set auth.admin.token=JGivRLzRUSf39AvTnxzUd8 \
  --set auth.admin.org=primary \
  --set auth.admin.bucket=primary \
  --set influxdb.service.type=NodePort \
  --set influxdb.service.nodePorts=32073

Telegraf

helm update

helm repo add influxdata https://helm.influxdata.com/
helm repo update

value-override.yml

cat <<EOF > value-override.yaml
override_config:
  toml: |+
    [global_tags]
      cluster = "openstack-192-168-160-242"
      hostname = "$HOSTNAME"
    [[inputs.cpu]]
    [[inputs.disk]]
    [[inputs.mem]]
    [[inputs.nvidia_smi]]
    [[outputs.influxdb_v2]]
      urls = ["http://influxdb.telegraf.svc.cluster.local:8086"]
      bucket = "primary"
      organization = "primary"
      token = "JGivRLzRUSf39AvTnxzUd8"

config:
  # global_tags:
  #   cluster: "openstack-192-168-160-242"
  agent:
    interval: "10s"
    round_interval: false
    metric_batch_size: 1000
    metric_buffer_limit: 10000
    collection_jitter: "0s"
    flush_interval: "10s"
    flush_jitter: "0s"
    precision: ""
  outputs:
    - influxdb:
        urls:
          - "http://influxdb.telegraf.svc.cluster.local:8086"
        database: "telegraf"
        retention_policy: ""
        timeout: "5s"
        username: ""
        password: ""
        user_agent: "telegraf"
        insecure_skip_verify: false
EOF

Install

helm upgrade --install telegraf-ds influxdata/telegraf-ds \
  --create-namespace \
  --namespace telegraf \
  --set config.docker_endpoint="" \
  -f value-override.yaml

image

@taking
Copy link
Author

taking commented Jul 7, 2022

(Option) Sample

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: redis
  namespace: telegraf
spec:
  selector:
    matchLabels:
      app: redis
  serviceName: redis
  template:
    metadata:
      labels:
        app: redis
      annotations:
        telegraf.influxdata.com/inputs: |+
          [[inputs.redis]]
            servers = ["tcp://localhost:6379"]
        telegraf.influxdata.com/class: app
        telegraf.influxdata.com/env-fieldref-NAMESPACE: metadata.namespace
        telegraf.influxdata.com/limits-cpu: '750m'
        # invalid memory limit, which will be ignored
        telegraf.influxdata.com/limits-memory: '800x'
    spec:
      containers:
      - name: redis
        image: redis:alpine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment