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

node: retrieve logs from journal socket #69

Merged
merged 3 commits into from Jan 22, 2021

Conversation

pires
Copy link
Member

@pires pires commented Jan 22, 2021

... instead of doing it through journalctl CLI.

This is the first step to address #5. What's missing and will eventually be addressed in separate PRs?

  • follow mode support
  • retrieving logs pertaining to the current Pod, in case a homonym Pod once existed for which journald still has entries for.

Some examples of a Pod named hello, that simply prints date, every 5 seconds:

kubectl logs --since:

$ k logs --since 20s hello
Thu Jan 21 23:20:52 WET 2021
Thu Jan 21 23:20:57 WET 2021
Thu Jan 21 23:21:02 WET 2021
Thu Jan 21 23:21:07 WET 2021

$k logs --since 1m hello
Thu Jan 21 23:20:17 WET 2021
Thu Jan 21 23:20:22 WET 2021
Thu Jan 21 23:20:27 WET 2021
Thu Jan 21 23:20:32 WET 2021
Thu Jan 21 23:20:37 WET 2021
Thu Jan 21 23:20:42 WET 2021
Thu Jan 21 23:20:47 WET 2021
Thu Jan 21 23:20:52 WET 2021
Thu Jan 21 23:20:57 WET 2021
Thu Jan 21 23:21:02 WET 2021
Thu Jan 21 23:21:07 WET 2021
Thu Jan 21 23:21:12 WET 2021

kubectl logs --timestamps - by default, kubectl has timestamps disabled:

$ k logs --since 20s --timestamps hello
2021-01-21 23:21:02.231042 +0000 WET Thu Jan 21 23:21:02 WET 2021
2021-01-21 23:21:07.23385 +0000 WET Thu Jan 21 23:21:07 WET 2021
2021-01-21 23:21:12.236292 +0000 WET Thu Jan 21 23:21:12 WET 2021
2021-01-21 23:21:17.238822 +0000 WET Thu Jan 21 23:21:17 WET 2021

kubectl logs --tail:

k logs --tail 10 hello
Thu Jan 21 23:22:07 WET 2021
Thu Jan 21 23:22:12 WET 2021
Thu Jan 21 23:22:17 WET 2021
Thu Jan 21 23:22:22 WET 2021
Thu Jan 21 23:22:27 WET 2021
Thu Jan 21 23:22:32 WET 2021
Thu Jan 21 23:22:37 WET 2021
Fri Jan 22 09:07:06 WET 2021
Fri Jan 22 09:07:11 WET 2021
Fri Jan 22 09:07:16 WET 2021

$ k logs --tail 2 hello
Fri Jan 22 09:07:21 WET 2021
Fri Jan 22 09:07:26 WET 2021

... instead of doing it through journalctl CLI.

This is the first step to address virtual-kubelet#5

Signed-off-by: Pires <pjpires@gmail.com>
@pires pires added the enhancement New feature or request label Jan 22, 2021
@pires pires requested a review from miekg January 22, 2021 11:00
This happens because go-systemd binds systemd C code.

Signed-off-by: Pires <pjpires@gmail.com>
Signed-off-by: Pires <pjpires@gmail.com>
@miekg miekg merged commit 5443b6f into virtual-kubelet:main Jan 22, 2021
@pires pires deleted the feature/journald_logs branch January 22, 2021 12:56
@miekg miekg mentioned this pull request Feb 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants