<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Darek Barecki on Medium]]></title>
        <description><![CDATA[Stories by Darek Barecki on Medium]]></description>
        <link>https://medium.com/@bareckidarek?source=rss-b554baf236a5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*BJvLjwq9zrTbAr_tBLaVqg.png</url>
            <title>Stories by Darek Barecki on Medium</title>
            <link>https://medium.com/@bareckidarek?source=rss-b554baf236a5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 17:30:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bareckidarek/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Test eBPF programs across various Linux Kernel versions]]></title>
            <link>https://medium.com/@bareckidarek/test-ebpf-programs-across-various-linux-kernel-versions-97413d97b426?source=rss-b554baf236a5------2</link>
            <guid isPermaLink="false">https://medium.com/p/97413d97b426</guid>
            <category><![CDATA[ebpf]]></category>
            <category><![CDATA[linux-kernel]]></category>
            <category><![CDATA[qemu]]></category>
            <category><![CDATA[emulation]]></category>
            <category><![CDATA[e2e-testing]]></category>
            <dc:creator><![CDATA[Darek Barecki]]></dc:creator>
            <pubDate>Thu, 21 Nov 2024 17:27:30 GMT</pubDate>
            <atom:updated>2024-12-03T18:13:30.345Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*Vdkofb4eIlOcmBOc_tWpFQ.png" /></figure><h3>Introduction</h3><p>eBPF programs listen to events emitting from the kernel, depending on the used hooks. The technology has been developing since the version 3.15 of Linux, and almost every subsequent release has introduced new features, such as new types of programs and maps. A complete list of supported features per kernel version can be found on the website: <a href="https://github.com/iovisor/bcc/blob/master/docs/kernel-versions.md">https://github.com/iovisor/bcc/blob/master/docs/kernel-versions.md</a>.</p><p>As you can see, there is a big leap between the first version 3.x and the current 6.x. How can you ensure you aren’t out of supported versions when adding new eBPF features to your application? It would be helpful to have the option to test your application on the most popular or required kernel versions.</p><h3>Possibilities</h3><p>To assess an eBPF application across many versions of Linux, we need to install operating systems separately, have the chance to establish an application there and do some prepared tests. What kind of options do we have?</p><ol><li>few disk partitions, every with other operating system installed</li><li>establishing virtual machines with various kernels on the public cloud</li><li>use emulation tools to run guest operating systems, like <strong>QEMU</strong></li></ol><p>The first option isn’t very convenient. We need to allocate a lot of local disk capacity for installations. Testing requires restarting the machine to switch between kernel versions, making the process time-consuming and challenging in CI/CD workflows.</p><p>The second option is much better than the first one. We don’t need to allocate private space, it is possible to integrate with the CI/CD process and allows us to invoke a particular virtual machine only when needed. The disadvantage of that approach is the cost of the virtual machine when in running status, images prepared with various operating systems and VM size.</p><p>The third option sounds the best: run a test on one and only one machine with an emulation of the guest OS for other kernel versions. There is no need to allocate local or public resources, and no additional cost is incurred.</p><h3>Emulation preparations</h3><p>To emulate guest OS, we will use QEMU, an open-source tool (<a href="https://www.qemu.org/">https://www.qemu.org/</a>). QEMU requires two significant options during the run command: kernel and filesystem images.</p><h4>Kernel image</h4><p>You need to do a few steps to compile kernel images for testing. The first one is to choose specific versions. My suggestion is to use at least long-term support versions and download them from the website: <a href="https://www.kernel.org/">https://www.kernel.org/</a></p><p>Next is to prepare the configuration file. This file is needed to build the kernel, which we will do further. By changing properties in that file, you can modify the system configuration and you need to adjust it to your requirements. Based on the <a href="https://github.com/k8spacket/k8spacket/tree/master/tests/e2e/vm/kernels">k8spacket</a> example, we need to enable some features:</p><pre># new config based on defaults for the current ARCH<br>make defconfig<br><br># Rely on the default DWARF (debugging information file format) toolchain&#39;s version<br>./scripts/config --set-val CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT y<br># Enable the bpf() system call that allows to manipulate BPF programs and maps in kernel<br>./scripts/config --set-val CONFIG_BPF_SYSCALL y<br># Compile kernel with debug info, autoset by CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT on 6.x kernels<br>./scripts/config --set-val CONFIG_DEBUG_INFO y<br># Generate BTF type information from DWARF debug info<br>./scripts/config --set-val CONFIG_DEBUG_INFO_BTF y<br><br># enable network classification, autoset by CONFIG_NET_CLS_BPF<br>#./scripts/config --set-val CONFIG_NET_CLS_ACT y<br># BPF-based classifier<br>./scripts/config --set-val CONFIG_NET_CLS_BPF y<br># Ingress/classifier-action qdisc<br>./scripts/config --set-val CONFIG_NET_SCH_INGRESS y<br><br># regenerate config based on new values and defaults<br>make olddefconfig</pre><p>Be aware of selecting particular configs. Some of them depend on others. For example, the field DEBUG_INFO_BTF depends on the field DEBUG_INFO=y. If you mark DEBUG_INFO_BTF only, then it will have no effect. Dependency can be checked through the make menuconfig GUI or by command:</p><pre>❯ cat lib/Kconfig.debug | grep &quot;DEBUG_INFO_BTF&quot; -A10<br>config DEBUG_INFO_BTF<br> bool &quot;Generate BTF typeinfo&quot;<br> depends on DEBUG_INFO<br> depends on !DEBUG_INFO_SPLIT &amp;&amp; !DEBUG_INFO_REDUCED<br> depends on !GCC_PLUGIN_RANDSTRUCT || COMPILE_TEST<br> help<br>   Generate deduplicated BTF type information from DWARF debug info.<br>   Turning this on expects presence of pahole tool, which will convert<br>   DWARF type info into equivalent deduplicated BTF type info.</pre><p>The last step is to build a Linux kernel based on the prepared config file.</p><pre>make -j8</pre><p>If you selected LTS versions only, everything should work as expected because the fresh releases are available. It looks worse for kernels without support like 5.8</p><pre>linux-5.8.18.tar.xz          01-Nov-2020 11:52                109M</pre><p>While building old kernels you may have problems with newer compilers gcc. It could be too fresh for old codes and force you to build the kernel with an old compiler. To build Linux 5.8 I used Ubuntu 18.04 distribution with kernel 5.4 onboard.</p><p>The generated kernel image is available on the path ./arch/x86/boot/bzImage</p><h4>Filesystem image</h4><p>QEMU needs the filesystem image to know how to start the system. Unlike in the docker environment, we have to provide the init system to indicate where booting should start. You can check the full Dockerfile on <a href="https://github.com/k8spacket/k8spacket/blob/master/tests/e2e/vm/filesystem/Dockerfile">GitHub</a>. A few important steps:</p><ul><li>use Ubuntu distribution 22.04 as a base for the filesystem</li><li>install init system — systemd</li><li>install SSH server to have access from the host further</li><li>prepare root user and allow autologin</li><li>allow login as root through SSH</li><li>enable eth0 network interface</li><li>prepare systemd services to run the application and some test-oriented apps</li></ul><p>To build a filesystem image based on Dockerfile you have to run commands from <a href="https://github.com/k8spacket/k8spacket/blob/master/Makefile">Makefile</a>:</p><pre>.ONESHELL:<br>prepare_e2e_filesystem:<br> # build filesystem image and store as tar archive<br> DOCKER_BUILDKIT=1 docker build --output &quot;type=tar,dest=filesystem.tar&quot; .<br> # convert tar to qcow2 image<br> sudo virt-make-fs --format=qcow2 --size=+100M filesystem.tar filesystem-large.qcow2<br> # reduce size of image<br> qemu-img convert filesystem-large.qcow2 -O qcow2 filesystem.qcow2</pre><h3>Start QEMU emulation</h3><p>We are ready to start QEMU emulating a particular Linux kernel.</p><pre>.ONESHELL:<br>start_qemu:<br> # create differential image based on base image | new layer RW, base R only<br> sudo qemu-img create -f qcow2 -b filesystem.qcow2 -F qcow2 filesystem-diff.qcow2<br> sudo qemu-system-x86_64 \<br> # cpu model | host is recommended<br> -cpu host \<br> # guest startup RAM size<br> -m 4G \<br> # symmetric multiprocessing - cores count<br> -smp 4 \<br> # kernel image<br> -kernel ${PWD}/bzImage \<br> # kernel command line <br> #   send guest output to serial port ttyS0 <br> #   use /dev/sda to mount filesystem image<br> -append &quot;console=ttyS0 root=/dev/sda rw&quot; \<br> # filesystem image and image format<br> -drive file=&quot;${PWD}/filesystem-diff.qcow2,format=qcow2&quot; \<br> # create Network Interface Card<br> -net nic \<br> # configure host network<br> #   forwart host port (10022) to guest port (22)<br> -net user,hostfwd=tcp::10022-:22,hostfwd=tcp::16676-:6676,hostfwd=tcp::10443-:443 \<br> # enable kvm full virtualization support<br> -enable-kvm \<br> # where to store QEMU process PID<br> -pidfile qemu.pid \<br> # disable graphical outpu<br> -nographic</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*uAPK7cMtb9n5v8iVbBpmeQ.gif" /></figure><h3>Run tests</h3><p>When VM is started, we can prepare the environment for running tests. We can connect with the VM through SSH and send files and commands to the guest OS.</p><pre>.ONESHELL:<br>prepare_e2e: start_qemu<br> # wait for SSH port available<br> while ! nc -z 127.0.0.1 10022 ; do echo &quot;waiting for ssh&quot;; sleep 1; done<br> # send the k8spacket application to VM<br> sshpass -p root scp -o &#39;StrictHostKeyChecking no&#39; -P 10022 ./k8spacket root@127.0.0.1:/root/k8spacket<br> sshpass -p root scp -o &#39;StrictHostKeyChecking no&#39; -P 10022 ./fields.json root@127.0.0.1:/root/fields.json<br> # start systemd service responsible for the k8spacket application<br> sshpass -p root ssh -p 10022 root@127.0.0.1 &#39;chmod 0655 /root/k8spacket &amp;&amp; systemctl start k8spacket.service&#39;<br> # wait for service to be active <br> while ! sshpass -p root ssh -p 10022 root@127.0.0.1 &#39;systemctl is-active k8spacket.service&#39; ; do echo &quot;waiting for k8spacket service&quot;; sleep 1; done</pre><p>Now is the time to run tests</p><pre>.ONESHELL:<br>e2e: prepare_e2e<br> # run test with environment variables<br> CLIENT_IP=10.0.2.2 HOST_IP=127.0.0.1 GUEST_IP=10.0.2.15 go test -v<br> RC=$$?<br> # print logs from k8spacket service<br> sshpass -p root ssh -p 10022 root@127.0.0.1 &#39;journalctl -u k8spacket -n100&#39;<br> # kill qemu process<br> sudo cat ./vm/filesystem/qemu.pid | sudo xargs kill<br> # return exit code from tests<br> exit $$RC</pre><h3>Run in CI/CD workflow</h3><p>QEMU can be installed on most popular Linux distributions and it is easy to use it as an action in a workflow process, like GitHub actions. <a href="https://github.com/k8spacket/k8spacket/actions">k8spacket</a> uses this approach to test changes in PRs before merging to master.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EeevTapMN1UBNZaTwfQEgA.gif" /></figure><h3>Does it work?</h3><p>Let’s test the negative scenario. k8spacket uses BPF_MAP_TYPE_PERF_EVENT_ARRAY map type to send messages from kernel to userspace. This map is available from version 4.3. Let’s change it to BPF_MAP_TYPE_RINGBUF available from 5.8. k8spacket is tested on kernels 5.4, 5.8, 5.15 and above. After switching we can assume to fail one test - belonging to kernel 5.4</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JHCX3VKUIOGjHpNtZ0dycg.png" /><figcaption><a href="https://github.com/k8spacket/k8spacket/actions/runs/11934928602">https://github.com/k8spacket/k8spacket/actions/runs/11934928602</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HHjemy-EsttY_pRPFDj8WQ.png" /><figcaption><a href="https://github.com/k8spacket/k8spacket/actions/runs/11934928602/job/33265396773">https://github.com/k8spacket/k8spacket/actions/runs/11934928602/job/33265396773</a></figcaption></figure><p>e2e-5.4 was the only test that failed - as expected.</p><h3>Summary</h3><p>Emulation with QEMU is a great and powerful manner to test your eBPF programs across various Linux kernels. It can protect you before going into production and causing damage to some environments with older than in the development process operating systems.</p><h4>References</h4><ul><li><a href="https://mergeboard.com/blog/2-qemu-microvm-docker/">https://mergeboard.com/blog/2-qemu-microvm-docker/</a> - great article about the first steps in QEMU and filesystem built on Dockerfile</li><li><a href="https://vccolombo.github.io/cybersecurity/linux-kernel-qemu-setup/">https://vccolombo.github.io/cybersecurity/linux-kernel-qemu-setup/</a> - about compile a kernel and prepare config file</li><li><a href="https://github.com/grafana/beyla/tree/main/test/vm">https://github.com/grafana/beyla/tree/main/test/vm</a> - similar implementation made for Grafana Beyla</li><li><a href="https://www.qemu.org/docs/master/system/invocation.html">https://www.qemu.org/docs/master/system/invocation.html</a> - QEMU system emulation</li><li><a href="https://www.kernel.org/">https://www.kernel.org/</a> - latest releases</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=97413d97b426" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[k8spacket is fully based on eBPF right now]]></title>
            <link>https://medium.com/@bareckidarek/k8spacket-a-fully-based-on-ebpf-right-now-e72d5383c743?source=rss-b554baf236a5------2</link>
            <guid isPermaLink="false">https://medium.com/p/e72d5383c743</guid>
            <category><![CDATA[tcp]]></category>
            <category><![CDATA[observability]]></category>
            <category><![CDATA[tls]]></category>
            <category><![CDATA[ebpf]]></category>
            <category><![CDATA[grafana]]></category>
            <dc:creator><![CDATA[Darek Barecki]]></dc:creator>
            <pubDate>Sat, 09 Mar 2024 15:19:58 GMT</pubDate>
            <atom:updated>2024-09-29T16:29:25.294Z</atom:updated>
            <content:encoded><![CDATA[<h3>k8spacket - a fully based on eBPF right now</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*YdFlLRZnNmDDxYOa9kBf7A.png" /></figure><p>What is k8spacket? It is the tool to collect information about TCP traffic and TLS connection metadata in the Kubernetes cluster using eBPF and visualize it in Grafana. <a href="https://killercoda.com/k8spacket/scenario/k8spacket">Try on Killercoda</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aFWQ0t4H5bADqLPbzLeIRQ.png" /><figcaption>k8spacket — node graph</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5qNWg-3p6OxjH59bxZOZ2A.png" /><figcaption>k8spacket — TLS connections &amp; certificates</figcaption></figure><p>Check <a href="https://medium.com/@bareckidarek/tcp-packets-traffic-visualization-for-kubernetes-by-k8spacket-and-grafana-bb87cb106f30">this article</a> for more details.</p><p>Before version 2.0.0, k8spacket used the gopacket Google library to collect information about TCP packets. The application could process replicated TCP raw data in user space with that library. It was a heavy and inefficient process regarding high network traffic inside the cluster.</p><p><strong>eBPF</strong> is a Linux kernel technology that allows processing data in kernel space and sending events to user space with only the necessary details. There are a few methods to attach the eBPF program to the kernel calls, and k8spacket uses two of them:</p><ul><li><strong>tracepoint </strong><strong>inet_sock_set_state</strong> — to get information about TCP connections inside the cluster</li><li><strong>traffic control and queueing discipline filters on ingress and egress</strong> — to collect information about the TLS handshake process</li></ul><p>Let’s go deeper and understand what’s happening with eBPF programs used in k8spacket.</p><h3>Tracepoint inet_sock_set_state</h3><p>k8spacket works as a DaemonSet resource on each Kubernetes cluster node. It has to sniff TCP connections on every network interface regarding all containers run on the node. An important fact is that the container could be client-side or server-side in the established TCP connection. k8spacket has to be vigilant at that point. The eBPF program listens to two types of TCP states to cover this.</p><ul><li><strong>TCP_SYN_SENT</strong> — container as a TCP client</li><li><strong>TCP_SYN_RECV</strong> — container as a TCP server</li></ul><h3>TCP_SYN_SENT</h3><p>When a container wants to connect to the TCP server, it sends a <strong>SYN</strong> packet to start setting up the connection. At the same time, the Linux TCP stack sets the state to <strong>TCP_SYN_SENT</strong>. k8spacket is attached to the tracepoint, which emits an event about changing the state. That’s how we know the connection to the server has been started and can store that information for further operations.</p><h3>TCP_SYN_RECV</h3><p>When someone from the outside (it can be another container in the cluster or even a client from the outside of the cluster network) wants to connect to the sniffed container, it must send a <strong>SYN</strong> packet to the receiver. When the TCP server gets this packet, after a few complicated operations (<a href="https://levelup.gitconnected.com/deep-dive-into-tcp-connection-establishment-process-f6cfb7b4e8e1"><em>great article about it</em></a><em>),</em> changes the state to <strong>TCP_SYN_RECV</strong>. Now, k8spacket knows: <strong><em>ok, someone is knocking, let’s store it and wait for what will happen</em></strong>.</p><h3>TCP_CLOSE</h3><p>The last TCP state, interesting for k8spacket, is <strong>TCP_CLOSE</strong>. It’s a common state for both the client and the server side. When a TCP connection lands in that state, k8spacket receives a signal: <strong><em>conversation finished so we can collect data and send them to the user space</em></strong>.</p><p>To sum up, using only one tracepoint <strong>inet_sock_set_state</strong>, we get information about all TCP connections in the cluster node.</p><h3>Traffic Control and queueing discipline filters</h3><p>The second skill of k8spacket is collecting information about TLS connections. Before the eBPF approach, as mentioned earlier, it was a heavy and inefficient process concerning copying all packets to user space.</p><p>Regarding eBPF, there are two main approaches to sniffing packet data:</p><ul><li><strong>TC</strong> (Traffic Control)</li><li><strong>XDP</strong> (eXpress Data Path)</li></ul><p>k8spacket uses a traffic control approach because of two aspects:</p><ul><li>XDP works for incoming packets only</li><li>XDP is supported by a long but still not complete list of network drivers (<a href="https://github.com/iovisor/bcc/blob/master/docs/kernel-versions.md#xdp"><em>supported network drivers</em></a>)</li></ul><p>With the traffic control (TC) subsystem, we can attach ingress and egress filters to sniff incoming and outgoing TCP packets. k8packet uses the <strong>clsact</strong> queueing discipline to attach the eBPF program as a filter (<a href="https://qmonnet.github.io/whirl-offload/2020/04/11/tc-bpf-direct-action/#the-clsact-qdisc"><em>see more info about clsact</em></a>). The program waits for TCP packets. When a packet arrives, we check if the message belongs to a TLS handshake process. k8spacket is interested in two types of messages (<strong>clientHello</strong> and <strong>serverHello</strong>) and gets necessary data only from them. After all, it sends collected data to user space for further processing.</p><h3>Collecting TLS domain certificates</h3><p>eBPF program collects metadata about TLS handshake operation but without certificate raw data. It is pointless to do it in kernel space and send it to user space because of the amount of data and limitation of supported versions (less than <strong>TLS 1.3</strong> because of encryption server handshake data from version 1.3). It could be done in user space by the eBPF program as well, but there are many libraries for TLS encryption, like <em>OpenSSL</em>, <em>LibreTLS</em>, <em>BoringTLS</em>, <em>GnuTLS</em>, <em>GoTLS</em>, etc. Development and maintenance would be a difficult task.</p><p>For now, k8spacket uses scrapping with cache for server certificates using the Golang tls package and <strong>tls.Dial()</strong> function. As a rarely fluctuating factor, a scraped certificate stays in the cache for 24 hours (could be configured).</p><h3>Limitations</h3><p>k8spacket uses <strong>ring buffer map</strong>, which forces using Linux kernel version at least <strong>5.8</strong> (<a href="https://github.com/iovisor/bcc/blob/master/docs/kernel-versions.md#map-types"><em>BPF Features by Linux Kernel Version</em></a>).</p><h3>New features</h3><ul><li>Dashboard <strong>k8spacket — TLS certificate expiration</strong> shows the remaining time until the certificates expire. By variable <strong>Past interval to analyze</strong>, you can narrow or expand the scope of data to analyze. Data sorted by expiring earliest first. It’s easy to build alerts based on the certificate expiration date. See more raw metrics in the dashboard <strong>k8spacket — TLS metrics</strong></li></ul><figure><img alt="k8spacket — TLS certificate expiration" src="https://cdn-images-1.medium.com/max/1024/1*6Q8rbc_kRmGKL69v5b0L4A.gif" /><figcaption>k8spacket — TLS certificate expiration</figcaption></figure><ul><li>Two principal k8spacket dashboards (<strong>k8spacket — node graph</strong> and <strong>k8spacket — TLS connections &amp; certificates</strong>) are sensitive to Grafana time range control now. You can show cluster TCP traffic or TLS connections, f.e., for the last 5 minutes.</li></ul><figure><img alt="k8spacket — node graph" src="https://cdn-images-1.medium.com/max/1024/1*drNPGnlaXHsizapa2jPaYw.gif" /><figcaption>k8spacket — node graph</figcaption></figure><figure><img alt="k8spacket — TLS connections &amp; certificates" src="https://cdn-images-1.medium.com/max/1024/1*4vqir8Z9v8WDvIhe1ZUXsg.gif" /><figcaption>k8spacket — TLS connections &amp; certificates</figcaption></figure><h3>Summary</h3><p>If you work with the Kubernetes cluster on Linux distribution and the kernel version is at least 5.4, upgrade or try the new k8spacket. It is faster, more efficient, and requires less memory than older versions.</p><p>The source code can be found at <a href="https://github.com/k8spacket/k8spacket">github.com/k8spacket</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e72d5383c743" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[k8spacket — are your TLS connections inside the cluster still secure?]]></title>
            <link>https://medium.com/@bareckidarek/k8spacket-are-your-tls-connections-inside-the-cluster-still-secure-4a114ff75573?source=rss-b554baf236a5------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a114ff75573</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[tls]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[grafana]]></category>
            <category><![CDATA[observability]]></category>
            <dc:creator><![CDATA[Darek Barecki]]></dc:creator>
            <pubDate>Sat, 10 Dec 2022 17:49:48 GMT</pubDate>
            <atom:updated>2024-03-10T14:47:16.108Z</atom:updated>
            <content:encoded><![CDATA[<h3>k8spacket — are your TLS connections inside the cluster still secure?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*KPJqU0BKxQMQiH7gQ2yqdw.png" /></figure><p>Don’t you know the k8spacket tool yet? Check <a href="https://medium.com/@bareckidarek/tcp-packets-traffic-visualization-for-kubernetes-by-k8spacket-and-grafana-bb87cb106f30">this article</a>.</p><p>How long ago did you check if TLS communications in the cluster were secure? You have TLS, so you are secured — is this information good enough for you? Do you know when and where your services or third-party libraries establish TLS communication inside and outside the cluster?</p><p><strong>Read the article “</strong><a href="https://medium.com/@bareckidarek/k8spacket-a-fully-based-on-ebpf-right-now-e72d5383c743"><strong><em>k8spacket — a fully based on eBPF right now</em></strong></a><strong>” and see how </strong><strong>k8spacket changed after switching to eBPF.</strong></p><h3>Description</h3><p>k8spacket has a new feature that helps you understand and monitor the phase of establishing secure connections. New metrics show which workloads establish TLS connections and what kind of version and cipher suites they use. There isn’t a better option to understand the TLS versions and why the cipher suite is so significant for encryption than visit and read <a href="https://howhttps.works/">how HTTPS works comics</a>. To go deeply about cipher suites, see <a href="https://www.keyfactor.com/blog/cipher-suites-explained/">this article</a>.</p><p>In short words:</p><ul><li>A TLS version tells about the freshness of secure protocol. It’s better secured and less vulnerable in the recent version.</li><li>A cipher suite contains ciphers used to establish a secure connection and encrypt transmitted data.</li></ul><p>In the Kubernetes cluster, there is a lot of secure connection established, not always designed by you, f.e.</p><ul><li>monitoring stack to external webhook, like slack or opsgenie</li><li>third-party libraries to external partners, like getting secrets from Key Management Service</li><li>any statistics sent through tools installed in the cluster like Grafana(<a href="https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/#reporting_enabled">see here</a>)</li><li>incoming traffic from the Internet</li></ul><p>k8spacket can pick TLS connections inside the K8S cluster, decode TLS parameters, and show them in the Grafana. There are two dashboards available about it currently:</p><ul><li>with Prometheus time-series metrics — get information about called domains, used TLS version and cipher suite</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R7yj16vP8EglXoZ6d-F8Mg.gif" /></figure><ul><li>with a table-oriented panel to show more details about the server certificate chain and client-supported TLS versions</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4vqir8Z9v8WDvIhe1ZUXsg.gif" /></figure><ul><li>IP, name, and namespace of TLS client workload</li><li>destination name, IP, domain, and port of the TLS server</li><li>supported TLS versions and cipher suites by the client</li><li>chosen TLS version and cipher suite by the server</li></ul><h3>Installation</h3><p>To install k8spacket, you need to have Helm and Grafana installed. Additionally, the tls-parser extension requires a <a href="https://grafana.com/grafana/plugins/marcusolsson-json-datasource/">JSON API plugin</a>.</p><p>See all installation steps <a href="https://k8spacket.github.io/k8spacket/#installation">here</a>.</p><h3>Additional note</h3><p>Since version 1.0.0 of k8spacket, the architecture has changed to pluggable. Now, you can write custom extensions with respect an interface of <a href="https://github.com/k8spacket/plugin-api">plugin-api</a> and apply them through the helm configuration <a href="https://github.com/k8spacket/k8spacket-helm-chart/blob/master/charts/k8spacket/values.yaml">values file</a></p><h3>Summary</h3><p>If you want to check TLS connection parameters used by the clients in the Kubernetes cluster written by you or used by a third-party library, try the k8spacket tls-parser plugin.</p><p>Find the source code at <a href="https://github.com/k8spacket">github.com/k8spacket</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a114ff75573" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TCP packets traffic visualization for kubernetes by k8spacket and Grafana]]></title>
            <link>https://medium.com/@bareckidarek/tcp-packets-traffic-visualization-for-kubernetes-by-k8spacket-and-grafana-bb87cb106f30?source=rss-b554baf236a5------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb87cb106f30</guid>
            <category><![CDATA[grafana]]></category>
            <category><![CDATA[tcp]]></category>
            <category><![CDATA[observability]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Darek Barecki]]></dc:creator>
            <pubDate>Tue, 09 Aug 2022 11:34:37 GMT</pubDate>
            <atom:updated>2024-03-10T14:46:25.016Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*k-8QKTG4GVYj2sxS_vJIGg.png" /></figure><p>Do you know what your k8s cluster does when you are not watching? Who establishes the TCP communication with him? Who is called by him, e.g., from third-party libraries?</p><p>With k8spacket and Grafana, you can visualize TCP traffic in the cluster. See how your workloads communicate together. Inspect how many connections are established, how many bytes are exchanged, and how long these connections are active.</p><p><strong>Read the article “</strong><a href="https://medium.com/@bareckidarek/k8spacket-a-fully-based-on-ebpf-right-now-e72d5383c743"><strong><em>k8spacket — a fully based on eBPF right now</em></strong></a><strong><em>”</em> and see how </strong><strong>k8spacket changed after switching to eBPF.</strong></p><h3>Description</h3><p>k8spacket is the tool written in Golang and uses the gopacket third-party library to sniff TCP packets on your workloads (incoming and outgoing). It creates TCP listeners on running container network interfaces. When Kubernetes creates a new container, the CNI plugin is responsible for giving the possibility to communicate either with other containers or from cluster to the world. The most common approach uses linux namespace to isolate networks and veth pair to connect the isolated namespace with the bridge. If you want to know more, please refer to a great article written by Safak (<a href="https://dev.to/polarbit/how-docker-container-networking-works-mimic-it-using-linux-network-namespaces-9mj">How Docker Container Networking Works - Mimic It Using Linux Network Namespaces</a>). Besides type bridge, the CNI plugin can use other types (vlan, ipvlan, macvlan), but all create a network interface for container linux namespace, which is the main handle for k8spacket sniffers.</p><p>k8spacket is running with the option</p><pre>hostNetwork: true</pre><p>to eliminate the isolation mentioned earlier. It collects TCP streams, processes data, and exposes results through API to be used by Grafana.</p><p>Additionally,</p><ul><li>k8spacket is a Kubernetes API client and can resolve sniffed workload as a cluster resource name (Pods and Services) visible on visualization.</li><li>It is launched as a DaemonSet to listen to network interfaces on all nodes.</li><li>Implemented watcher checks every 10s (default) if there is a new (or old) network interface to observe (or forget).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aFWQ0t4H5bADqLPbzLeIRQ.png" /></figure><p>In addition to showing a graph of your cluster resources, it also exposes Prometheus metrics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dzxrCFauzKuoyC9gygjjow.png" /></figure><h3>Installation</h3><p>To install k8spacket, you need to have Helm and Grafana installed. Additionally, the tool requires Hamad&#39;s Node Grafana API plugin (<a href="https://grafana.com/grafana/plugins/hamedkarbasi93-nodegraphapi-datasource/">Node Graph API</a>).<br>See all installation steps <a href="https://k8spacket.github.io/k8spacket/#installation">here</a>.</p><h3>Usage</h3><h4>Types of stats</h4><ul><li>connection - helps understand how many connections are established between your workloads and from/to outside clients. It tells you which sockets stay open and could cause problems. It is helpful when you are behind some SNAT gateway with port exhaustion (e.g., Azure AKS).</li><li>bytes - shows how many bytes are sent or received by workloads.</li><li>duration - calculates the lifetime of connections.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FLQpQwmFWr0-nsk-ijzTrQ.gif" /></figure><h4>Filters</h4><ul><li>by namespace - select one or more k8s namespaces</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3bGPSTXjmiSYQzgAqX1ZEw.gif" /></figure><ul><li>by names included - select workload names for visualization</li><li>by names excluded - exclude workload names from visualization</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oJUqgwokFNUTlkehD3EJfw.gif" /></figure><h3>Summary</h3><p>If you want to know what is going on with TCP traffic in your cluster, try k8spacket. Investigation about cutting the traffic (network policy) could be painless when you see a leak of packages outside. Make a review of third-party libraries to check connections with the world.</p><p>The source code can be found at <a href="https://github.com/k8spacket/k8spacket">github.com/k8spacket</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb87cb106f30" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>