Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-log_dir和-log_file不生效 #300

Open
liuxue-2000 opened this issue Nov 19, 2024 · 2 comments
Open

-log_dir和-log_file不生效 #300

liuxue-2000 opened this issue Nov 19, 2024 · 2 comments

Comments

@liuxue-2000
Copy link

liuxue-2000 commented Nov 19, 2024

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

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

@yusheng-guo
Copy link

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
Copy link
Author

你好@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants