# How to deploy logstash with persistent volume on kubernetes?

**URL:** <https://discuss.elastic.co/t/how-to-deploy-logstash-with-persistent-volume-on-kubernetes/258505>\
**Category:** Logstash\
**Created:** [December 13, 2020, 1:17pm UTC](https://discuss.elastic.co/t/how-to-deploy-logstash-with-persistent-volume-on-kubernetes/258505 "2020-12-13T13:17:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![iooi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/iooi/32/79231_2.png) [@iooi](https://discuss.elastic.co/u/iooi)\
**Post date:** [December 13, 2020, 1:17pm UTC](https://discuss.elastic.co/t/how-to-deploy-logstash-with-persistent-volume-on-kubernetes/258505/1 "2020-12-13T13:17:59Z")

</div>

Using GKE to deploy logstash by statefulset kind with pvc. Also need to install an output plugin.

When don't use `while true; do sleep 1000; done;` in container's command `args`, it can't deploy with pvc successfully.

The pod will cause `CrashLoopBackOff` error.

```auto
  Normal Created 13s (x2 over 14s) kubelet Created container logstash
  Normal Started 13s (x2 over 13s) kubelet Started container logstash
  Warning BackOff 11s (x2 over 12s) kubelet Back-off restarting failed container

```

From [here](https://stackoverflow.com/a/40093356/14718202) I found it can try to add sleep. So the statefulset with pvc can deploy successfully.

But when check its logs will find:

```auto
/bin/sh: bin/logstash-plugin: No such file or directory
/bin/sh: bin/logstash: No such file or directory

```

How to do it in a good way to start container to install an logstash output plugin?

The whole manifest file:

```auto
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: logstash-to-gcs
  namespace: logging
spec:
  serviceName: "logstash"
  selector:
    matchLabels:
      app: logstash
  updateStrategy:
    type: RollingUpdate
  replicas: 3
  template:
    metadata:
      labels:
        app: logstash
    spec:
      containers:
      - name: logstash
        image: docker.elastic.co/logstash/logstash:7.10.0
        resources:
          limits:
            memory: 2Gi
        ports:
          - containerPort: 5044
        volumeMounts:
          - name: config-volume
            mountPath: /usr/share/logstash/config
          - name: logstash-pipeline-volume
            mountPath: /usr/share/logstash/pipeline
          - name: logstash-data
            mountPath: /usr/share/logstash
        command: ["/bin/sh","-c"]
        args:
          - bin/logstash-plugin install logstash-output-google_cloud_storage;
            bin/logstash -f /usr/share/logstash/pipeline/logstash.conf;
            while true; do sleep 1000; done;
      volumes:
        - name: config-volume
          configMap:
            name: logstash-configmap
            items:
              - key: logstash.yml
                path: logstash.yml
        - name: logstash-pipeline-volume
          configMap:
            name: logstash-configmap
            items:
              - key: logstash.conf
                path: logstash.conf
  volumeClaimTemplates:
  - metadata:
      name: logstash-data
    spec:
      accessModes: ["ReadWriteOnce"]
      resources:
        requests:
          storage: 1Gi

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 10, 2021, 1:18pm UTC](https://discuss.elastic.co/t/how-to-deploy-logstash-with-persistent-volume-on-kubernetes/258505/2 "2021-01-10T13:18:01Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
