AliyunContainerService / kube-eventer

kube-eventer emit kubernetes events to sinks
Apache License 2.0
1.01k stars 278 forks source link

-log_dir和-log_file不生效 #300

Open liuxue-2000 opened 1 week ago

liuxue-2000 commented 1 week ago

配置如下,在镜像中已授权,并使用root启动 image image

是还需要其他权限?还是哪里配置不对呢

yusheng-guo commented 1 week ago

Hi @liuxue-2000 , I have carefully reviewed your question.

First, in klog v1.0.0, the options --log_dir and --log_file cannot be used simultaneously. You can find more details here.

Second, if you built the image using the project's Dockerfile or Dockerfile.multi, please note that the image runs the program with non-root permissions. This means it won't work even if you start it with root permissions.

Lastly, to save logs to a specific directory or file, you will need to use Kubernetes Storage. You can find more information here.

Below is an example of a Deployment configuration that saves logs to a host directory:

containers:
  - command:
      - /kube-eventer
      - '--source=<source>'
      - >-
        --sink=<sink>
      - '--log_dir=/var/log/kube-eventer'
    ...
    volumeMounts:
      - mountPath: /var/log/kube-eventer
        name: volume-1732240867108
...
volumes:
  - hostPath:
      path: /tmp
      type: ''
    name: volume-1732240867108
liuxue-2000 commented 1 week ago

你好@liuxue-2000,我仔细审阅了您的问题。

首先,在 klog v1.0.0 中,选项--log_dir--log_file不能同时使用。你可以在这里找到更多详细信息。

其次,如果你使用项目的DockerfileDockerfile.multi构建了镜像,请注意,镜像以非 root 权限运行程序。这意味着即使你以 root 权限启动它,它也不会起作用。

最后,要将日志保存到特定目录或文件,您需要使用 Kubernetes Storage。您可以在此处找到更多信息。

以下是将日志保存到主机目录的部署配置示例:

containers:
  - command:
      - /kube-eventer
      - '--source=<source>'
      - >-
        --sink=<sink>
      - '--log_dir=/var/log/kube-eventer'
    ...
    volumeMounts:
      - mountPath: /var/log/kube-eventer
        name: volume-1732240867108
...
volumes:
  - hostPath:
      path: /tmp
      type: ''
    name: volume-1732240867108

I understand, thank you