如何在Kubernetes上以持久卷部署Logstash? [英] How to deploy logstash with persistent volume on kubernetes?
问题描述
使用GKE通过带pvc的statefulset种类部署logstash.还需要安装输出插件.
Using GKE to deploy logstash by statefulset kind with pvc. Also need to install an output plugin.
当不使用时为true;睡一千完成;
在容器的命令 args
中,则无法通过pvc成功部署.
When don't use while true; do sleep 1000; done;
in container's command args
, it can't deploy with pvc successfully.
广告连播会导致 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
在此处中,我发现它可以尝试增加睡眠.因此,带有pvc的状态集可以成功部署.
From here I found it can try to add sleep. So the statefulset with pvc can deploy successfully.
但是当检查其日志时会发现:
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
如何以良好的方式启动容器以安装Logstash输出插件?
How to do it in a good way to start container to install an logstash output plugin?
整个清单文件:
---
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
推荐答案
对于我的容器,我有一个在Container Deployments上运行过的脚本,它可以安装插件,然后运行logstash.发表Arg>sh/usr/share/logstash/config/plugins.sh
For my containers I have a script I have ran on Container Deployments and it works to install the plugins and then run logstash. Post 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
这篇关于如何在Kubernetes上以持久卷部署Logstash?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!