influxdata / helm-charts

Official Helm Chart Repository for InfluxData Applications
MIT License
233 stars 330 forks source link

[telegraf] etc directory is a read only file system #203

Closed sttrayno closed 4 years ago

sttrayno commented 4 years ago

Hi,

First off massive thank you for these charts, they've got me into using helm and have been a massive help.

I've been having an issue with the chart for telegraf, I'm using custom docker container as I have quite a complex telegraf config and need to install some packages so

Whenever I try to copy or clone files into the etc directory of the container I'm hit with an error that the /etc directory is a read only filesystem. I've verified this by doing an exec into the container. I'm able to clone or copy files into other directories such as root, just not the etc.

I'm assuming I'm missing something, but can't see anything in the configs or values thats /etc or filesystem specific.

When I deploy the container manually with kubectl all works as expected so I'm pretty sure I've narrowed it down to the helm chart.

Many thanks!

rawkode commented 4 years ago

The /etc/telegraf directory is read only because this Helm chart mounts over the top of it:

https://github.com/influxdata/helm-charts/blob/79b663c325b1ddcfe69330f8be4a1feff07d2995/charts/telegraf/templates/deployment.yaml#L46

Whenever I try to copy or clone files into the etc directory of the container

I don't understand this. When / how are you doing this?

sttrayno commented 4 years ago

Hi David,

That makes sense now I knew I was missing something.

To try explain myself a bit better, I'm trying to get the chart to use my own container which at build time copies some .conf files I've built into the telegraf.d directory. Looked fine on my machine but every time the container started with helm they weren't there, I wasn't sure why that was happening but you'd now explained it.

This was my values.yaml file

image:
  repo: "sttrayno/telegraf-connector"
  tag: "0.1"
  pullPolicy: Always

outputs:
  - influxdb:
     urls:
       - "http://influxdb.sttrayno-dev:8086"
     database: "telegraf"

Is there anyway to be able to write to the /etc/telegraf directory? or should I be looking for another way to achieve this?

rawkode commented 4 years ago

Unfortunately this chart won't support this use case, but I think it should.

I can describe what needs to happen, if you'd like to have a go at a PR; or I can find some time over the next few days to make the change.

Whatever you prefer is good with me

sttrayno commented 4 years ago

Happy to give it a shot, I'm a novice picking this stuff up

rawkode commented 4 years ago

Hey @sttrayno

I forgot I actually added something like this recently 😃

# volumes:
# - name: telegraf-output-influxdb2
#   configMap:
#     name: "telegraf-output-influxdb2"
# mountPoints:
# - name: telegraf-output-influxdb2
#   mountPath: /etc/telegraf/conf.d
#   subPath: influxdb2.conf

You can add your own config volume with a manual config.

cnf commented 3 years ago

@rawkode this doesn't actually work, there is no sub dir in /etc/telegraf and the filesystem is read-only still

Error: failed to create containerd task: OCI runtime create failed: container_linux.go:370: starting container process caused: process_linux.go:459: container init caused: rootfs_linux.go:59: mounting "/var/lib/kubelet/pods/5b689fe9-6313-4ec1-ad39-3ec08d3394f3/volume-subpaths/telegraf-input-snmp-edgemax/telegraf/1" to rootfs at "/run/k3s/containerd/io.containerd.runtime.v2.task/k8s.io/telegraf/rootfs/etc/telegraf/telegraf.d" caused: not a directory: unknown

rawkode commented 3 years ago

@cnf please provide a values file for me to reproduce and I’ll work it out

cnf commented 3 years ago

Hi @rawkode

The value file from this repo (https://github.com/influxdata/helm-charts/blob/master/charts/telegraf/values.yaml#L28) will reproduce this issue.

Uncomment line 28 to 35

volumes:
 - name: telegraf-output-influxdb2
   configMap:
     name: "telegraf-output-influxdb2"
 mountPoints:
 - name: telegraf-output-influxdb2
   mountPath: /etc/telegraf/conf.d
   subPath: influxdb2.conf

create a config map, and deploy helm

touch influxdb2.conf
kubectl create configmap telegraf-output-influxdb2 --from-file=influxdb2.conf
helm upgrade --install -f local-values.yaml telegraf-mount-test influxdata/telegraf

Thanks!