Permission Denied error using kubernetes and Logstash

10/23/2019

I am using a Logstash sidecar to monitor log files from a deployment. I Was intending to use a configmap to pass my own logstash.yml to the Logstash sidecar. My first implementation was as follows

  - name: logstash-sidecar
    image: docker.elastic.co/logstash/logstash:7.2.0
    volumeMounts:
      - name: shared-plugins-logstash
        mountPath: /usr/share/logstash/plugins/
      - name: logstash-yaml
        readOnly: true
        mountPath: /usr/share/logstash/config/logstash.yml
        subPath: logstash.yml
      - name: logstash-conf
        mountPath: /usr/share/logstash/pipeline/logstash.conf
        subPath: logstash.conf
      - name: shared-logs
        mountpath: var/logs/logstash

with the volumes as follows

volumes:
  - name: shared-plugins-logstash
    emptyDir: {}
  - name: logstash-yaml
    configMap:
      name: logstash-yaml
  - name: logstash-conf
    configMap:
      name: logstash-conf

The logstash-yaml config map

apiVersion: v1
kind: ConfigMap
metadata:
  name: logstash-yaml
data:
  logstash.yml: |
    http.host: "0.0.0.0"
    path.config: /usr/share/logstash/pipeline
    log.level: debug
    path.logs: /var/logs/logstash

This would generate an error saying that /usr/share/logstash/config/ is a read-only file system

I researched the problem and also saw the following solution

Kubernetes deployment read-only filesystem error

The 2nd solution of this creates a new error saying that

permission denied cannot open /usr/share/logstash/config/logstash.yml

setting the security context of the container as 2000 did not help in running the container as well.

Any help on the matter will be greatly appreciated.

-- Ranika Nisal
kubernetes
logstash

0 Answers