简体   繁体   English

如何在 kubernetes 上部署具有持久卷的 Logstash?

[英]How to deploy logstash with persistent volume on kubernetes?

Using GKE to deploy logstash by statefulset kind with pvc.使用 GKE 通过有状态集类型和 pvc 部署 logstash。 Also need to install an output plugin.还需要安装一个 output 插件。

When don't use while true; do sleep 1000; done;什么时候不使用while true; do sleep 1000; done; while true; do sleep 1000; done; in container's command args , it can't deploy with pvc successfully.在容器的命令args中,它无法使用 pvc 成功部署。

The pod will cause CrashLoopBackOff error. pod 会导致CrashLoopBackOff错误。

  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 I found it can try to add sleep.这里我发现它可以尝试添加睡眠。 So the statefulset with pvc can deploy successfully.所以带pvc的statefulset可以部署成功。

But when check its logs will find:但是当检查它的日志时会发现:

/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?如何以一种好的方式启动容器以安装logstash output 插件?

The whole manifest file:整个清单文件:

---
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

For my containers I have a script I have ran on Container Deployments and it works to install the plugins and then run logstash.对于我的容器,我有一个在 Container Deployments 上运行的脚本,它可以安装插件然后运行 logstash。 Post Arg> sh /usr/share/logstash/config/plugins.sh发布 Arg> sh /usr/share/logstash/config/plugins.sh

#!binbash

echo running post install scripts for plugins..;
logstash-plugin install logstash-filter-sentimentalizer
logstash-plugin install logstash-input-mysql
echo finished post install scripts for plugins..;
sleep 1
exec logstash 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM