Failed to deploy Telegraf by its helm chart to Kubernetes

I am trying to deploy Telegraf by its helm chart to Kubernetes.

However, when I follow the readme by GitHub - influxdata/helm-charts: Official Helm Chart Repository for InfluxData Applications

helm repo add influxdata https://helm.influxdata.com/
helm upgrade --install my-release influxdata/telegraf

I got error

Failed to pull image "telegraf:1.24-alpine": rpc error: code = NotFound desc = failed to pull and unpack image "docker.io/library/telegraf:1.24-alpine": no match for platform in manifest: not found

Usually, the image name is docker.io/someOrganization/telegraf:1.24-alpine, however, Telegraf image is not under an org at Docker Hub

I am thinking should docker.io/library/telegraf:1.24-alpine be docker.io/telegraf:1.24-alpine?

Any idea? Thanks! :smiley:

Once I change from official image telegraf to bitnami/telegraf by

helm install \
  telegraf \
  influxdata/telegraf \
  --values=my-values.yaml

my-values.yaml:

# Based on https://github.com/influxdata/helm-charts/blob/master/charts/telegraf/values.yaml

image:
  repo: "bitnami/telegraf"
  tag: "1.24.3"
  outputs:
    - influxdb_v2:
      urls:
        - "http://influxdb.hm-influxdb:8086"
      token: "xxx"
      organization: "primary"
      bucket:  "primary"

The previous image not found issue will be fixed, however, I got a new error:

Error: INSTALLATION FAILED: Service “telegraf” is invalid: spec.ports: Required value

This error means Kubernetes Service has to expose a port, apparently Telegraf installed by this helm chart does not expose a port by default.

Also, I have container error log:

NAME:
   Telegraf - The plugin-driven server agent for collecting & reporting metrics.

USAGE:
   Telegraf [global options] command [command options] [arguments...]

COMMANDS:
   config   print out full sample configuration to stdout
   version  print current version to stdout
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --aggregator-filter value                              filter the aggregators to enable, separator is ':'
   --config value [ --config value ]                      configuration file to load
   --config-directory value [ --config-directory value ]  directory containing additional *.conf files
   --debug                                                turn on debug logging (default: false)
   --deprecation-list                                     print all deprecated plugins or plugin options (default: false)
   --help, -h                                             show help (default: false)
   --input-filter value                                   filter the inputs to enable, separator is ':'
   --input-list                                           print available input plugins (default: false)
   --once                                                 run one gather and exit (default: false)
   --output-filter value                                  filter the outputs to enable, separator is ':'
   --output-list                                          print available output plugins (default: false)

Due to I met too many issues for this helm chart, I currently temporally end up with writing my own Kubernetes YAML files:

telegraf/telegraf-deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: telegraf-deployment
  labels:
    app.kubernetes.io/name: telegraf
spec:
  replicas: 1
  selector:
    matchLabels:
      app: telegraf
  template:
    metadata:
      labels:
        app: telegraf
    spec:
      containers:
        - name: telegraf
          image: telegraf:1.24.3
          ports:
            - name: telegraf
              protocol: TCP
              containerPort: 8094
          volumeMounts:
            - name: telegraf-configmap-volume
              mountPath: /etc/telegraf/
      volumes:
        - name: telegraf-configmap-volume
          configMap:
            name: telegraf-configmap

telegraf/telegraf-service.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: telegraf-deployment
  labels:
    app.kubernetes.io/name: telegraf
spec:
  replicas: 1
  selector:
    matchLabels:
      app: telegraf
  template:
    metadata:
      labels:
        app: telegraf
    spec:
      containers:
        - name: telegraf
          image: telegraf:1.24.3
          ports:
            - name: telegraf
              protocol: TCP
              containerPort: 8094
          volumeMounts:
            - name: telegraf-configmap-volume
              mountPath: /etc/telegraf/
      volumes:
        - name: telegraf-configmap-volume
          configMap:
            name: telegraf-configmap

telegraf/telegraf-configmap.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: telegraf-configmap
  namespace: hm-telegraf
  labels:
    app.kubernetes.io/name: telegraf
data:
  telegraf.conf: |
    [[outputs.influxdb_v2]]
      urls = ["http://influxdb.hm-influxdb:8086"]
      token = "xxx"
      organization = "primary"
      bucket = "primary"

Then I can succeed installing by

kubectl apply --filename=telegraf

Hopefully it helps future people! :smiley:

I also opened a GitHub issue ticket Failed to deploy Telegraf · Issue #528 · influxdata/helm-charts · GitHub

1 Like