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

fix(cni): make cni logs available via kubectl logs #4845

Merged
merged 5 commits into from
Aug 17, 2022

Conversation

slonka
Copy link
Contributor

@slonka slonka commented Aug 17, 2022

Signed-off-by: slonka [email protected]

I wrongly assumed that you can't send logs to stdout or stderr. This is not true, logs of "install-cni" can be sent to stderr - kubelet only cares about about stdout. As for "kuma-cni" (the main cni process) to make logs available via "kubectl logs" they need to appear in the daemonset stderr so in this PR we hijack this file descriptor and send logs there.

Example logs:

kubectl logs -n kube-system   kuma-cni-node-gt56p -f
2022-08-17T18:31:13.394Z        DEBUG   install-cni     cni binary file permissions     {"permissions": 493, "path": "/opt/cni/bin/kuma-cni"}

...

2022-08-17T18:31:45.376Z        INFO    kuma-cni        successfully injected iptables rules    {"pod": "demo-app-7458cfdd75-ztgjb", "namespace": "kuma-demo", "podInfraContainerId": "bfe54a320886f00e2f97a6c36cfeabda69a28a0608efbdea0f9adcb291b95389", "ip": "", "containerId": "bfe54a320886f00e2f97a6c36cfeabda69a28a0608efbdea0f9adcb291b95389", "args": "IgnoreUnknown=1;K8S_POD_NAMESPACE=kuma-demo;K8S_POD_NAME=demo-app-7458cfdd75-ztgjb;K8S_POD_INFRA_CONTAINER_ID=bfe54a320886f00e2f97a6c36cfeabda69a28a0608efbdea0f9adcb291b95389"}

...

2022-08-17T18:31:45.565Z        DEBUG   install-cni     config valid    {"file": "/host/etc/cni/net.d/10-flannel.conflist", "name": "cbr0", "plugins": [{"delegate":{"forceAddress":true,"hairpinMode":true,"isDefaultGateway":true},"type":"flannel"},{"capabilities":{"portMappings":true},"type":"portmap"},{"cniVersion":"0.3.1","kubernetes":{"cni_bin_dir":"/bin","exclude_namespaces":["kube-system"],"kubeconfig":"/var/lib/rancher/k3s/agent/etc/cni/net.d/ZZZ-kuma-cni-kubeconfig"},"log_level":"info","name":"kuma-cni","type":"kuma-cni"}]}
2

As you can see we have logs from both install-cni and kuma-cni

Checklist prior to review

  • Link to docs PR or issue -- no docs yet
  • Link to UI issue or PR -- not a UI issue
  • Is the issue worked on linked? -- not reported yet
  • The PR does not hardcode values that might break projects that depend on kuma (e.g. "kumahq" as a image registry) -- no
  • The PR will work for both Linux and Windows, system specific functions like syscall.Mkfifo have equivalent implementation on the other OS -- CNI only works on linux so this is not relevant
  • Unit Tests -- I don't think we have assertions on logs, mentioned in the previous PR
  • E2E Tests --
  • Manual Universal Tests --
  • Manual Kubernetes Tests -- yes on k3d
  • Do you need to update UPGRADE.md? --
  • Does it need to be backported according to the backporting policy? --

@slonka slonka marked this pull request as ready for review August 17, 2022 18:37
@slonka slonka requested a review from a team as a code owner August 17, 2022 18:37
@slonka
Copy link
Contributor Author

slonka commented Aug 17, 2022

@Mergifyio backport release-1.8

@mergify
Copy link
Contributor

mergify bot commented Aug 17, 2022

backport release-1.8

✅ Backports have been created

@slonka slonka enabled auto-merge (squash) August 17, 2022 19:29
@slonka slonka merged commit ef89161 into kumahq:master Aug 17, 2022
mergify bot pushed a commit that referenced this pull request Aug 17, 2022
* fix(cni): make cni logs available via kubectl logs

Signed-off-by: slonka <[email protected]>
(cherry picked from commit ef89161)
mergify bot added a commit that referenced this pull request Aug 18, 2022
fix: make cni logs available via kubectl logs (#4845)

* fix(cni): make cni logs available via kubectl logs

Signed-off-by: slonka <[email protected]>
(cherry picked from commit ef89161)

Co-authored-by: Krzysztof Słonka <[email protected]>
@slonka slonka mentioned this pull request Aug 18, 2022
11 tasks
@lukidzi lukidzi changed the title fix: make cni logs available via kubectl logs fix(cni): make cni logs available via kubectl logs Nov 3, 2022
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

Successfully merging this pull request may close these issues.

2 participants