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

Kernel with CONFIG_IKHEADERS for BPF tools on Kubernetes #8556

Open
alban opened this issue Jun 25, 2020 · 13 comments · Fixed by #8582
Open

Kernel with CONFIG_IKHEADERS for BPF tools on Kubernetes #8556

alban opened this issue Jun 25, 2020 · 13 comments · Fixed by #8582
Labels
area/guest-vm General configuration issues with the minikube guest VM kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/backlog Higher priority than priority/awaiting-more-evidence.

Comments

@alban
Copy link
Contributor

alban commented Jun 25, 2020

I would like the Minikube kernel to be compiled with CONFIG_IKHEADERS.

This is missing from linux_defconfig.

BCC tools need to have access to kernel headers. It can be done either by installing linux-headers packages or by having a kernel compiled with CONFIG_IKHEADERS so that enough information can be retrieved via /sys/kernel/kheaders.tar.xz.

BCC tools are used in Inspektor Gadget, a collection of tools for developers of Kubernetes applications. I would like Inspektor Gadget to support Minikube.

/cc @mauriciovasquezbernal

@tstromberg
Copy link
Contributor

/cc @priyawadhwa

@tstromberg
Copy link
Contributor

tstromberg commented Jun 25, 2020

@alban - building the headers into the kernel is likely the nicer of the two options, but I could go either way.

I'd be happy to approve a PR that does this: https://minikube.sigs.k8s.io/docs/contrib/building/iso/#adding-kernel-modules

@tstromberg tstromberg added area/guest-vm General configuration issues with the minikube guest VM kind/feature Categorizes issue or PR as related to a new feature. labels Jun 25, 2020
@priyawadhwa
Copy link

@alban we have a doc on running BCC tools as a container in minikube, maybe this would work for you until the headers get added to the kernel

https://minikube.sigs.k8s.io/docs/tutorials/ebpf_tools_in_minikube/

@alban
Copy link
Contributor Author

alban commented Jul 12, 2020

This issue should be reopened:

Minikube v1.12.0-beta.1 had Linux 5.4.40 (with CONFIG_IKHEADERS) but Minikube v1.12.0 has Linux 4.19.107 (without CONFIG_IKHEADERS since this build option only appeared in Linux 5.2).

See the revert commit: #8649

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 11, 2020
@alban
Copy link
Contributor Author

alban commented Oct 12, 2020

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 12, 2020
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 10, 2021
@mauriciovasquezbernal
Copy link

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 11, 2021
@alban
Copy link
Contributor Author

alban commented Jan 15, 2021

Additionally, I would like to have CONFIG_DEBUG_INFO_BTF (available from Linux 5.2) to benefit from BPF programs compiled with CO-RE.

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 15, 2021
@mauriciovasquezbernal
Copy link

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 15, 2021
@sharifelgamal sharifelgamal added the lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. label Jul 14, 2021
@sharifelgamal
Copy link
Collaborator

sharifelgamal commented Jul 14, 2021

So this won't be able to be supported until we update the kernel version of the ISO to v5, which we currently cannot for several reasons. I'm freezing this so that it won't get closed while we wait for that.

@pnasrat
Copy link
Contributor

pnasrat commented Oct 17, 2023

I came across this issue while experimenting with eBPF and minikube and it looks like current Minikube has the required support as now on the 5.10 kernel per above mentioned #12707 and this issue may be closable (bar the doc updated mentioned below)

eBPF tools can be shown to work in a number of ways by eBPF tools that support the options requested

Note the blog post Running eBPF Tools in Minikube would need to be updated.

  • Remove the custom iso
  • Use a docker command with volumes for /sys/kernel/kheaders.tar.xz, /sys/fs/bpf
  • Use an updated container as the bcc shipped with 'zlim/bcc:latest uses libbcc Version: 0.8.0-78.git.eba6beb4 from Feb 2019 so doesn't include the necessary to load from loader: Add support for reading kernel headers from /proc iovisor/bcc#2312 - below I've just used a fedora container and installed bcc into it to test

Version info

minikube version
minikube version: v1.31.2
commit: fd7ecd9c4599bef9f04c0986c4a0187f98a4396e
minikube ssh -- uname -r
5.10.57

Updated example of minikube and execsnoop

This means that if a container has mounted /sys/kernel/kheaders.tar.xz and is privileged with the right tools installed (xz, bcc) you can run execsnoop. Note needs xz here to read headers

minikube ssh
docker run --rm   --privileged -v /sys/kernel/kheaders.tar.xz:/sys/kernel/kheaders.tar.xz -it   -v /lib/modules:/lib/modules:ro   -v /sys/fs/bpf:/sys/fs/bpf fedora:latest /bin/bash
dnf install -y xz bcc
cd /usr/share/bcc/tools
./execsnoop
[root@15ccc8e21c91 tools]# ./execsnoop
PCOMM            PID     PPID    RET ARGS
bridge           103806  1041      0 /opt/cni/bin/bridge
portmap          103811  1041      0 /opt/cni/bin/portmap
iptables         103815  2295      0 /usr/sbin/iptables -w 5 -W 100000 -S KUBE-KUBELET-CANARY -t mangle
ip6tables        103816  2295      0 /usr/sbin/ip6tables -w 5 -W 100000 -N KUBE-KUBELET-CANARY -t mangle
ip6tables        103817  2295      0 /usr/sbin/ip6tables -w 5 -W 100000 -N KUBE-KUBELET-CANARY -t nat
runc             103820  8279      0 /usr/bin/runc --root /var/run/docker/runtime-runc/moby --log /var/run/docker/containerd/daemon/io.containerd.runtime.v2.task/moby/651ba58ea0979c86fd16e779b30e6246c85dada4d84bb5dc0ec5547db06 --log-format json exec --process /tmp/runc-process1214458527 --detach --pid-file /var/run/docker/containerd/daemon/io.containerd.runtime.v2.task/moby/651ba58ea0979c86fd16e779b30e6246c85dada4d84bb5dc0ec5547db06 651ba58ea0979c86fd16e779b30e6246c85dada4d84bb5dc0ec5547db06cb964

Kernel config of minikube iso

See also

zgrep -E '(CONFIG_DEBUG_INFO_BTF|CONFIG_IKHEADERS|BPF)' /proc/config.gz
CONFIG_IKHEADERS=y
CONFIG_CGROUP_BPF=y
CONFIG_BPF=y
CONFIG_BPF_LSM=y
CONFIG_BPF_SYSCALL=y
CONFIG_ARCH_WANT_DEFAULT_BPF_JIT=y
# CONFIG_BPF_JIT_ALWAYS_ON is not set
CONFIG_BPF_JIT_DEFAULT_ON=y
# CONFIG_BPF_PRELOAD is not set
CONFIG_NETFILTER_XT_MATCH_BPF=m
# CONFIG_BPFILTER is not set
CONFIG_NET_CLS_BPF=m
CONFIG_NET_ACT_BPF=m
CONFIG_BPF_JIT=y
# CONFIG_BPF_STREAM_PARSER is not set
CONFIG_HAVE_EBPF_JIT=y
CONFIG_DEBUG_INFO_BTF=y
CONFIG_BPF_EVENTS=y
# CONFIG_BPF_KPROBE_OVERRIDE is not set
# CONFIG_TEST_BPF is not set

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/guest-vm General configuration issues with the minikube guest VM kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/backlog Higher priority than priority/awaiting-more-evidence.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants