loggie-io/loggie

containerd无法通过stdout收集到日志

Closed this issue · 0 comments

基础环境如下:

kubernetes: 1.25.11
containerd: 1.6.14
loggie:v1.4.0

安装配置values.yaml目录对应如下:

extraVolumeMounts:
  - mountPath: /var/log/pods
    name: podlogs
  - mountPath: /var/lib/docker/containers
    name: dockercontainers
  - mountPath: /var/lib/kubelet/pods
    name: kubelet

extraVolumes:
  - hostPath:
      path: /var/log/pods
      type: DirectoryOrCreate
    name: podlogs
  - hostPath:
      # path: /var/lib/docker/containers
      path: /data/containerd # containerd的实际目录
      type: DirectoryOrCreate
    name: dockercontainers
  - hostPath:
      path: /var/lib/kubelet/pods
      type: DirectoryOrCreate
    name: kubelet

logconfig

apiVersion: loggie.io/v1beta1
kind: LogConfig
metadata:
  name: java-demo
  namespace: linuxea-dev
spec:
  selector:
    type: pod
    labelSelector:
      namespace: linuxea-dev
      app:  linuxea
  pipeline:
    sources: |
      - type: file
        name: java-demo
        paths:
        - stdout
        fields:
          topic: "java-demo"
          environment: "dev"
    sinkRef: default-kafka
    interceptorRef: default

pod标签

[root@master-01 ~]# kubectl -n linuxea-dev get pod -o yaml |grep labels -1
    generateName: production-java-demo-5cf5b97645-
    labels:
      app: linuxea

重启loggie日志提示: logConfig linuxea-dev/java-demo matches no pods

[root@master-01 ~/loggie-io]# kubectl -n loggie logs -f loggie-k5xqj 
2023-07-31 21:08:42 INF cmd/loggie/main.go:69 > version: v1.4.0-33d018f
2023-07-31 21:08:42 INF cmd/loggie/main.go:78 > real GOMAXPROCS 2
2023-07-31 21:08:42 INF cmd/loggie/main.go:81 > node name: 172.16.100.80
2023-07-31 21:08:42 INF pkg/eventbus/center.go:161 > listener(sink) start
2023-07-31 21:08:42 INF pkg/eventbus/center.go:161 > listener(filesource) start
2023-07-31 21:08:42 INF pkg/eventbus/center.go:161 > listener(filewatcher) start
2023-07-31 21:08:42 INF pkg/eventbus/center.go:161 > listener(pipeline) start
2023-07-31 21:08:42 INF pkg/eventbus/center.go:161 > listener(queue) start
2023-07-31 21:08:42 INF pkg/eventbus/center.go:161 > listener(reload) start
2023-07-31 21:08:42 INF cmd/loggie/main.go:92 > pipelines config path: /opt/loggie/pipeline/*.yml
2023-07-31 21:08:42 INF cmd/loggie/main.go:102 > initial pipelines:
pipelines: []

2023-07-31 21:08:42 INF cmd/loggie/main.go:137 > started Loggie
2023-07-31 21:08:42 INF pkg/core/reloader/reload.go:61 > reloader starting...
W0731 21:08:42.126288       1 client_config.go:617] Neither --kubeconfig nor --master was specified.  Using the inClusterConfig.  This might not work.
2023-07-31 21:08:42 INF pkg/discovery/kubernetes/controller/controller.go:112 > Creating event broadcaster
2023-07-31 21:08:42 INF pkg/discovery/kubernetes/controller/controller.go:147 > Setting up event handlers
2023-07-31 21:08:42 INF pkg/discovery/kubernetes/controller/controller.go:414 > Starting controller
2023-07-31 21:08:42 INF pkg/discovery/kubernetes/controller/controller.go:417 > Waiting for informer caches to sync
2023-07-31 21:08:42 INF pkg/discovery/kubernetes/controller/controller.go:422 > Starting kubernetes discovery workers
2023-07-31 21:08:42 INF pkg/discovery/kubernetes/controller/reconcile.go:238 > logConfig: linuxea-dev/java-demo add or update event received
2023-07-31 21:08:42 INF pkg/discovery/kubernetes/controller/selectpodhandler.go:136 > logConfig linuxea-dev/java-demo matches no pods
2023-07-31 21:08:42 INF pkg/discovery/kubernetes/controller/reconcile.go:238 > logConfig: default/nginx add or update event received
2023-07-31 21:08:42 INF pkg/discovery/kubernetes/controller/selectpodhandler.go:136 > logConfig default/nginx matches no pods
2023-07-31 21:08:42 INF pkg/discovery/kubernetes/controller/reconcile.go:177 > start reconcile sink default-kafka
2023-07-31 21:09:12 INF pkg/eventbus/export/logger/logger.go:141 > [metric]: {"filesource":{},"queue":{},"reload":{"ReloadTotal":0},"sink":{}}

LogConfig标签

[root@master-01 ~/loggie-io]# kubectl -n linuxea-dev get LogConfig
NAME        POD SELECTOR                                  AGE
java-demo   {"app":"linuxea","namespace":"linuxea-dev"}   19m
[root@master-01 ~/loggie-io]# kubectl -n linuxea-dev describe LogConfig | tail -10
  fields:
    topic: "java-demo"
    environment: "dev"

  Selector:
    Label Selector:
      App:        linuxea
      Namespace:  linuxea-dev
    Type:         pod
Events:           <none>

LogConfig *

[root@master-01 ~/loggie-io]# kubectl -n linuxea-dev describe LogConfig | tail -10
  fields:
    topic: "java-demo"
    environment: "dev"

  Selector:
    Label Selector:
      App:        *
      Namespace:  linuxea-dev
    Type:         pod
Events:           <none>

thanks