Open stianlagstad opened 2 years ago
I have the same problem.
I have the same issue. I run influxdb on an UBUNTU server in docker. I like to use my Synology NAS as a persistent store for the influx database. The NAS directory is mounted and owned by root. It looks like the influxdb docker container always runs as user:1000. I guess, this combination creates the issue for me. I have not been able to figure out how to make it work (I am not a Linux expert, I have to admit). Any help is appreciated. I have a similar constellation with Frigate, also using the NAS as persistent storage. Frigate runs as root though, and this works fine.
This problem might be related to this issue: https://github.com/kubernetes/kubernetes/issues/62099
I don't think it's possible to set permissions on ConfigMaps and Secrets mounted as files, I was running into a similar error like chown: changing ownership of '/etc/influxdb2/config.yml': Read-only file system
. Instead, use an initContainer to copy the ConfigMap/Secret to a file on another volume, then mount that volume into the target container like this simplified example using ConfigMaps:
spec:
containers:
- envFrom:
- configMapRef:
name: influxdb-env
optional: false
image: influxdb:2.7.7
imagePullPolicy: Always
name: influxdb
ports:
- containerPort: 8086
name: influxdb
protocol: TCP
readinessProbe:
failureThreshold: 10
httpGet:
path: /ping
port: 8086
scheme: HTTPS
initialDelaySeconds: 3
periodSeconds: 30
successThreshold: 1
timeoutSeconds: 1
volumeMounts:
- mountPath: /etc/ssl/influxdb-selfsigned.crt
name: influxdb-certs-volume
readOnly: true
subPath: tls.crt
- mountPath: /etc/ssl/influxdb-selfsigned.key
name: influxdb-certs-volume
readOnly: true
subPath: tls.key
- mountPath: /etc/influxdb2/config.yml
name: config-writable
subPath: config.yml
- mountPath: /var/lib/influxdb2
name: influxdb-volume
initContainers:
- command:
- sh
- '-c'
- cp /config/config.yml /config-writable/config.yml
image: busybox
imagePullPolicy: Always
name: copy-influxdb-config
volumeMounts:
- mountPath: /config-writable
name: config-writable
- mountPath: /config/config.yml
name: influxdb-config-volume
subPath: config.yml
I'd like to run InfluxDB2 in a docker container in Kubernetes, and I'd like to avoid having to manually setup a user. I do know from https://hub.docker.com/_/influxdb that it's possible to do this using environment variables, and I've made that work, but I'd like to do this using a kubernetes secret instead and mount that as the file
/etc/influxdb2/influx-configs
in the container.I have this secret:
And I'm mounting it like this in my statefulset:
And this seems to work. If I go into the container I can see this:
I can also see that it seems to be a symbolic link:
However, if I port forward (
kubectl -n observability port-forward influxdb-0 8086:8086
) and open browser at http://localhost:8086 I'm redirected to http://localhost:8086/onboarding/0, which seems to indicate that my efforts failed.Here are the initial logs of the influxdb container:
Should this be possible? If so, what am I missing? Thanks for reading! (I've also posted this here: https://stackoverflow.com/questions/72126100/bootstrap-influxdb-2-in-a-docker-container-with-pre-existing-influx-configs-file)