将日志从特定pod发送到外部服务器



我们需要从一个k8s pod(具有巨大流量负载的pod(向Splunk服务器发送大量(非常(日志,我查看了文档,发现:

https://kubernetes.io/docs/concepts/cluster-administration/logging/#sidecar-集装箱——带记录

但是,文档中有一个注释,说明了大量的资源消耗。还有其他选择吗?我是说效率更高?由于这些吊舱处理流量,而我们无法添加额外的负载,这可能会危及其稳定性。。。

有一个官方的解决方案来获取Kubernets日志:用于Kubernetes的Splunk Connect。在引擎盖下,它还使用fluentd作为日志记录部分。

https://github.com/splunk/splunk-connect-for-kubernetes

您将首先在microK8上找到一个示例配置和测试方法,以熟悉配置和部署:https://mattymo.io/deploying-splunk-connect-for-kubernetes-on-microk8s-with-helm/

如果你只想要来自特定容器的日志,你可以使用值文件的这一部分只从你感兴趣的容器中选择日志:

fluentd:
# path of logfiles, default /var/log/containers/*.log
path: /var/log/containers/*.log
# paths of logfiles to exclude. object type is array as per fluentd specification:
# https://docs.fluentd.org/input/tail#exclude_path
exclude_path:
#  - /var/log/containers/kube-svc-redirect*.log
#  - /var/log/containers/tiller*.log
#  - /var/log/containers/*_kube-system_*.log (to exclude `kube-system` namespace)

最新更新