<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Roman Belshevitz</title>
    <description>The latest articles on DEV Community by Roman Belshevitz (@rbelshevitz).</description>
    <link>https://dev.to/rbelshevitz</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F740774%2F6bfe5f6f-8b94-487a-b524-b407e715aefc.png</url>
      <title>DEV Community: Roman Belshevitz</title>
      <link>https://dev.to/rbelshevitz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rbelshevitz"/>
    <language>en</language>
    <item>
      <title>bfban: Dynamic IP Blocking with bpfilter and eBPF</title>
      <dc:creator>Roman Belshevitz</dc:creator>
      <pubDate>Wed, 18 Nov 2026 13:46:16 +0000</pubDate>
      <link>https://dev.to/rbelshevitz/bfban-dynamic-ip-blocking-with-bpfilter-and-ebpf-14ml</link>
      <guid>https://dev.to/rbelshevitz/bfban-dynamic-ip-blocking-with-bpfilter-and-ebpf-14ml</guid>
      <description>&lt;p&gt;I’ve returned to the topic of eBPF after 4 years, but this article won’t be about Cilium.&lt;/p&gt;

&lt;p&gt;Well, I recently came across the &lt;code&gt;bpfilter&lt;/code&gt; project and started wondering whether it could be useful for something very practical: maintaining a dynamic blocklist on a Linux server.&lt;/p&gt;

&lt;p&gt;The idea was not to build yet another complete firewall. Linux already has excellent tools for that. I was more interested in a narrower problem: can a small service accept block decisions from Fail2ban, CrowdSec, an operator, or a threat feed and apply them directly in the kernel?&lt;/p&gt;

&lt;p&gt;When a Linux server is under attack, the first question is usually simple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Which addresses should be blocked?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The second question is more complicated:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Where should those blocks be enforced?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The usual Linux answer is familiar: Fail2ban makes a decision, and nftables or iptables applies it.&lt;/p&gt;

&lt;p&gt;This line of thinking led to &lt;a href="https://github.com/rbelshevitz/bfban/" rel="noopener noreferrer"&gt;&lt;code&gt;bfban&lt;/code&gt;&lt;/a&gt;: dynamic IP and CIDR blocklists managed by a small daemon and applied through bpfilter and eBPF.&lt;/p&gt;

&lt;p&gt;I did not want to present it as a replacement for nftables. The goal was much more specific:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Can a Linux service maintain a changing blocklist and apply it inside the kernel, with expiration times (TTLs), CIDR support, and state recovery after a restart?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The answer is yes — at least for the functionality tested so far.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem with mixing the roles
&lt;/h2&gt;

&lt;p&gt;Several tools are often mentioned together even though they do different jobs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fail2ban reads logs and decides when an address should be banned.&lt;/li&gt;
&lt;li&gt;CrowdSec can make similar decisions using its own detection and reputation mechanisms.&lt;/li&gt;
&lt;li&gt;nftables and iptables enforce firewall rules.&lt;/li&gt;
&lt;li&gt;bpfilter is another packet-filtering engine that can load chains and sets as eBPF programs.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;bfband&lt;/code&gt; manages dynamic bans, expiration times, and persistent state.&lt;/li&gt;
&lt;li&gt;XDP and Netfilter are kernel attachment points where filtering can happen.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A simple workflow looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Fail2ban / CrowdSec / threat feed / operator
                    |
                    v
         bfband Unix-socket daemon
                    |
                    v
        bpfilter chain and dynamic sets
                    |
                    v
             packet accepted or dropped
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The important distinction is that &lt;code&gt;bfban&lt;/code&gt; is not a log detector.&lt;/p&gt;

&lt;p&gt;It does not decide that an SSH login is suspicious. It receives a decision from Fail2ban, CrowdSec, an operator, or another security system and applies that decision.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where eBPF is involved
&lt;/h2&gt;

&lt;p&gt;The daemon is not in the packet path.&lt;/p&gt;

&lt;p&gt;When an administrator adds an address:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo /usr/sbin/bfbandctl add 203.0.113.10 60
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;bfband&lt;/code&gt; updates a bpfilter set. bpfilter then loads the filtering chain into the kernel as an eBPF program with associated maps.&lt;/p&gt;

&lt;p&gt;After that, packets are checked in the kernel. A packet does not start a new process, call the daemon, or pass through a shell command for every lookup.&lt;/p&gt;

&lt;p&gt;This separation is important:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Control plane:
bfbandctl -&amp;gt; Unix socket -&amp;gt; bfband -&amp;gt; bpfilter set

Packet path:
incoming packet -&amp;gt; kernel hook -&amp;gt; eBPF rule -&amp;gt; ACCEPT or DROP
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The daemon manages the data. The kernel makes the packet decision.&lt;/p&gt;

&lt;h2&gt;
  
  
  Is bfban a replacement for nftables?
&lt;/h2&gt;

&lt;p&gt;No — not as a complete firewall.&lt;/p&gt;

&lt;p&gt;Use nftables when the server needs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;stateful firewall rules;&lt;/li&gt;
&lt;li&gt;NAT;&lt;/li&gt;
&lt;li&gt;routing and forwarding policy;&lt;/li&gt;
&lt;li&gt;service and port policy;&lt;/li&gt;
&lt;li&gt;connection tracking;&lt;/li&gt;
&lt;li&gt;complex combinations of firewall conditions;&lt;/li&gt;
&lt;li&gt;a mature general-purpose firewall configuration.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;bfban&lt;/code&gt; has a narrower purpose: maintaining a dynamic list of IP addresses and networks that should be blocked.&lt;/p&gt;

&lt;p&gt;A useful way to think about it is this:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task&lt;/th&gt;
&lt;th&gt;Suitable component&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Detect brute-force login attempts&lt;/td&gt;
&lt;td&gt;Fail2ban&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Maintain a general firewall policy&lt;/td&gt;
&lt;td&gt;nftables&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Maintain a dynamic blocklist from several sources&lt;/td&gt;
&lt;td&gt;bfban&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Apply a packet decision inside the kernel&lt;/td&gt;
&lt;td&gt;bpfilter/eBPF&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Drop packets at the earliest supported ingress point&lt;/td&gt;
&lt;td&gt;XDP&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If a direct Fail2ban-to-nftables setup already solves the problem, there may be no reason to add &lt;code&gt;bfban&lt;/code&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The point of the project is not to replace every firewall. The point is to provide a focused blocklist-management layer with a different enforcement backend.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  What does the proof of concept demonstrate?
&lt;/h2&gt;

&lt;p&gt;The proof of concept demonstrates several concrete properties:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;IPv4 and IPv6 address handling;&lt;/li&gt;
&lt;li&gt;CIDR prefix handling;&lt;/li&gt;
&lt;li&gt;dynamic updates to kernel-backed sets;&lt;/li&gt;
&lt;li&gt;temporary bans with an expiration time (TTL);&lt;/li&gt;
&lt;li&gt;automatic removal after expiration;&lt;/li&gt;
&lt;li&gt;preservation of the original expiration time after a daemon restart;&lt;/li&gt;
&lt;li&gt;real packet drops, not only changes in a user-space list;&lt;/li&gt;
&lt;li&gt;integration with a bpfilter chain attached to &lt;code&gt;NF_LOCAL_IN&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That last point matters.&lt;/p&gt;

&lt;p&gt;It is easy to show that a command accepted an IP address. It is more useful to show that traffic from that address actually stops, and that traffic starts working again after the TTL expires.&lt;/p&gt;

&lt;h2&gt;
  
  
  A real integration test
&lt;/h2&gt;

&lt;p&gt;The test environment was:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Rocky Linux 10;&lt;/li&gt;
&lt;li&gt;Linux kernel 6.12;&lt;/li&gt;
&lt;li&gt;bpfilter 0.8.0.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;First, the daemon and the empty kernel sets were checked:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo /usr/sbin/bfbandctl ping
sudo /usr/sbin/bfbandctl list
sudo bfcli ruleset get
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then a documentation address was blocked for 60 seconds:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo /usr/sbin/bfbandctl add 203.0.113.10 60
sudo /usr/sbin/bfbandctl list
sudo bfcli ruleset get
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The address appeared in both places:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the daemon's list;&lt;/li&gt;
&lt;li&gt;the kernel-side &lt;code&gt;banlist4&lt;/code&gt; set.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After the TTL expired, the address disappeared from both lists.&lt;/p&gt;

&lt;p&gt;The next test used a second machine on the network. Its IP address was blocked for 70 seconds. ICMP packets stopped arriving. After approximately 70 seconds, ping started working again without manual removal.&lt;/p&gt;

&lt;p&gt;That verified the complete cycle:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ADD -&amp;gt; DROP -&amp;gt; TTL expiration -&amp;gt; REMOVE -&amp;gt; ACCEPT
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The restart test was more important.&lt;/p&gt;

&lt;p&gt;The test address was blocked for 180 seconds. After approximately 30 seconds, the daemon was restarted:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo systemctl restart bfband
sudo /usr/sbin/bfbandctl list
sudo bfcli ruleset get
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The block remained active after the restart. It disappeared roughly 180 seconds after the original &lt;code&gt;ADD&lt;/code&gt;, not 180 seconds after the restart.&lt;/p&gt;

&lt;p&gt;That means the daemon restored the existing state without extending the ban.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why use a daemon instead of direct firewall commands?
&lt;/h2&gt;

&lt;p&gt;A shell command can add an address to a firewall set. That may be enough for a small setup.&lt;/p&gt;

&lt;p&gt;A daemon becomes useful when several systems need to submit decisions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fail2ban;&lt;/li&gt;
&lt;li&gt;CrowdSec;&lt;/li&gt;
&lt;li&gt;an operator;&lt;/li&gt;
&lt;li&gt;an abuse-response script;&lt;/li&gt;
&lt;li&gt;a threat-intelligence feed;&lt;/li&gt;
&lt;li&gt;an internal security service.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead of every producer implementing its own firewall update logic, they can use one Unix-socket API.&lt;/p&gt;

&lt;p&gt;The daemon can also centralize:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;TTL handling;&lt;/li&gt;
&lt;li&gt;state persistence;&lt;/li&gt;
&lt;li&gt;restart recovery;&lt;/li&gt;
&lt;li&gt;duplicate handling;&lt;/li&gt;
&lt;li&gt;CIDR validation;&lt;/li&gt;
&lt;li&gt;bounded batch updates;&lt;/li&gt;
&lt;li&gt;reconciliation between user-space state and kernel state.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is the main value of &lt;code&gt;bfban&lt;/code&gt;: not the existence of another &lt;code&gt;add IP&lt;/code&gt; command, but the lifecycle around a changing blocklist.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a threat feed?
&lt;/h2&gt;

&lt;p&gt;A threat feed is not a database containing every malicious bot on the Internet.&lt;/p&gt;

&lt;p&gt;It is usually a curated list of indicators associated with a specific threat or abuse pattern:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;IP addresses;&lt;/li&gt;
&lt;li&gt;CIDR networks;&lt;/li&gt;
&lt;li&gt;malicious hosting ranges;&lt;/li&gt;
&lt;li&gt;command-and-control infrastructure;&lt;/li&gt;
&lt;li&gt;addresses observed in phishing, malware, or scanning activity.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An IOC means “indicator of compromise”. In this context, an IOC may simply be an IP address or CIDR network that another system has already identified as suspicious.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;bfban&lt;/code&gt; can apply such a list. It does not discover or verify the indicators itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is XDP?
&lt;/h2&gt;

&lt;p&gt;XDP stands for eXpress Data Path.&lt;/p&gt;

&lt;p&gt;It is an early Linux hook for incoming packets. On a supported interface, an&lt;br&gt;
XDP program can make a decision before the packet enters most of the normal&lt;br&gt;
network stack.&lt;/p&gt;

&lt;p&gt;bpfilter documents XDP as an early receive hook, before the regular Linux network stack processes the packet. See the &lt;a href="https://bpfilter.io/usage/explanation/hooks.html" rel="noopener noreferrer"&gt;bpfilter hook documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;bfban&lt;/code&gt; can attach its filtering chain to XDP:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo env &lt;span class="nv"&gt;BFBAN_HOOK&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'BF_HOOK_XDP{ifindex=2}'&lt;/span&gt; \
  /usr/sbin/bfban init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, XDP is not automatically the right choice for every server.&lt;/p&gt;

&lt;p&gt;It only handles incoming traffic on the selected interface. It does not filter outgoing traffic from the host. It also does not solve a saturated provider link: if the uplink is already full, the packets have reached the provider and the local machine is too late.&lt;/p&gt;

&lt;p&gt;The default &lt;code&gt;bfban&lt;/code&gt; configuration uses &lt;code&gt;NF_LOCAL_IN&lt;/code&gt;, which is usually easier to understand and suitable for protecting services running on the local host.&lt;/p&gt;

&lt;h2&gt;
  
  
  Native XDP and generic XDP
&lt;/h2&gt;

&lt;p&gt;There are two important XDP execution modes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Native XDP
&lt;/h3&gt;

&lt;p&gt;Native XDP runs in the network driver's receive path, before the packet becomes a Linux socket-buffer structure (&lt;code&gt;skb&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;This is the earliest software path and usually has the lowest host overhead. It depends on support from the Linux driver.&lt;/p&gt;

&lt;h3&gt;
  
  
  Generic XDP
&lt;/h3&gt;

&lt;p&gt;Generic XDP runs later, after the packet has entered the regular Linux receive path and has been turned into an &lt;code&gt;skb&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It is compatible with more interfaces, so it is useful for testing and for environments where native support is unavailable. However, it has already paid some of the normal packet-processing cost.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;bfban&lt;/code&gt; supports both native and generic XDP attachment. The actual mode depends on the kernel, driver, and attachment path.&lt;/p&gt;

&lt;p&gt;It is important to verify the mode instead of assuming that a successful XDP attachment means native XDP is active:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo bpftool net show dev eno1
sudo ip -details link show dev eno1
ethtool -i eno1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The same filtering rule can therefore run at different points in the receive path.&lt;/p&gt;

&lt;p&gt;Native and generic XDP should not be treated as equivalent performance modes. Generic XDP is still real XDP, but it does not provide the same early-ingress advantage.&lt;/p&gt;

&lt;h2&gt;
  
  
  What bfban does not do
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;bfban&lt;/code&gt; does not:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;classify botnets automatically;&lt;/li&gt;
&lt;li&gt;replace a stateful firewall;&lt;/li&gt;
&lt;li&gt;perform NAT;&lt;/li&gt;
&lt;li&gt;restore a saturated Internet connection;&lt;/li&gt;
&lt;li&gt;guarantee that every packet of a distributed attack is visible;&lt;/li&gt;
&lt;li&gt;decide whether a log entry represents an attack;&lt;/li&gt;
&lt;li&gt;turn an untrusted threat feed into a verified source of truth.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is a component in a layered security design.&lt;/p&gt;

&lt;p&gt;A practical deployment might include these layers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;provider filtering / DDoS protection
              |
              v
        Linux host
       /         \
      v           v
 nftables       bfban
                   ^
                   |
           Fail2ban / CrowdSec
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The provider protects the uplink, the host firewall handles general policy, and &lt;code&gt;bfban&lt;/code&gt; handles a changing blocklist. Fail2ban and CrowdSec remain decision makers; they feed bans into &lt;code&gt;bfban&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The practical conclusion
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;bfban&lt;/code&gt; is useful when a Linux host needs a small, focused, kernel-backed blocklist service with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;one API for multiple producers;&lt;/li&gt;
&lt;li&gt;IP and CIDR support;&lt;/li&gt;
&lt;li&gt;TTL-based bans;&lt;/li&gt;
&lt;li&gt;persistent state;&lt;/li&gt;
&lt;li&gt;restart recovery;&lt;/li&gt;
&lt;li&gt;bpfilter/eBPF enforcement;&lt;/li&gt;
&lt;li&gt;optional XDP placement.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is not a universal firewall and does not need to become one.&lt;/p&gt;

&lt;p&gt;The proof of concept is valuable precisely because it tests a narrow claim in the real datapath: a user-space daemon can maintain a dynamic blocklist, bpfilter can represent that list as kernel-side sets and rules, and traffic from a blocked source can actually stop and later recover when the TTL expires.&lt;/p&gt;

&lt;p&gt;That is a useful building block — as long as it is used for the job it was designed to do.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources and further reading
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/rbelshevitz/bfban/" rel="noopener noreferrer"&gt;bfban GitHub repository&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://bpfilter.io/usage/explanation/hooks.html" rel="noopener noreferrer"&gt;bpfilter hook placement&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://bpfilter.io/usage/reference/rules.html" rel="noopener noreferrer"&gt;bpfilter rules and verdicts&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://bpfilter.io/developers/modules/libbpfilter/libbpfilter.html" rel="noopener noreferrer"&gt;bpfilter &lt;code&gt;libbpfilter&lt;/code&gt; documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://bpfilter.io/developers/build.html" rel="noopener noreferrer"&gt;bpfilter source-build instructions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/meta/bpfilter" rel="noopener noreferrer"&gt;bpfilter GitHub repository&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.ebpf.io/linux/program-type/BPF_PROG_TYPE_XDP/" rel="noopener noreferrer"&gt;eBPF XDP documentation and driver support&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.kernel.org/networking/filter.html" rel="noopener noreferrer"&gt;Linux BPF/JIT documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.kernel.org/bpf/map_lpm_trie.html" rel="noopener noreferrer"&gt;Linux LPM-trie maps&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.kernel.org/bpf/map_hash.html" rel="noopener noreferrer"&gt;Linux BPF hash maps&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.kernel.org/bpf/bpf_prog_run.html" rel="noopener noreferrer"&gt;Linux XDP live-frame documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://doi.org/10.1145/3281411.3281443" rel="noopener noreferrer"&gt;XDP research paper&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://wiki.netfilter.org/wiki-nftables/index.php/Sets" rel="noopener noreferrer"&gt;nftables sets&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://feodotracker.abuse.ch/blocklist/" rel="noopener noreferrer"&gt;Feodo Tracker blocklist&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.spamhaus.org/faqs/do-not-route-or-peer-drop/" rel="noopener noreferrer"&gt;Spamhaus DROP&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>linux</category>
      <category>ebpf</category>
      <category>networking</category>
      <category>xdp</category>
    </item>
    <item>
      <title>Зачем я создал yesh. Язык автоматизации Linux, который можно объяснить</title>
      <dc:creator>Roman Belshevitz</dc:creator>
      <pubDate>Mon, 02 Nov 2026 18:26:06 +0000</pubDate>
      <link>https://dev.to/rbelshevitz/zachiem-ia-sozdal-yesh-iazyk-avtomatizatsii-linux-kotoryi-mozhno-obiasnit-6pg</link>
      <guid>https://dev.to/rbelshevitz/zachiem-ia-sozdal-yesh-iazyk-avtomatizatsii-linux-kotoryi-mozhno-obiasnit-6pg</guid>
      <description>&lt;p&gt;Update: Сейчас полирую TUI-навигатор (помощник) и реальные backup-сценарии. Буду рад обратной связи, уважаемые админы, если попробуете yesh на своём сценарии.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Вышел yesh &lt;code&gt;v0.2.2&lt;/code&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;В &lt;code&gt;v0.2.2&lt;/code&gt; можно проверить резервное копирование и восстановление с помощью &lt;code&gt;rsync&lt;/code&gt; и &lt;code&gt;rsnapshot&lt;/code&gt;, подготовить и опубликовать конфигурацию, проверить службу и журнал, посмотреть действия через &lt;code&gt;--plan&lt;/code&gt; и убедиться, что после ошибки старые данные не исчезают. Начата работа над поддержкой OpenRC. Команды Linux остаются видимыми; yesh сам по себе не делает ваши действия в системе безопасными.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Типичный админский скрипт на Bash
&lt;/h2&gt;

&lt;p&gt;...начинается довольно прозаично. В нём обычно есть четыре шага:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;проверить, что действие допустимо;&lt;/li&gt;
&lt;li&gt;выполнить его;&lt;/li&gt;
&lt;li&gt;проверить результат;&lt;/li&gt;
&lt;li&gt;при ошибке остановиться так, чтобы было понятно, где и что уже изменилось.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;На практике Bash усложняет проверку корректности именно этих четырёх шагов. Кавычки, неявное разделение слов, особенности &lt;code&gt;set -e&lt;/code&gt;, неочевидное поведение конвейеров, различия между &lt;code&gt;mv&lt;/code&gt; и &lt;code&gt;cp&lt;/code&gt; на разных файловых системах, отсутствие явной границы «подготовили → опубликовали» — всё это приходится держать в голове одновременно. Поэтому даже в скрипте на 15–20 строк приходится мысленно компилировать последовательность действий, чтобы понять, что он действительно сделает.&lt;/p&gt;

&lt;p&gt;Это не означает, что Bash плох. Bash — полноценный императивный язык с функциями, циклами, условиями, &lt;code&gt;trap&lt;/code&gt; и обработкой ошибок. Он прекрасен для интерактивной работы, коротких команд и соединения существующих Linux-утилит. Проблема в другом: Bash не знает, какое изменение системы вы задумали, и не проверяет, соответствуют ли ему команды.&lt;/p&gt;

&lt;p&gt;Синтаксически правильная команда всё ещё может обратиться не к тому пути, опубликовать неполный результат или оставить администратора без понятного доказательства успеха.&lt;/p&gt;

&lt;h2&gt;
  
  
  Где появляется yesh
&lt;/h2&gt;

&lt;p&gt;yesh убирает часть этого шума вокруг команд. Он не делает Linux безопасным и не заменяет &lt;code&gt;rsync&lt;/code&gt;, &lt;code&gt;systemctl&lt;/code&gt;, &lt;code&gt;ssh&lt;/code&gt; или &lt;code&gt;tar&lt;/code&gt;. Идея проще:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;команды остаются видимыми, аргументы — точными, ошибки — явными, а порядок действий — читаемым сверху вниз.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Например, обычное обновление конфигурации выглядит так:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-euo&lt;/span&gt; pipefail

&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-q&lt;/span&gt; &lt;span class="s1"&gt;'^mode=production$'&lt;/span&gt; config.next&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-m&lt;/span&gt; 0640 &lt;span class="nt"&gt;--&lt;/span&gt; config.next /etc/myapp.conf.next
    &lt;span class="nb"&gt;mv&lt;/span&gt; &lt;span class="nt"&gt;-T&lt;/span&gt; /etc/myapp.conf.next /etc/myapp.conf
    systemctl restart myapp.service
    systemctl is-active &lt;span class="nt"&gt;--quiet&lt;/span&gt; myapp.service
&lt;span class="k"&gt;else
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"configuration validation failed"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&amp;amp;2
    &lt;span class="nb"&gt;exit &lt;/span&gt;2
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;В yesh тот же порядок записан как последовательность процедуры:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if grep -q '^mode=production$' config.next:
    install -m 0640 -- config.next /etc/myapp.conf.next
    publish /etc/myapp.conf.next to /etc/myapp.conf
    service restart myapp.service until active within 10s
else:
    echo "configuration validation failed"
    exit 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Сначала проверка, затем подготовка, публикация, перезапуск и проверка состояния. Код не обязан быть намного короче; важно, чтобы его можно было понять до запуска.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;publish&lt;/code&gt; выполняет переименование в пределах одной файловой системы и не переходит незаметно к копированию. Назначение должно быть новым именем или заменяемой символической ссылкой: yesh не сливает каталоги и не подменяет обычный существующий файл скрытой операцией.&lt;/p&gt;

&lt;h2&gt;
  
  
  Значения и команды
&lt;/h2&gt;

&lt;p&gt;Строка остаётся одним значением, список раскрывается в отдельные аргументы, а переменная раскрывается явно через &lt;code&gt;$name&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;message = "backup finished"
hosts = [web-1, web-2]

echo $message

for host in $hosts:
    echo $host
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;yesh не превращает строку команды в текст для &lt;code&gt;sh -c&lt;/code&gt;. Например:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;install -m 0640 -- config.next /etc/myapp.conf.next
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;получает такие аргументы:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;["install", "-m", "0640", "--", "config.next", "/etc/myapp.conf.next"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;rsync&lt;/code&gt; остаётся &lt;code&gt;rsync&lt;/code&gt;, &lt;code&gt;systemctl&lt;/code&gt; остаётся &lt;code&gt;systemctl&lt;/code&gt;, а yesh отвечает за окружающие проверки, порядок действий и остановку после ошибки. Python по-прежнему подходит для сложной логики и библиотек, Ansible — для инвентаря и желаемого состояния множества узлов. yesh занимает более узкую промежуточную нишу.&lt;/p&gt;

&lt;h2&gt;
  
  
  Что показывает &lt;code&gt;--plan&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;--plan&lt;/code&gt; показывает раскрытые действия без запуска процессов и открытия файлов, указанных в перенаправлениях. Вот нормализованный фрагмент настоящего прогона примера &lt;code&gt;examples/rsync-incremental.yesh&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PLAN lock "/srv/example-snapshots/.rsync.lock"
PLAN ["rsync" "-a" "--fsync" "--delay-updates" "--" "&amp;lt;environment value&amp;gt;" "&amp;lt;environment value&amp;gt;"]
PLAN publish "/srv/example-snapshots/snapshot.1.tmp" to "/srv/example-snapshots/snapshot.1"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;До передачи видны блокировка, реальные флаги &lt;code&gt;rsync&lt;/code&gt; и граница, после которой завершённое дерево станет доступно под постоянным именем. Значения из окружения заменяются на &lt;code&gt;&amp;lt;environment value&amp;gt;&lt;/code&gt;, чтобы просмотр плана не печатал их содержимое.&lt;/p&gt;

&lt;p&gt;Но план не является транзакцией и не фотографирует будущее состояние машины. Источник может исчезнуть после проверки, служба может изменить состояние до перезапуска, а внешняя команда всё равно может завершиться ошибкой. &lt;code&gt;--plan&lt;/code&gt; отвечает на вопрос «что этот сценарий попытается сделать с такими значениями?», а не на вопрос «сработает ли это через минуту?».&lt;/p&gt;

&lt;h2&gt;
  
  
  Ошибка должна быть понятной
&lt;/h2&gt;

&lt;p&gt;Обычная ошибка команды останавливает сценарий. Ненулевой результат команды, использованной как условие, может выбрать явную ветвь &lt;code&gt;else&lt;/code&gt;. Отсутствующий исполняемый файл, ошибка запуска, сигнал, отмена или превышение времени остаются ошибками выполнения, а не превращаются молча в обычное условие.&lt;/p&gt;

&lt;p&gt;Если падает любая стадия конвейера, падает весь конвейер. На POSIX отмена завершает группу принадлежащих сценарию процессов и дожидается дочерних процессов, а не останавливает только первый видимый PID.&lt;/p&gt;

&lt;p&gt;Это не делает внешние программы добрыми. &lt;code&gt;rsync&lt;/code&gt; всё ещё может удалить данные, если ему явно передали разрушительные аргументы. &lt;code&gt;systemctl&lt;/code&gt; всё ещё может перезапустить службу. Прямой запуск с отдельными аргументами убирает повторный разбор оболочкой, но не заменяет проверку намерения администратора.&lt;/p&gt;

&lt;h2&gt;
  
  
  Что происходит при отказе
&lt;/h2&gt;

&lt;p&gt;Количество тестов само по себе мало что доказывает. Гораздо полезнее один понятный пример того, что происходит при ошибке.&lt;/p&gt;

&lt;p&gt;На временном Linux-стенде настоящий &lt;code&gt;rsync&lt;/code&gt; запускается через обёртку, которая затем возвращает код &lt;code&gt;23&lt;/code&gt;, моделируя результат частичной передачи. Проверяется, что новый снимок не публикуется, предыдущий снимок не изменяется, временный каталог остаётся для диагностики, а повторный запуск завершается успешно.&lt;/p&gt;

&lt;p&gt;Здесь проверяется простое обещание: частичная передача не должна стать резервной копией, которую увидит восстановление, а ошибка повторного запуска не должна уничтожить последнюю хорошую копию. Это не ответ на все возможные проблемы файловой системы и сети. Это один конкретный случай, проверенный на Linux-стенде.&lt;/p&gt;

&lt;p&gt;В &lt;code&gt;v0.2.0&lt;/code&gt; есть и ещё одна практическая вещь: yesh может некоторое время наблюдать за одной службой systemd на Linux с cgroup v2. Он сохраняет историю в формате JSONL и строит сводку по памяти, процессору и дисковому вводу-выводу. Это удобно во время одного инцидента или обслуживания, но это не постоянный сборщик метрик и не управление cgroup.&lt;/p&gt;

&lt;h2&gt;
  
  
  Когда это имеет смысл
&lt;/h2&gt;

&lt;p&gt;Рассмотрим резервное копирование, которое не должно публиковать неполный результат:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;source = environment YESH_BACKUP_SOURCE
staging = "/srv/backups/.next"
published = "/srv/backups/current"

rsync -a -- $source $staging
publish $staging to $published
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Полный сценарий добавляет предварительные проверки, блокировку и новый пустой каталог назначения для каждого запуска. Если &lt;code&gt;rsync&lt;/code&gt; возвращает код, означающий частичную передачу или превышение времени, &lt;code&gt;publish&lt;/code&gt; не достигается, а прежнее опубликованное дерево остаётся доступным для восстановления.&lt;/p&gt;

&lt;p&gt;У yesh есть цена: ещё один исполняемый файл, ещё один язык и ещё одна среда выполнения, которую нужно сопровождать. Для однострочной команды это не оправдано. Польза появляется там, где Bash-сценарий уже труднее проверить, чем сами Linux-команды: при публикации файлов, отмене процессов, ограниченных проверках служб и проверке восстановления.&lt;/p&gt;

&lt;p&gt;Практический способ оценить такой инструмент простой: прочитать &lt;a href="https://github.com/rbelshevitz/yesh/blob/main/docs/syntax-guide.ru.md" rel="noopener noreferrer"&gt;учебник по синтаксису&lt;/a&gt;, запустить &lt;code&gt;--plan&lt;/code&gt;, посмотреть раскрытые аргументы, вызвать один отказ и проверить, что осталось неизменным. Если процедура после этого не стала проще для объяснения следующему администратору, Bash остаётся более подходящим выбором.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/rbelshevitz/yesh/blob/main/README.ru.md" rel="noopener noreferrer"&gt;Русская страница проекта&lt;/a&gt; · &lt;a href="https://github.com/rbelshevitz/yesh/releases/tag/v0.2.2" rel="noopener noreferrer"&gt;Выпуск &lt;code&gt;v0.2.2&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>linux</category>
      <category>bash</category>
      <category>devops</category>
      <category>go</category>
    </item>
    <item>
      <title>Why I Built yesh: Linux Automation You Can Explain</title>
      <dc:creator>Roman Belshevitz</dc:creator>
      <pubDate>Sat, 31 Oct 2026 17:00:07 +0000</pubDate>
      <link>https://dev.to/rbelshevitz/why-i-built-yesh-linux-automation-you-can-explain-32cj</link>
      <guid>https://dev.to/rbelshevitz/why-i-built-yesh-linux-automation-you-can-explain-32cj</guid>
      <description>&lt;h1&gt;
  
  
  Why I Built yesh: Linux Automation You Can Explain
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;yesh &lt;code&gt;v0.3.0&lt;/code&gt; is out.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;yesh is a small language and Go runtime for Linux scripts that need more than a command, but less than a full automation system. It keeps &lt;code&gt;rsync&lt;/code&gt;, &lt;code&gt;rsnapshot&lt;/code&gt;, &lt;code&gt;systemctl&lt;/code&gt;, &lt;code&gt;ssh&lt;/code&gt;, and other Linux tools visible. Its job is to make the checks around those tools, their order, and their failure paths easier to read.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;One day I was sitting in a cramped server room with a small laptop, trying to fix a server in a hurry. Its Bash scripts ran from &lt;code&gt;rc.local&lt;/code&gt; and cron. With every look at those scripts, my mood sank a little further. Nothing fit on the screen. I kept scrolling back and forth, trying to remember what ran first, which command failure would actually stop the script, and whether a half-finished run had left the old configuration intact.&lt;/p&gt;

&lt;p&gt;The scripts had started as a few commands. By then they checked mounts, copied files, restarted services, waited for them to recover, wrote logs, and cleaned up temporary directories. The commands were familiar. The scripts were not.&lt;/p&gt;

&lt;p&gt;That was the moment I started thinking about a different kind of tool: something that would stay close to Linux commands, but make the surrounding procedure possible to read on a small screen and explain before running it. I was not looking for a new language. I wanted to get through one repair without having to mentally execute an entire Bash script first.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bash is not the enemy
&lt;/h2&gt;

&lt;p&gt;Bash is good at what it was made for. It starts quickly, is already installed on most Linux systems, and is excellent for interactive work, small scripts, and composing Unix programs. I use it and respect it.&lt;/p&gt;

&lt;p&gt;Bash can also express complete procedures. It has functions, loops, conditions, traps, and error handling. The difficulty is seeing, before execution, how shell syntax, expansions, process rules, and error handling combine. Bash does not know what change you intend to make, and it does not check that the commands match that intention. A syntactically valid command can still point at the wrong path, publish a partial result, or leave the operator without useful evidence that it succeeded.&lt;/p&gt;

&lt;p&gt;yesh takes a narrower approach. It keeps the Linux command visible and makes the important parts of the procedure explicit: what is checked, what may change, what is published, what happens after a partial failure, and what counts as success.&lt;/p&gt;

&lt;p&gt;The goal is not to replace Bash, Python, or Ansible. Python is a better fit for application logic, data structures, and APIs. Ansible is a better fit for inventory, roles, desired state, and many machines. yesh is for the awkward middle: a small administrative script that is too important to hide behind shell tricks, but too close to the Linux command line to justify a larger framework.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start with a real operation
&lt;/h2&gt;

&lt;p&gt;Consider a configuration update. The file must be checked, installed under a temporary name, published, and followed by a service restart and health check.&lt;/p&gt;

&lt;p&gt;In Bash, a careful version might look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-euo&lt;/span&gt; pipefail

&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-q&lt;/span&gt; &lt;span class="s1"&gt;'^mode=production$'&lt;/span&gt; config.next&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-m&lt;/span&gt; 0640 &lt;span class="nt"&gt;--&lt;/span&gt; config.next /etc/myapp.conf.next
    &lt;span class="nb"&gt;mv&lt;/span&gt; &lt;span class="nt"&gt;-T&lt;/span&gt; /etc/myapp.conf.next /etc/myapp.conf
    systemctl restart myapp.service
    systemctl is-active &lt;span class="nt"&gt;--quiet&lt;/span&gt; myapp.service
&lt;span class="k"&gt;else
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"configuration validation failed"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&amp;amp;2
    &lt;span class="nb"&gt;exit &lt;/span&gt;2
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is the same procedure in yesh:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if grep -q '^mode=production$' config.next:
    install -m 0640 -- config.next /etc/myapp.conf.next
    publish /etc/myapp.conf.next to /etc/myapp.conf
    service restart myapp.service until active within 10s
else:
    echo "configuration validation failed"
    exit 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The yesh version is not interesting because it is dramatically shorter. It is interesting because it reads from top to bottom as a procedure: validate, prepare, publish, restart, verify.&lt;/p&gt;

&lt;p&gt;That small &lt;code&gt;publish&lt;/code&gt; word has a precise meaning. It uses a rename on the same filesystem. It does not quietly fall back to copying, merge an existing directory, or overwrite an ordinary existing file. The destination must be a new name or a replaceable symlink. The service operation has a deadline and checks that the requested unit becomes active.&lt;/p&gt;

&lt;p&gt;Those rules are next to the actions. A reader does not have to reconstruct them from a collection of shell commands and conventions.&lt;/p&gt;

&lt;h2&gt;
  
  
  What happens when the node dies?
&lt;/h2&gt;

&lt;p&gt;The interesting test is not the happy path. Suppose the script has acquired &lt;code&gt;with lock&lt;/code&gt;, &lt;code&gt;rsync&lt;/code&gt; is writing into the private staging directory, and the process is killed or the container is stopped.&lt;/p&gt;

&lt;p&gt;In our interruption tests, a yesh process was killed while holding the lock on an Alpine 3.24.3 stand. We repeated the same check with &lt;code&gt;docker kill&lt;/code&gt; in the WSL2 container stand. In both cases, a second run acquired the same lock again. A lock-path file may remain, but in these tests it did not prevent reacquisition.&lt;/p&gt;

&lt;p&gt;The staging directory is not silently promoted. Because &lt;code&gt;publish&lt;/code&gt; has not run, the previous published snapshot remains the one a restore job can see. If the filesystem is still accessible, the unfinished staging tree is available for diagnosis or cleanup according to the scenario. yesh does not claim to repair arbitrary files that an external command may already have changed.&lt;/p&gt;

&lt;p&gt;Separate POSIX tests cover cancellation and descriptor cleanup. They check that yesh stops the process group it owns, waits for its children, and does not accumulate file descriptors or goroutines across repeated cancellation. These are test results for the exercised process paths, not a general claim about every external program.&lt;/p&gt;

&lt;p&gt;We did not test an actual power cut or force an OOM kill of yesh. The article therefore makes no claim about filesystem state after power loss or about an OOM interruption beyond the fact that those scenarios still need their own tests.&lt;/p&gt;

&lt;h2&gt;
  
  
  The language removes a few traps
&lt;/h2&gt;

&lt;p&gt;The syntax is intentionally small.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;message = "backup finished"
hosts = [web-1, web-2]

echo $message

for host in $hosts:
    echo $host
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A string remains one value. A list expands into separate arguments. A variable is expanded only with the explicit &lt;code&gt;$name&lt;/code&gt; form; a bare word remains a literal. Values are not split by whitespace and are not parsed again as code.&lt;/p&gt;

&lt;p&gt;Those rules remove one category of shell reasoning. They do not make &lt;code&gt;rsync&lt;/code&gt;, &lt;code&gt;ssh&lt;/code&gt;, or &lt;code&gt;systemctl&lt;/code&gt; safe by themselves. The administrator still has to choose the right command and the right arguments.&lt;/p&gt;

&lt;p&gt;Commands remain commands. yesh does not turn a line into a string and pass it to &lt;code&gt;sh -c&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;install -m 0640 -- config.next /etc/myapp.conf.next
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The process receives this argument list:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;["install", "-m", "0640", "--", "config.next", "/etc/myapp.conf.next"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;rsync&lt;/code&gt; remains &lt;code&gt;rsync&lt;/code&gt;. &lt;code&gt;systemctl&lt;/code&gt; remains &lt;code&gt;systemctl&lt;/code&gt;. &lt;code&gt;ssh&lt;/code&gt; remains &lt;code&gt;ssh&lt;/code&gt;. yesh handles the procedure around them; it does not replace their semantics.&lt;/p&gt;

&lt;h2&gt;
  
  
  Planning is part of reading
&lt;/h2&gt;

&lt;p&gt;Before it changes anything, yesh can show the commands it would try to run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PLAN lock "/srv/example-snapshots/.rsync.lock"
PLAN ["rsync" "-a" "--fsync" "--delay-updates" "--" "&amp;lt;environment value&amp;gt;" "&amp;lt;environment value&amp;gt;"]
PLAN publish "/srv/example-snapshots/snapshot.1.tmp" to "/srv/example-snapshots/snapshot.1"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is not a transaction and it does not remove the gap between checking and acting. A source can disappear after &lt;code&gt;exists&lt;/code&gt;; a service can change state before a restart; an external program can fail. The plan answers a smaller, useful question: what would this script try to do with these values?&lt;/p&gt;

&lt;p&gt;Environment values are shown as &lt;code&gt;&amp;lt;environment value&amp;gt;&lt;/code&gt; rather than printed into the plan. That makes it possible to review the shape of a command without exposing its contents.&lt;/p&gt;

&lt;h2&gt;
  
  
  Failure should be boring
&lt;/h2&gt;

&lt;p&gt;An ordinary command failure stops a yesh script by default. A non-zero result used as a condition can choose an explicit &lt;code&gt;else&lt;/code&gt; branch. A missing executable, startup failure, signal, cancellation, or timeout remains an execution error; it does not quietly become a normal branch.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;source = "/srv/releases/current"

if exists $source:
    echo "release is present"
else:
    echo "release is missing"
    exit 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pipelines are where this matters most. If one stage fails, the pipeline fails. On POSIX systems, cancellation stops the process group owned by the script and waits for the child processes it started, rather than killing only the first visible process.&lt;/p&gt;

&lt;p&gt;This is not a claim that external programs are safe. &lt;code&gt;rsync&lt;/code&gt; can still delete data when given destructive arguments. &lt;code&gt;systemctl&lt;/code&gt; can still interrupt a service. Direct argument execution prevents another shell from reinterpreting the command; it does not give an arbitrary executable good intentions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why backups are a useful test
&lt;/h2&gt;

&lt;p&gt;Backups make the difference concrete. “The command returned zero” is not enough. The administrator also needs to know whether the source existed, whether the destination was the expected filesystem, whether a partial result became visible, and whether the last good snapshot survived a failed retry.&lt;/p&gt;

&lt;p&gt;The important part of an incremental backup is the order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;check the destination and the paths;&lt;/li&gt;
&lt;li&gt;acquire the lock;&lt;/li&gt;
&lt;li&gt;copy into a new private directory;&lt;/li&gt;
&lt;li&gt;publish it only after &lt;code&gt;rsync&lt;/code&gt; finishes.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The yesh scenario leaves &lt;code&gt;rsync&lt;/code&gt; and its flags visible while making that order explicit. &lt;code&gt;rsnapshot&lt;/code&gt; remains responsible for its own configuration, transfer, and rotation; yesh only adds the checks and confirmation around it.&lt;/p&gt;

&lt;p&gt;One test on a disposable Linux setup runs real &lt;code&gt;rsync&lt;/code&gt;, then uses a wrapper to return code 23, simulating a partial transfer. The test checks that the new snapshot is not published, the previous snapshot is unchanged, the staging directory remains available for diagnosis, and a retry succeeds.&lt;/p&gt;

&lt;p&gt;This is a modest promise, but a useful one: a partial transfer must not become the backup that a restore job sees. It does not prove that every filesystem, kernel, network, or external-tool failure behaves the same way.&lt;/p&gt;

&lt;h2&gt;
  
  
  Small systems are part of the reason
&lt;/h2&gt;

&lt;p&gt;The problem is not limited to a large server with systemd and a full Bash installation. On a small Alpine host, a home server, an edge machine, or a lightweight container, the available environment may be musl, BusyBox, OpenRC, a few external tools, and not much else.&lt;/p&gt;

&lt;p&gt;That is a good place for a small statically linked yesh binary. It can sit beside the commands that already know how to do the real work. It does not replace OpenRC, BusyBox, Docker, or the application; it connects a few checks and commands so that the order is visible.&lt;/p&gt;

&lt;p&gt;The OpenRC support is still experimental. It has been checked on the documented Alpine fixture for service state, processes, cgroups, and short resource snapshots. That is evidence for that setup, not a promise about every OpenRC installation.&lt;/p&gt;

&lt;p&gt;There is also a small container example: &lt;a href="//docs/underthehood/container-sqlite-lab.md"&gt;one-shot SQLite migration in an Alpine container&lt;/a&gt;. The image contains yesh, the external &lt;code&gt;sqlite3&lt;/code&gt; program, a yesh script, and a migration file. On startup, the script checks the database and migration, takes a local lock, sees whether the migration has already run, invokes &lt;code&gt;sqlite3&lt;/code&gt;, and verifies the new column.&lt;/p&gt;

&lt;p&gt;The boundaries stay clear. SQLite owns the database and SQL transaction. Docker owns the image, volume, and process limits. yesh owns the order, lock, exact arguments, plan, and result check. The example covers one local database file in one Linux/amd64 container; it does not claim to solve migrations for a cluster, PostgreSQL, Kubernetes, or distributed storage.&lt;/p&gt;

&lt;h2&gt;
  
  
  Not another monitoring system
&lt;/h2&gt;

&lt;p&gt;The same restraint applies to service measurements. yesh can take a short look at one service: its state, processes, cgroup counters, and a limited part of the journal. It can write those observations as JSONL and summarize them later. That is enough to compare a service before and after a change or to leave useful evidence during an incident.&lt;/p&gt;

&lt;p&gt;It is closer to taking a photograph than running a security camera. There is no resident agent, dashboard, alert rules, time-series database, or elaborate metric catalogue. yesh does not try to turn a few counters into a complete picture of system health. If the host cannot provide a value, the result says that it is unavailable or incomplete.&lt;/p&gt;

&lt;p&gt;This is deliberately less ambitious than monitoring. The point is to answer one question about one machine at one moment, then leave a small record that another person can read.&lt;/p&gt;

&lt;h2&gt;
  
  
  What shipped in &lt;code&gt;v0.3.0&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;For now, yesh ships for Linux/amd64. The release includes backup and restore examples, checks around &lt;code&gt;rsync&lt;/code&gt; and &lt;code&gt;rsnapshot&lt;/code&gt;, configuration publication, locking, reruns, &lt;code&gt;--plan&lt;/code&gt;, and service and journal operations with clear limits.&lt;/p&gt;

&lt;p&gt;It also includes the separate &lt;a href="//README.md#tui-assistant-for-first-time-users"&gt;&lt;code&gt;yesh-navigator&lt;/code&gt;&lt;/a&gt; companion, a small assistant that runs in the terminal. A first-time user can choose a backup or a read-only service check, fill in a few paths or names, and get a real yesh script rather than a hidden template. The navigator shows that file and its plan before saving, so the user can read the result and reject it if the paths or commands are wrong. It never runs the generated script, and the ordinary &lt;code&gt;yesh&lt;/code&gt; binary does not depend on it.&lt;/p&gt;

&lt;p&gt;The project is backed by more than 200 automated tests and four fuzz targets. The POSIX/Linux tests cover pipeline failure, &lt;code&gt;SIGPIPE&lt;/code&gt;, process groups, timeouts, cancellation, child cleanup, redirects, and repeated cancellation. The release checks use real Linux fixtures and external tools. They give us confidence in the cases that were tested; they are not a safety guarantee for every machine.&lt;/p&gt;

&lt;h2&gt;
  
  
  The limits are part of the design
&lt;/h2&gt;

&lt;p&gt;yesh is not an interactive shell, a Bash-compatible replacement, a Python competitor, an Ansible alternative, or a backup engine. It does not grant privileges, manage cgroups, control somebody else’s processes, or make a successful command proof that the machine is healthy.&lt;/p&gt;

&lt;p&gt;It is also not trying to grow into a general-purpose configuration language. A feature belongs in yesh only when it makes a real Linux procedure easier to read, check, or repeat. If a visible &lt;code&gt;rsync&lt;/code&gt;, &lt;code&gt;ssh&lt;/code&gt;, or &lt;code&gt;systemctl&lt;/code&gt; command explains the action better, that command stays visible.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not just use Python or Go?
&lt;/h2&gt;

&lt;p&gt;The obvious objection is fair: why use another language at all? A Python script can run the same commands. A Go program can be compiled into one binary. Both are more powerful than yesh.&lt;/p&gt;

&lt;p&gt;I would not describe yesh as a domain-specific language or a configuration DSL. It is a small executable language for Linux procedures. The external commands remain ordinary commands; yesh supplies the control flow around them and gives that control flow one predictable runtime.&lt;/p&gt;

&lt;p&gt;For a larger tool, that power is usually the point. For a small Linux procedure, it also creates room for another layer of code: process wrappers, argument conversion, timeout handling, cleanup, and a reporting format around commands that already have their own semantics. A Go program can be excellent here, but it asks the author to build a program. Python is comfortable, but a Python wrapper can hide the command line inside string handling and library code.&lt;/p&gt;

&lt;p&gt;yesh makes a narrower trade. Its syntax is new, and its runtime is another thing to install and maintain. In return, the common case stays close to the command line: lists and strings have fixed boundaries, commands become direct argument lists, failure stops by default, and the same parsed file can produce a plan without executing anything. It has fewer escape hatches because it is not meant to be an application language.&lt;/p&gt;

&lt;p&gt;That trade is not automatically worth it. For a one-line command, use the command. For substantial logic, use Python or Go. yesh earns its place only when a small procedure has enough checks, ordering, and failure handling that the surrounding shell code is harder to review than the Linux commands themselves.&lt;/p&gt;

&lt;h2&gt;
  
  
  The case for trying it
&lt;/h2&gt;

&lt;p&gt;Take a backup that must not publish a partial result. The important failure is not an exotic parser bug. It is an interrupted transfer that leaves a directory looking complete, or a retry that overwrites the last good copy.&lt;/p&gt;

&lt;p&gt;In yesh, the core of the operation is easy to point at:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;source = environment YESH_BACKUP_SOURCE
staging = "/srv/backups/.next"
published = "/srv/backups/current"

rsync -a -- $source $staging
publish $staging to $published
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The full scenario adds the checks and the lock. If &lt;code&gt;rsync&lt;/code&gt; reports a partial transfer or times out, the script stops and never reaches &lt;code&gt;publish&lt;/code&gt;. The previous tree remains the one a restore job can see. A rerun gets a new staging path instead of relying on a tangle of shell traps.&lt;/p&gt;

&lt;p&gt;There is a cost: another executable, another language, and another runtime to understand. That cost is not justified for a one-line command or a script that Bash already makes clear. It becomes reasonable when the procedure has a real point of failure—staging and publication, process cancellation, a service check with a deadline, or restore verification—and the shell code around the Linux commands is harder to review than the commands themselves.&lt;/p&gt;

&lt;p&gt;Read the &lt;a href="https://github.com/rbelshevitz/yesh/blob/main/docs/syntax-guide.md" rel="noopener noreferrer"&gt;syntax tutorial&lt;/a&gt;, run &lt;code&gt;--plan&lt;/code&gt;, inspect the arguments, force one failure, and check what remained unchanged. If the result is not easier to explain to the next operator, use Bash. yesh should earn its place in the toolchain by passing that test.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/rbelshevitz/yesh" rel="noopener noreferrer"&gt;Explore yesh on GitHub&lt;/a&gt; · &lt;a href="https://github.com/rbelshevitz/yesh/releases/tag/v0.3.0" rel="noopener noreferrer"&gt;Download &lt;code&gt;v0.3.0&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>linux</category>
      <category>bash</category>
      <category>devops</category>
      <category>go</category>
    </item>
    <item>
      <title>Das U-Boot: from Power-On to initrd</title>
      <dc:creator>Roman Belshevitz</dc:creator>
      <pubDate>Wed, 07 May 2025 15:01:05 +0000</pubDate>
      <link>https://dev.to/rbelshevitz/from-power-on-to-initrd-with-u-boot-35da</link>
      <guid>https://dev.to/rbelshevitz/from-power-on-to-initrd-with-u-boot-35da</guid>
      <description>&lt;p&gt;&lt;a href="https://github.com/u-boot/u-boot" rel="noopener noreferrer"&gt;Das U-Boot&lt;/a&gt; is a well-known bootloader which brings embedded Linux devices to life since 1999, it turns 25 this year. &lt;/p&gt;

&lt;p&gt;My today's post walks through the complete U-Boot boot process, covering everything from SoC power-on to launching the Linux &lt;code&gt;initrd&lt;/code&gt;, along with hardware-specific gotchas.&lt;/p&gt;




&lt;h2&gt;
  
  
  The boot flow
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;Power On]
   ↓
&lt;span class="o"&gt;[&lt;/span&gt;SoC BootROM] → &lt;span class="o"&gt;[&lt;/span&gt;SPL]
   ↓
&lt;span class="o"&gt;[&lt;/span&gt;U-Boot Proper]
   ↓
&lt;span class="o"&gt;[&lt;/span&gt;Loads kernel + dtb + initrd]
   ↓
&lt;span class="o"&gt;[&lt;/span&gt;bootz / booti]
   ↓
&lt;span class="o"&gt;[&lt;/span&gt;Linux Kernel starts]
   ↓
&lt;span class="o"&gt;[&lt;/span&gt;initrd: /init runs]
   ↓
&lt;span class="o"&gt;[&lt;/span&gt;Switch to rootfs]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  🔌 1. Power-On: SoC BootROM
&lt;/h3&gt;

&lt;p&gt;Every SoC contains a hardcoded BootROM:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Executes right after power-on or reset&lt;/li&gt;
&lt;li&gt;Detects the boot source via boot pins&lt;/li&gt;
&lt;li&gt;Loads the Secondary Program Loader (SPL) from flash, SD, UART, or USB&lt;/li&gt;
&lt;li&gt;Minimal hardware is initialized here&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  📦 2. SPL (Secondary Program Loader)
&lt;/h3&gt;

&lt;p&gt;SPL is a tiny version of U-Boot:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Brings up DRAM and essential regulators&lt;/li&gt;
&lt;li&gt;Loads full U-Boot into RAM&lt;/li&gt;
&lt;li&gt;Operates within very constrained SRAM limits&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 &lt;em&gt;Hardware nuance:&lt;/em&gt; If DRAM init fails here, the system will hang silently. Always verify timing parameters for your DDR/LPDDR.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  🚀 3. U-Boot Proper
&lt;/h3&gt;

&lt;p&gt;Now the full U-Boot runs from RAM:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Initializes serial console, eMMC/SD, network, USB, etc.&lt;/li&gt;
&lt;li&gt;Parses environment variables (&lt;code&gt;bootargs&lt;/code&gt;, &lt;code&gt;bootcmd&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Loads:

&lt;ul&gt;
&lt;li&gt;Linux kernel (&lt;code&gt;zImage&lt;/code&gt; or &lt;code&gt;Image&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Device Tree Blob (&lt;code&gt;.dtb&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;initrd (&lt;code&gt;initramfs&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Starts the boot using &lt;code&gt;bootz&lt;/code&gt; or &lt;code&gt;booti&lt;/code&gt;
&lt;/li&gt;

&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bootz &lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;kernel_addr_r&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt; &lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;ramdisk_addr_r&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt; &lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;fdt_addr_r&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Regarding boot device order, modern U-Boot uses so-called "Distro Boot" framework:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;bootcmd&lt;/code&gt; runs &lt;code&gt;distro_bootcmd&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;distro_bootcmd&lt;/code&gt; iterates over &lt;code&gt;boot_targets&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;code&gt;distro_bootcmd&lt;/code&gt; mechanism in U-Boot supports booting using configuration files like &lt;code&gt;extlinux.conf&lt;/code&gt; and scripts like &lt;code&gt;boot.scr&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;extlinux.conf&lt;/code&gt;: A configuration file that specifies kernel, initrd, and device tree paths, allowing for multiple boot entries and parameters.&lt;/li&gt;
&lt;li&gt;boot.scr: a compiled script containing U-Boot commands, offering a way to automate complex boot sequences.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Looks for known boot files: &lt;code&gt;extlinux.conf&lt;/code&gt;, &lt;code&gt;boot.scr&lt;/code&gt;, &lt;code&gt;boot.ini&lt;/code&gt;, or standard kernel/initrd/fdt triplets. Usually there is '1st eMMC/SD - 1st USB - 1st NVMe' sequence of boot devices.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;setenv&lt;/code&gt; command in U-Boot is used to define or override environment variables, which control nearly every aspect of how U-Boot boots your system.&lt;/p&gt;

&lt;p&gt;🔧 Basic Syntax&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;setenv variable_name value
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;setenv bootargs &lt;span class="s2"&gt;"console=ttyS0,115200 root=/dev/mmcblk0p2 rw"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To persist changes do &lt;code&gt;saveenv&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This writes changes to persistent storage (e.g., SPI NOR, eMMC, NAND, or a UBI volume). If you don't run &lt;code&gt;saveenv&lt;/code&gt;, any updates you may have made to the U-Boot environment will be lost on next system reboot.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 Use &lt;code&gt;printenv&lt;/code&gt; and &lt;code&gt;bdinfo&lt;/code&gt; to check variables and layout. Be careful: U-Boot does not validate variable syntax, so typos can silently break boot! To recover from bad bootcmd or bootargs, use serial console and interrupt boot early (usually by pressing a key).&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  🐧 4. Linux Kernel Boot
&lt;/h3&gt;

&lt;p&gt;The kernel is now in control:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Unpacks itself into RAM&lt;/li&gt;
&lt;li&gt;Parses command-line and DTB&lt;/li&gt;
&lt;li&gt;Mounts &lt;code&gt;initrd&lt;/code&gt; as the rootfs&lt;/li&gt;
&lt;li&gt;Runs &lt;code&gt;/init&lt;/code&gt; script from initrd&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 If any addresses (kernel/initrd/fdt) overlap in RAM, the kernel &lt;strong&gt;may crash&lt;/strong&gt;. Always double-check memory layout!&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  🐧 5. What Happens in initrd?
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;initrd&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Loads drivers/modules&lt;/li&gt;
&lt;li&gt;Mounts the actual root filesystem (e.g., &lt;code&gt;/dev/mmcblk0p2&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;May perform decryption, overlay setup, or network discovery&lt;/li&gt;
&lt;li&gt;Executes &lt;code&gt;switch_root&lt;/code&gt; or &lt;code&gt;pivot_root&lt;/code&gt; to hand off to your real system (e.g., &lt;code&gt;systemd&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  ⚙️ Hardware-Related Pitfalls
&lt;/h2&gt;

&lt;p&gt;Some common embedded issues:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;DRAM doesn't initialize? &lt;a href="https://docs.u-boot.org/en/latest/develop/memory.html" rel="noopener noreferrer"&gt;Wrong timing in SPL&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Kernel hangs early? &lt;a href="https://lists.denx.de/pipermail/u-boot/2008-May/034686.html" rel="noopener noreferrer"&gt;Overlapping memory regions&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Ethernet/MAC not working? &lt;a href="https://samuel.dionne-riel.com/blog/2024/12/05/dtb-loading-is-harder-than-it-looks.html" rel="noopener noreferrer"&gt;Wrong or mismatched DTB&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;NAND boot fails? &lt;a href="https://adaptivesupport.amd.com/s/question/0D52E00006hpLPbSAM/enabling-ecc-results-in-kernel-panic-during-booting-with-initramfs?language=en_US" rel="noopener noreferrer"&gt;Missing ECC config in U-Boot&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Secure boot halts execution? &lt;a href="https://docs.u-boot.org/en/v2025.01/usage/fit/verified-boot.html" rel="noopener noreferrer"&gt;U-Boot binary not signed&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Sources: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.u-boot.org/en/latest/" rel="noopener noreferrer"&gt;https://docs.u-boot.org/en/latest/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://samuel.dionne-riel.com/blog/2024/12/05/dtb-loading-is-harder-than-it-looks.html" rel="noopener noreferrer"&gt;https://samuel.dionne-riel.com/blog/2024/12/05/dtb-loading-is-harder-than-it-looks.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842223/U-boot" rel="noopener noreferrer"&gt;Xilinx Wiki: U-boot&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://microchip.my.site.com/s/article/SAMA5D3-EDS---Modifying-Device-Tree-Overlays-in-U-Boot-Prompt-using--fdt--utility" rel="noopener noreferrer"&gt;Microchip: Modifying Device Tree Overlays in U-Boot Prompt using 'fdt' utility&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Todo: add more context; describe ARM related nuances...&lt;br&gt;
Cover pic: Pixabay / Pexels&lt;/p&gt;

</description>
      <category>linux</category>
      <category>embedded</category>
    </item>
    <item>
      <title>Landing From Clouds: Why On-Premise Will Eventually Win... In a Large Number of Cases</title>
      <dc:creator>Roman Belshevitz</dc:creator>
      <pubDate>Mon, 05 May 2025 21:36:26 +0000</pubDate>
      <link>https://dev.to/rbelshevitz/landing-from-clouds-why-on-premise-will-eventually-win-4j7o</link>
      <guid>https://dev.to/rbelshevitz/landing-from-clouds-why-on-premise-will-eventually-win-4j7o</guid>
      <description>&lt;p&gt;&lt;em&gt;Update: Well, folks, I edited the title. No one spoke so categorically. Clouds will remain in their niches for some time. But these are strictly niches. In the article I explain why the hype will subside.&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;“The computer industry is the only industry that is more fashion-driven than women’s fashion.”&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;em&gt;Larry Ellison&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In our era, the cloud is the haute couture of infrastructure. Everyone wants it. Everyone says you &lt;em&gt;need&lt;/em&gt; it. And few ask whether it actually fits.&lt;/p&gt;

&lt;p&gt;This post is for those who remember that &lt;a href="https://news.ycombinator.com/item?id=37965142" rel="noopener noreferrer"&gt;not every problem needs 12 layers of abstraction&lt;/a&gt;. It's for careful builders who believe that &lt;strong&gt;owning your tools&lt;/strong&gt; is better than &lt;strong&gt;renting your soul&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;And here are &lt;strong&gt;12 reasons&lt;/strong&gt; why on-premise will outlast the hype.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Cloud Is Renting the Same Hardware for Triple the Price
&lt;/h2&gt;

&lt;p&gt;The cloud sells convenience, but charges premium rent, &lt;strong&gt;forever&lt;/strong&gt;. When you buy servers, you own an asset. When you rent a VM, you feed a meter. The cloud &lt;strong&gt;is like living in a hotel room&lt;/strong&gt; and bragging you don’t have to fix the faucet. &lt;/p&gt;

&lt;p&gt;Sure, but you’re paying 10× the mortgage and still can’t open a window.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. DevOps Became a Way to Work 24/7
&lt;/h2&gt;

&lt;p&gt;DevOps was meant to unify teams. Instead, it blurred boundaries: developer and admin, work and sleep, code and ops. Now every developer is also on call. This "you build it, you run it" culture leads to burnout, not harmony.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Complexity Is Not a Virtue
&lt;/h2&gt;

&lt;p&gt;In the old days, a deployment was &lt;code&gt;make install&lt;/code&gt;. Now it's a procession of YAML files, container registries, ephemeral environments, secrets managers, Terraform pipelines, and CI/CD rituals that often do less than a Bash script with &lt;code&gt;rsync&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The industry calls this &lt;em&gt;“modern infrastructure”&lt;/em&gt;. I call it &lt;em&gt;complexity theater&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Many engineers grew up on the UNIX philosophy — small, composable tools, each doing one job well. But this doesn’t mean they signed up for a balkanized mesh of microservices, &lt;strong&gt;each with its own language, API, database, and dev team&lt;/strong&gt;. Microservices often don’t simplify — they multiply: bugs, failure points, logging silos, and deployment dependencies.&lt;/p&gt;

&lt;p&gt;Abstraction without necessity is just friction in disguise. Ask yourself: Do you need ten services—or just ten functions?&lt;/p&gt;

&lt;h2&gt;
  
  
  4. You Will Regret Vendor Lock-In
&lt;/h2&gt;

&lt;p&gt;When you rent your stack, the landlord can raise the rent—or remove the plumbing. Cloud APIs change, regions go down, and cost models shift. &lt;/p&gt;

&lt;p&gt;Take &lt;strong&gt;CoreWeave&lt;/strong&gt;, a cloud provider for AI workloads: they’ve accumulated &lt;strong&gt;$7.5 billion in debt&lt;/strong&gt;, &lt;a href="https://www.ft.com/content/163c6927-2032-4346-857e-8e3787e4babc" rel="noopener noreferrer"&gt;much of it due to aggressive infrastructure expansion&lt;/a&gt; without sustainable financial models. They now face &lt;strong&gt;$1 billion/year in interest&lt;/strong&gt;. Growth without sovereignty is a debt spiral.  &lt;/p&gt;

&lt;h2&gt;
  
  
  5. Not Every Company Needs Speed. Some Need Sanity
&lt;/h2&gt;

&lt;p&gt;There’s a cult of speed in DevOps: deploy 50 times a day! But most companies — municipalities, utilities, banks — don’t need to push &lt;strong&gt;hourly patches&lt;/strong&gt;. They need reliability.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;2025 Vertice survey&lt;/strong&gt; showed that &lt;strong&gt;55% of CFOs&lt;/strong&gt; &lt;a href="https://www.cfodive.com/news/runaway-cloud-spending-frustrates-finance-execs-vertice/694706" rel="noopener noreferrer"&gt;saw cloud spending increase year-over-year&lt;/a&gt;, and &lt;strong&gt;24% called it “significant.”&lt;/strong&gt; These weren’t startup execs—they were finance leaders. The "move fast" mantra, unchecked, has real financial consequences.  &lt;/p&gt;

&lt;h2&gt;
  
  
  6. Data Wants to Stay Home
&lt;/h2&gt;

&lt;p&gt;For many industries, data is too large or too sensitive to outsource. Petabytes of sensor data, medical records, or real-time video don’t want to live in some abstract region. They want proximity. They want privacy. And often, regulators &lt;strong&gt;demand it&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;When regulators ask, “Where is the data?” — you can’t answer “uh... &lt;code&gt;us-east-1&lt;/code&gt;”. You need direct control. On-premise allows you to define, audit, and defend your policies with confidence. &lt;/p&gt;

&lt;p&gt;Compliance is not a checkbox, not something to outsource! Regulatory compliance isn’t just a checklist — it’s a legal and financial time bomb, especially when you're storing personal data somewhere in the cloud. Frameworks like GDPR in Europe and HIPAA in the U.S. demand strict control over where data resides, who can access it, and how it’s processed. Cloud vendors offer compliance-ready services, but when breaches or misconfigurations occur, it's your organization — not AWS, GCP or Azure —writing the check.&lt;/p&gt;

&lt;p&gt;Consider these real-world reminders:&lt;/p&gt;

&lt;p&gt;💰 &lt;em&gt;TikTok's €530 Million Fine:&lt;/em&gt; In May 2025, Ireland's Data Protection Commission &lt;a href="https://www.theguardian.com/technology/2025/may/02/tiktok-fined-530m-for-failing-to-protect-user-data-from-chinese-state" rel="noopener noreferrer"&gt;fined TikTok €530 million&lt;/a&gt; for unlawfully transferring European user data to China without adequate safeguards, violating the General Data Protection Regulation (GDPR). The investigation revealed that TikTok failed to ensure sufficient data protection measures once the data was transferred, posing significant risks under Chinese surveillance laws. &lt;/p&gt;

&lt;p&gt;💰 &lt;em&gt;European Commission's Breach with Microsoft 365:&lt;/em&gt; In March 2024, the European Data Protection Supervisor found that the European Commission's use of Microsoft 365 &lt;a href="https://www.edps.europa.eu/press-publications/press-news/press-releases/2024/european-commissions-use-microsoft-365-infringes-data-protection-law-eu-institutions-and-bodies_en" rel="noopener noreferrer"&gt;infringed several key data protection rules&lt;/a&gt;. The Commission failed to provide appropriate safeguards for personal data transferred outside the EU/EEA, leading to a suspension order on data flows resulting from its use of Microsoft 365 to countries not covered by an adequacy decision. &lt;/p&gt;

&lt;p&gt;💰 &lt;em&gt;British Airways' £20 Million Fine:&lt;/em&gt; British Airways &lt;a href="https://www.theguardian.com/business/2020/oct/16/ba-fined-record-20m-for-customer-data-breach" rel="noopener noreferrer"&gt;faced a £20 million fine&lt;/a&gt; from the UK's Information Commissioner's Office after a 2018 data breach compromised the personal data of over 400,000 customers. The breach was attributed to poor security arrangements, including the storage of payment card details in plaintext and the use of outdated software, highlighting the airline's failure to protect customer data adequately. &lt;/p&gt;

&lt;p&gt;The moral: &lt;strong&gt;HIPAA and GDPR compliance&lt;/strong&gt; in the cloud isn’t automatic—and it certainly isn’t cheap. Keeping sensitive data on-premise, where access and residency are explicitly controlled, isn't just prudent—it might be the only defensible option when auditors come knocking.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. On-Prem Is Easier to Predict and Debug
&lt;/h2&gt;

&lt;p&gt;Multi-tenant clouds suffer from "noisy neighbors," surprise throttling, and vague incidents. With bare metal, what you provision is what you get.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;2025 report by Azul Systems&lt;/strong&gt; &lt;a href="https://www.cio.com/article/3957766/cios-are-overspending-on-the-cloud-but-still-think-its-worth-it.html" rel="noopener noreferrer"&gt;found that&lt;/a&gt; &lt;strong&gt;83% of CIOs overspent on the cloud&lt;/strong&gt;, and &lt;strong&gt;nearly half exceeded budgets by 25% or more&lt;/strong&gt;. You can’t fix what you can’t measure, and cloud abstraction blinds even the best teams.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. The Cloud Is Not Environmentally Holy
&lt;/h2&gt;

&lt;p&gt;The cloud is sold as green, but hyperscale datacenters consume enormous power, often sourced from fossil fuels. Meanwhile, localized, efficient, low-power on-premise servers (especially ARM-based) can be far more sustainable in specific workloads.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Reclaiming Infrastructure Is Moral
&lt;/h2&gt;

&lt;p&gt;Cloud Capital, a FinOps startup, recently raised $7.7M to combat what they estimate is a &lt;strong&gt;$344 billion/year overspending crisis&lt;/strong&gt; in cloud infrastructure, &lt;a href="https://techstartups.com/2025/04/24/cloud-capital-emerges-from-stealth-with-7-7m-to-tackle-the-344b-cloud-cost-crisis-for-cfos" rel="noopener noreferrer"&gt;projected to hit&lt;/a&gt; &lt;strong&gt;$1 trillion by 2030&lt;/strong&gt;. Their business exists because the DevOps toolchain forgot to add a budget dashboard.  &lt;/p&gt;

&lt;h2&gt;
  
  
  11. Only Rushed Software Farms Need DevOps Teams — And They're Expensive
&lt;/h2&gt;

&lt;p&gt;Let’s be blunt: &lt;strong&gt;DevOps is not cheap&lt;/strong&gt;. You're not just hiring engineers—you’re hiring toolchain babysitters, pipeline janitors, Kubernetes whisperers, and Slack war-room veterans. If your software team ships once a month — or doesn’t need to scale horizontally by Thursday — &lt;strong&gt;why mimic the deployment posture of a fintech unicorn?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Most businesses do not need that speed. They need uptime. They need audit trails. They need security. They do not need to pay $160K+ per year for someone to maintain Helm charts and debate YAML indentation style on GitHub.&lt;/p&gt;

&lt;p&gt;DevOps, in reality, serves urgency. But not every team should live in a permanent state of urgency. If you ship carefully and predictably, you don’t need a DevOps team — &lt;strong&gt;you need discipline and a good sysadmin&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  12. Everything Goes to Platforms
&lt;/h2&gt;

&lt;p&gt;What once ran on a server now lives in a platform. Version control? GitHub. Monitoring? Datadog. Deployments? Vercel. CI/CD? GHA &amp;amp; GitLab, until it breaks, then you’re Googling “runners stuck in pending”. The industry is becoming a patchwork of black boxes with dashboards.&lt;/p&gt;

&lt;p&gt;This isn't just infrastructure [as code] — &lt;strong&gt;it’s dependency&lt;/strong&gt;. You don’t maintain software anymore, you rent a slot in someone else’s stack. And every platform adds abstraction, latency, lock-in, and... another monthly invoice.&lt;/p&gt;

&lt;p&gt;Try doing it your way and you're suddenly unsupported, incompatible, or “non-compliant”. There's &lt;strong&gt;no oxygen left for homegrown DevOps&lt;/strong&gt; or pipelines-only “integrations”.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The industry has decided: DIY is dangerous&lt;/strong&gt;. Everything must be managed, billed, monitored — as a service.&lt;/p&gt;

&lt;p&gt;But this monoculture &lt;strong&gt;comes at a cost&lt;/strong&gt;. You lose understanding. You lose flexibility. And eventually, you lose the ability to build outside of someone else’s rules. What was once craft is now just configuration.&lt;/p&gt;

&lt;p&gt;On-prem systems, for all their grit, don’t hide from you. You know what it’s doing. You can tune it, fix it, or migrate it — without begging for API rate increases or watching a status page for two hours.&lt;/p&gt;

&lt;p&gt;Everything is becoming a platform. &lt;strong&gt;But platforms are not freedom&lt;/strong&gt;. They are permissioned productivity.&lt;/p&gt;

&lt;h2&gt;
  
  
  Epilogue: The Clouds Will Part
&lt;/h2&gt;

&lt;p&gt;Cloud isn’t evil. But it isn’t holy either. It’s just another tool. The problem is cultural: we've confused speed with value, outsourcing with maturity, and complexity with progress.  &lt;/p&gt;

&lt;p&gt;It’s time to land. Touch the machines again. Grab data back.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Cover pic: "Piano" (Klavír), 'Pat and Mat' Czech animation series by 'Krátký film Praha' studio.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>sysadmin</category>
      <category>myth</category>
    </item>
    <item>
      <title>Accelerating OpenCV with CUDA on Jetson Orin NX: A Complete Build Guide</title>
      <dc:creator>Roman Belshevitz</dc:creator>
      <pubDate>Fri, 21 Feb 2025 14:30:00 +0000</pubDate>
      <link>https://dev.to/rbelshevitz/accelerating-opencv-with-cuda-on-jetson-orin-nx-a-complete-build-guide-525j</link>
      <guid>https://dev.to/rbelshevitz/accelerating-opencv-with-cuda-on-jetson-orin-nx-a-complete-build-guide-525j</guid>
      <description>&lt;h2&gt;
  
  
  What do we have right out of the box?
&lt;/h2&gt;

&lt;p&gt;The NVIDIA Jetson Orin NX is a powerful, community recognized edge AI platform, designed for real-time computer vision and deep learning applications. &lt;/p&gt;

&lt;p&gt;While &lt;a href="https://developer.nvidia.com/embedded/jetpack-sdk-511" rel="noopener noreferrer"&gt;JetPack 5.1.x&lt;/a&gt; provides an optimized environment with CUDA, cuDNN, and TensorRT, the default &lt;strong&gt;OpenCV&lt;/strong&gt; package in Ubuntu’s repositories does not take full advantage of the GPU. This means that task such as object detection, video processing, and feature extraction &lt;strong&gt;runs primarily on the CPU&lt;/strong&gt;, significantly limiting performance.&lt;/p&gt;

&lt;p&gt;To unlock the full potential of OpenCV on the Orin NX, we need to build it from source with CUDA and cuDNN enabled. This ensures that image processing and deep learning workloads benefit from GPU acceleration, leading to significant speed improvements. In this guide, we will walk through the entire build process, from installing dependencies to verifying a successful installation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Choosing the Right OpenCV Version
&lt;/h2&gt;

&lt;p&gt;For JetPack 5.1.x on Ubuntu 20.04, the most robust OpenCV versions are &lt;strong&gt;4.5.5&lt;/strong&gt; and &lt;strong&gt;4.6.0&lt;/strong&gt;. These versions have been tested extensively with CUDA 11 and cuDNN, ensuring compatibility and stability. While newer versions, such as 4.7.x and 4.8.x, are available, they may require additional patches and modifications to work seamlessly on Jetson hardware. I recommend sticking with 4.5.5 unless specific features from newer releases are needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building OpenCV with CUDA
&lt;/h2&gt;

&lt;p&gt;Before we start, it's important to remove any pre-installed OpenCV versions that might interfere with our custom build. &lt;/p&gt;

&lt;p&gt;The default &lt;code&gt;python3-opencv&lt;/code&gt; package from Ubuntu repositories is &lt;em&gt;CPU-only&lt;/em&gt; and does not support CUDA acceleration. To avoid conflicts, remove it along with other OpenCV-related packages:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt remove --purge -y libopencv-dev libopencv-core-dev libopencv-imgproc-dev python3-opencv
sudo apt autoremove -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After building OpenCV, we must ensure Python correctly loads the CUDA-enabled version. We will set up the &lt;code&gt;PYTHONPATH&lt;/code&gt; accordingly.&lt;/p&gt;

&lt;p&gt;For the Jetson Orin NX, which uses the Ampere architecture, you should adjust the &lt;code&gt;CUDA_ARCH_BIN&lt;/code&gt; to &lt;code&gt;8.7&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;💥 Please keep in mind that you will need to download about six hundreds megabytes of packages from the Internet! One &lt;code&gt;libcudnn8-dev&lt;/code&gt; package alone weighs 397 MB!&lt;/p&gt;

&lt;p&gt;The following Bash script automates the entire process, ensuring a seamless installation of OpenCV with CUDA and Python bindings.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;

&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt;  &lt;span class="c"&gt;# Exit on error&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-x&lt;/span&gt;  &lt;span class="c"&gt;# Debug mode (prints each command)&lt;/span&gt;

&lt;span class="c"&gt;# Define OpenCV version&lt;/span&gt;
&lt;span class="nv"&gt;OPENCV_VERSION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"4.5.5"&lt;/span&gt;

&lt;span class="c"&gt;# Update system packages&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;apt upgrade &lt;span class="nt"&gt;-y&lt;/span&gt;

&lt;span class="c"&gt;# Install required dependencies&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; build-essential pv cmake ccache git unzip pkg-config &lt;span class="se"&gt;\&lt;/span&gt;
    libjpeg-dev libpng-dev libtiff-dev libavcodec-dev libavformat-dev &lt;span class="se"&gt;\&lt;/span&gt;
    libswscale-dev libv4l-dev v4l-utils libxvidcore-dev libx264-dev &lt;span class="se"&gt;\&lt;/span&gt;
    libgtk-3-dev libcanberra-gtk3-dev libtbb2 libtbb-dev libdc1394-22-dev &lt;span class="se"&gt;\&lt;/span&gt;
    python3-dev python3-numpy python3-pip libopenblas-dev libopenjp2-7-dev liblapack-dev gfortran &lt;span class="se"&gt;\&lt;/span&gt;
    libhdf5-dev libcudnn8-dev

&lt;span class="c"&gt;# Clone OpenCV and contrib modules&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; ~
git clone &lt;span class="nt"&gt;--branch&lt;/span&gt; &lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;OPENCV_VERSION&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt; https://github.com/opencv/opencv.git
git clone &lt;span class="nt"&gt;--branch&lt;/span&gt; &lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;OPENCV_VERSION&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt; https://github.com/opencv/opencv_contrib.git

&lt;span class="c"&gt;# Create build directory&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; ~/opencv
&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; build &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd &lt;/span&gt;build

&lt;span class="c"&gt;# Configure CMake with CUDA, cuDNN, and TensorRT&lt;/span&gt;
cmake &lt;span class="nt"&gt;-D&lt;/span&gt; &lt;span class="nv"&gt;CMAKE_BUILD_TYPE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;RELEASE &lt;span class="se"&gt;\&lt;/span&gt;
      &lt;span class="nt"&gt;-D&lt;/span&gt; &lt;span class="nv"&gt;CMAKE_INSTALL_PREFIX&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/local &lt;span class="se"&gt;\&lt;/span&gt;
      &lt;span class="nt"&gt;-D&lt;/span&gt; &lt;span class="nv"&gt;OPENCV_EXTRA_MODULES_PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;~/opencv_contrib/modules &lt;span class="se"&gt;\&lt;/span&gt;
      &lt;span class="nt"&gt;-D&lt;/span&gt; &lt;span class="nv"&gt;WITH_CUDA&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ON &lt;span class="se"&gt;\&lt;/span&gt;
      &lt;span class="nt"&gt;-D&lt;/span&gt; &lt;span class="nv"&gt;CUDA_ARCH_BIN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;8.7 &lt;span class="se"&gt;\&lt;/span&gt;
      &lt;span class="nt"&gt;-D&lt;/span&gt; &lt;span class="nv"&gt;CUDA_ARCH_PTX&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
      &lt;span class="nt"&gt;-D&lt;/span&gt; &lt;span class="nv"&gt;WITH_CUDNN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ON &lt;span class="se"&gt;\&lt;/span&gt;
      &lt;span class="nt"&gt;-D&lt;/span&gt; &lt;span class="nv"&gt;OPENCV_DNN_CUDA&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ON &lt;span class="se"&gt;\&lt;/span&gt;
      &lt;span class="nt"&gt;-D&lt;/span&gt; &lt;span class="nv"&gt;ENABLE_FAST_MATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ON &lt;span class="se"&gt;\&lt;/span&gt;
      &lt;span class="nt"&gt;-D&lt;/span&gt; &lt;span class="nv"&gt;CUDA_FAST_MATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ON &lt;span class="se"&gt;\&lt;/span&gt;
      &lt;span class="nt"&gt;-D&lt;/span&gt; &lt;span class="nv"&gt;WITH_CUBLAS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ON &lt;span class="se"&gt;\&lt;/span&gt;
      &lt;span class="nt"&gt;-D&lt;/span&gt; &lt;span class="nv"&gt;WITH_V4L&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ON &lt;span class="se"&gt;\&lt;/span&gt;
      &lt;span class="nt"&gt;-D&lt;/span&gt; &lt;span class="nv"&gt;WITH_LIBV4L&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ON &lt;span class="se"&gt;\&lt;/span&gt;
      &lt;span class="nt"&gt;-D&lt;/span&gt; &lt;span class="nv"&gt;WITH_OPENGL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ON &lt;span class="se"&gt;\&lt;/span&gt;
      &lt;span class="nt"&gt;-D&lt;/span&gt; &lt;span class="nv"&gt;BUILD_OPENCV_PYTHON3&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ON &lt;span class="se"&gt;\&lt;/span&gt;
      &lt;span class="nt"&gt;-D&lt;/span&gt; &lt;span class="nv"&gt;BUILD_EXAMPLES&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;OFF &lt;span class="se"&gt;\&lt;/span&gt;
      &lt;span class="nt"&gt;-D&lt;/span&gt; &lt;span class="nv"&gt;BUILD_TESTS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;OFF &lt;span class="se"&gt;\&lt;/span&gt;
      &lt;span class="nt"&gt;-D&lt;/span&gt; &lt;span class="nv"&gt;BUILD_DOCS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;OFF &lt;span class="se"&gt;\&lt;/span&gt;
      &lt;span class="nt"&gt;-D&lt;/span&gt; &lt;span class="nv"&gt;BUILD_PERF_TESTS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;OFF &lt;span class="se"&gt;\ &lt;/span&gt;
      &lt;span class="nt"&gt;-D&lt;/span&gt; &lt;span class="nv"&gt;CMAKE_C_COMPILER_LAUNCHER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ccache &lt;span class="se"&gt;\&lt;/span&gt;
      &lt;span class="nt"&gt;-D&lt;/span&gt; &lt;span class="nv"&gt;CMAKE_CXX_COMPILER_LAUNCHER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ccache ..

&lt;span class="c"&gt;# Compile OpenCV using all CPU cores&lt;/span&gt;
&lt;span class="nv"&gt;TOTAL_CPP&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;find ~/opencv ~/opencv_contrib/modules &lt;span class="nt"&gt;-name&lt;/span&gt; &lt;span class="s2"&gt;"*.cpp"&lt;/span&gt; | &lt;span class="nb"&gt;wc&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
make &lt;span class="nt"&gt;-j&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;nproc&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt; | pv &lt;span class="nt"&gt;-lep&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;TOTAL_CPP&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;# Install OpenCV&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;make &lt;span class="nb"&gt;install
sudo &lt;/span&gt;ldconfig

&lt;span class="c"&gt;# Verify installation&lt;/span&gt;
python3 &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"import cv2; print(cv2.getBuildInformation())"&lt;/span&gt;

&lt;span class="c"&gt;# Ensure Python recognizes the new OpenCV installation&lt;/span&gt;
&lt;span class="nv"&gt;PYTHON_VERSION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;python3 &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"import sys; print('python'+sys.version[:3])"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"export PYTHONPATH=/usr/local/lib/&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;PYTHON_VERSION&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/site-packages:&lt;/span&gt;&lt;span class="se"&gt;\$&lt;/span&gt;&lt;span class="s2"&gt;PYTHONPATH"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.bashrc
&lt;span class="nb"&gt;source&lt;/span&gt; ~/.bashrc

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"✅ OpenCV &lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;OPENCV_VERSION&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; built and installed with CUDA!"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here &lt;code&gt;ccache&lt;/code&gt; (Compiler Cache) speeds up compilation by storing previously compiled object files and reusing them when no source code changes occur. This is useful when frequently tweaking settings &lt;em&gt;or rebuilding&lt;/em&gt; OpenCV.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is this all for?
&lt;/h2&gt;

&lt;p&gt;Building OpenCV from source with CUDA support on the Jetson Orin NX is &lt;strong&gt;an essential optimization&lt;/strong&gt; for developers working with real-time image processing and AI applications. By &lt;strong&gt;leveraging the GPU&lt;/strong&gt; for operations such as object detection, background subtraction, and feature extraction, &lt;a href="https://opencv.org/platforms/cuda/" rel="noopener noreferrer"&gt;performance can improve&lt;/a&gt; &lt;strong&gt;by 5-10x&lt;/strong&gt; compared to CPU-only execution.&lt;/p&gt;

&lt;p&gt;This custom-built OpenCV version seamlessly integrates with Python, ensuring that developers can access GPU acceleration without changing their existing OpenCV-based code. Whether you are deploying deep learning models, processing high-resolution video streams, or performing complex computer vision tasks, this optimized OpenCV installation ensures that your Orin NX operates at its maximum potential.&lt;/p&gt;

&lt;p&gt;With this approach and using the provided script, developers can streamline the build process and focus on developing CUDA-powered applications that take full advantage of NVIDIA's cutting-edge hardware.&lt;/p&gt;

&lt;h2&gt;
  
  
  Performance gain
&lt;/h2&gt;

&lt;p&gt;Motion tracking and optical flow are ~7-10x faster with CUDA. Moving object detection gets a 9x boost with CUDA. E.g. from ~12 &lt;strong&gt;up to 100 FPS&lt;/strong&gt;. Recalling relatively simple tasks, it is also worth noting that CUDA provides a 5x–10x speed boost for basic image processing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wait, does NVIDIA’s TensorRT or DeepStream need OpenCV?
&lt;/h2&gt;

&lt;p&gt;TensorRT is a library for optimized deep learning inference on GPUs. It &lt;em&gt;does not need OpenCV&lt;/em&gt;, as it processes models (YOLO, ResNet, etc.) directly. You interact with TensorRT using Python (&lt;code&gt;tensorrt&lt;/code&gt; package) or C++. If you need preprocessing (e.g., image resizing, normalization), OpenCV can help but isn’t required.&lt;/p&gt;

&lt;p&gt;DeepStream is a full pipeline for video analytics using TensorRT + GStreamer. If you use DeepStream’s GStreamer-based pipeline, &lt;em&gt;OpenCV is optional&lt;/em&gt;. However, if you’re post-processing model output (e.g., drawing bounding boxes), OpenCV can be useful.&lt;/p&gt;

&lt;p&gt;🤖🔎👀 Wishing you keen machine vision! &lt;/p&gt;

&lt;p&gt;Technical specs sources:&lt;br&gt;
a. &lt;a href="https://developer.nvidia.com/cuda-gpus" rel="noopener noreferrer"&gt;https://developer.nvidia.com/cuda-gpus&lt;/a&gt;&lt;br&gt;
b. &lt;a href="https://developer.download.nvidia.com/assets/embedded/secure/jetson/orin_nx/docs/Jetson_Orin_NX_DS-10712-001_v0.5.pdf" rel="noopener noreferrer"&gt;https://developer.download.nvidia.com/assets/embedded/secure/jetson/orin_nx/docs/Jetson_Orin_NX_DS-10712-001_v0.5.pdf&lt;/a&gt;&lt;br&gt;
c. &lt;a href="https://arnon.dk/matching-sm-architectures-arch-and-gencode-for-various-nvidia-cards/" rel="noopener noreferrer"&gt;https://arnon.dk/matching-sm-architectures-arch-and-gencode-for-various-nvidia-cards/&lt;/a&gt;&lt;br&gt;
d. &lt;a href="https://opencv.org/platforms/cuda/" rel="noopener noreferrer"&gt;https://opencv.org/platforms/cuda/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>nvidia</category>
      <category>jetson</category>
      <category>cuda</category>
      <category>opencv</category>
    </item>
    <item>
      <title>Finding the Right "Brain" and Software for Civilian Drone. Part 2</title>
      <dc:creator>Roman Belshevitz</dc:creator>
      <pubDate>Tue, 19 Mar 2024 13:51:51 +0000</pubDate>
      <link>https://dev.to/rbelshevitz/finding-the-right-brain-and-software-for-civilian-drone-part-2-4h12</link>
      <guid>https://dev.to/rbelshevitz/finding-the-right-brain-and-software-for-civilian-drone-part-2-4h12</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a continuation. The first part is &lt;a href="https://dev.to/rbalashevich/finding-the-right-brain-and-software-for-civilian-drone-2on4"&gt;here&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;There was a US-based company called Aerotenna about ten years ago that made FPGA-based drone controller platforms. They moved onto specializing in sensors specifically. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://aerotenna.readme.io/docs/unboxing" rel="noopener noreferrer"&gt;The OcPoC-Zynq by Aerotenna&lt;/a&gt; was conceived as a compelling flight controller for those seeking to push the boundaries of drone technology. &lt;/p&gt;

&lt;p&gt;It's compatibility with the open-source PX4 project could provide a robust foundation of reliability. &lt;/p&gt;

&lt;p&gt;Unfortunately, the complexity of the implementation (as it turned out, excessive) did not allow all this to come true.&lt;/p&gt;

&lt;h2&gt;
  
  
  Technical Specifications and Unique Features
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Hybrid Architecture
&lt;/h3&gt;

&lt;p&gt;The heart of the OcPoC-Zynq is a Zynq System-on-Chip (SoC), combining an ARM processor with a programmable Field-Programmable Gate Array (FPGA). &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fewv2rxrjhhyb9c7mhlkj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fewv2rxrjhhyb9c7mhlkj.png" alt=" " width="623" height="505"&gt;&lt;/a&gt;&lt;br&gt;
&lt;small&gt;&lt;em&gt;The similar Z-turn Board V2 schematic diagram. Pic source: Xilinx&lt;/em&gt;&lt;/small&gt;&lt;/p&gt;

&lt;p&gt;This grants immense flexibility for hardware acceleration and customization.&lt;/p&gt;

&lt;h3&gt;
  
  
  Processing Power
&lt;/h3&gt;

&lt;p&gt;The chosen Zynq SoC typically features a dual-core ARM Cortex-A9 processor and a sizeable FPGA fabric, ensuring both baseline flight control capabilities and room for advanced functionality.&lt;/p&gt;

&lt;h3&gt;
  
  
  Enhanced I/O
&lt;/h3&gt;

&lt;p&gt;The OcPoC-Zynq boasts numerous configurable input/output pins, supporting a multitude of sensor configurations, communication protocols, and potential payloads.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpsb21shnbhjul36uj4ss.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpsb21shnbhjul36uj4ss.png" alt=" " width="600" height="599"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Sensor Redundancy
&lt;/h3&gt;

&lt;p&gt;To maximize reliability, the OcPoC-Zynq declared of support triple redundancy on important sensors like the GPS, IMU, and magnetometer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp5lr8cok7ocjo7qbs7ek.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp5lr8cok7ocjo7qbs7ek.png" alt=" " width="800" height="533"&gt;&lt;/a&gt;&lt;br&gt;
&lt;small&gt;&lt;em&gt;The OcPoC-Zynq is a FPGA+ARM SoC based flight control platform mounted on a drone.&lt;/em&gt;&lt;/small&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  A developer-oriented solution
&lt;/h2&gt;

&lt;p&gt;Just replacing an embedded MCU with an FPGA would be a step backward. However, FPGA's are far better suited to perform functions such as high bandwidth digital signal processing. However, these specifications create a platform where possibilities extend beyond traditional flight controllers. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The FPGA emerges as a space for hardware-level innovation. Instead of relying solely on the main processor, computationally demanding elements of the PX4 system, such as ones described below, could be offloaded to the FPGA. This distribution of tasks promised smoother flight performance and potential for more sophisticated features.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The FPGA's adaptability allows the OcPoC-Zynq &lt;a href="https://web.archive.org/web/20231128165753/https://aerotenna.readme.io/docs/ocpoctm-zynq-mini" rel="noopener noreferrer"&gt;to embrace custom sensors and specialized peripherals&lt;/a&gt;, propelling it beyond the limitations of standardized drone builds. This makes it particularly appealing within a research context, where the integration of experimental sensors or novel technologies is key. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Unfortunately, the site with the documentation was removed, some information is available in the cache of the "Web Archive".&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Perhaps most exciting is the potential the OcPoC-Zynq could have for advanced autonomous flight. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwojq8r7fh81kv92zwqyw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwojq8r7fh81kv92zwqyw.png" alt=" " width="800" height="424"&gt;&lt;/a&gt;&lt;br&gt;
&lt;small&gt;&lt;em&gt;Architecture model for a reconfigurable autopilot board. Source: &lt;a href="https://www.mdpi.com/1424-8220/21/4/1115" rel="noopener noreferrer"&gt;Queensland University of Technology&lt;/a&gt;&lt;/em&gt;&lt;/small&gt;&lt;/p&gt;

&lt;p&gt;The FPGA's processing power offers the opportunity to run AI algorithms directly on the drone. This localizes decision-making processes, potentially leading to real-time obstacle avoidance, sophisticated vision-based navigation, and previously unimaginable flight behaviors.&lt;/p&gt;

&lt;p&gt;The OcPoC flight controller isn't just specialized hardware; it runs a full-fledged operating system (i.e Ubuntu &lt;code&gt;armhf&lt;/code&gt;) on its Zynq-7010 ARM processor. This allows it to use standard Linux-based flight control software.&lt;/p&gt;

&lt;p&gt;You still can &lt;a href="https://github.com/Aerotenna/OcPoC_Mini_Zynq_Files" rel="noopener noreferrer"&gt;clone the repository&lt;/a&gt; and customize your kernel to your specific project using Xilinx's &lt;code&gt;linux-xlnx&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Some functions where the FPGA could be used in a drone
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Sensors
&lt;/h3&gt;

&lt;p&gt;High accuracy Kalman Filter/Inertial Measurement Unit (EKF/IMU). This would take input from &lt;a href="https://www.ndigital.com/6dof-explained/" rel="noopener noreferrer"&gt;a 6DOF sensor&lt;/a&gt; and provide tracking in flight.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cameras
&lt;/h3&gt;

&lt;p&gt;Video processing from multiple cameras. A single DSP is adequate for one camera input. But, multiple cameras would require an FPGA due to the high bandwidth requirement. So, you could do &lt;a href="https://github.com/Aerotenna/OcPoC_Mini_Zynq_Files/blob/3f03e50e0933fdf9934c262014f87c6c7c17a8e5/Kernel_Config/ocpoc_defconfig#L2239" rel="noopener noreferrer"&gt;some stereo-vision&lt;/a&gt; and &lt;a href="https://www.irjet.net/archives/V7/i1/IRJET-V7I189.pdf" rel="noopener noreferrer"&gt;🗎 object recognition&lt;/a&gt; using the FPGA.&lt;/p&gt;

&lt;h2&gt;
  
  
  The further fate of the solution
&lt;/h2&gt;

&lt;p&gt;It's important to note that unlocking the full potential of the OcPoC-Zynq requires a degree of development expertise. Customizing the FPGA involves  hardware design skills, and careful integration with PX4 software might be necessary to fully realize the benefits of hardware acceleration. &lt;/p&gt;

&lt;p&gt;Nonetheless, the Aerotenna OcPoC-Zynq served as an interesting exceptional platform for researchers and innovators eager to shape the future of drone technology within the dynamic PX4 landscape.&lt;/p&gt;

&lt;p&gt;Unfortunately, there is no news today about the development of this project. The project has been discontinued and is no longer commercially available.&lt;/p&gt;

&lt;p&gt;PX4 v1.11 is the last release that has experimental support for this platform.&lt;/p&gt;

&lt;p&gt;So there are certainly use cases for FPGA on flight controllers, and the author reviewed one of them here. &lt;/p&gt;

&lt;p&gt;Performing checksums on the sensors data interface, digital filters and cameras signal processing - these are small tasks that could be outsourced to the FPGA, since they are expensive on the CPU.&lt;/p&gt;

&lt;p&gt;Yet, flying &lt;em&gt;is still a relatively slow process&lt;/em&gt; with little data, so regular ARM CPUs can keep up. Compared to high speed video processing.&lt;/p&gt;

&lt;p&gt;Also, development for an FPGA is more expensive. The parts are pricey, high pin count thus the boards are expensive (&amp;gt; 2 layers) and the design software is expensive. Overall, development costs more time, and time is money.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Moreover, most modern ARM MCUs offer an attractively good balance of performance and affordability. They are readily available, well-supported, and cost less than FPGA-based solutions.&lt;/p&gt;

&lt;p&gt;In addition, over the decade, a large number of dedicated video transmission and processing modules have appeared on the market, taking on these tasks entirely.&lt;/p&gt;

&lt;p&gt;Thus, we can say that highly integrated ARM MCU solutions have gained the upper hand today, at least in the civil mass drone segment.&lt;/p&gt;

</description>
      <category>embedded</category>
      <category>drones</category>
      <category>zynq</category>
    </item>
    <item>
      <title>Finding the Right "Brain" and Software for Civilian Drone. Part 1</title>
      <dc:creator>Roman Belshevitz</dc:creator>
      <pubDate>Fri, 15 Mar 2024 20:36:52 +0000</pubDate>
      <link>https://dev.to/rbelshevitz/finding-the-right-brain-and-software-for-civilian-drone-2on4</link>
      <guid>https://dev.to/rbelshevitz/finding-the-right-brain-and-software-for-civilian-drone-2on4</guid>
      <description>&lt;p&gt;&lt;em&gt;This is like a beginning. See part 2 &lt;a href="https://dev.to/rbalashevich/finding-the-right-brain-and-software-for-civilian-drone-part-2-4h12"&gt;here&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Unmanned Aerial Vehicles (UAVs), colloquially known as drones, have revolutionized industries ranging from agriculture and construction to surveillance and logistics. &lt;/p&gt;

&lt;p&gt;This transformative potential hinges on the intricate interplay between hardware components and software systems. At the heart of this symbiotic relationship lies the Microcontroller Unit (MCU), an indispensable component orchestrating the UAV's operations. However, the efficacy of UAVs is contingent upon the selection of an appropriate MCU and the deployment of a robust operating system tailored to their unique operational exigencies.&lt;/p&gt;

&lt;h2&gt;
  
  
  Specialized Operating Requirements of UAVs
&lt;/h2&gt;

&lt;p&gt;UAVs operate in dynamic and resource-constrained environments, necessitating operating systems that diverge from traditional paradigms. Unlike desktop computers or laptops, UAVs prioritize power efficiency to maximize flight time, embodying stringent constraints on memory and processing capabilities. Real-time responsiveness assumes paramount importance to ensure flight stability, thereby demanding operating systems that offer deterministic timing and swift reaction to dynamic environmental stimuli.&lt;/p&gt;

&lt;h2&gt;
  
  
  Real-Time Operating Systems: A Tailored Solution
&lt;/h2&gt;

&lt;p&gt;Real-Time Operating Systems (RTOS) have emerged as a tailored solution to address the specialized operational requirements of UAVs. By offering deterministic timing and efficient resource utilization, RTOSes facilitate the seamless execution of critical tasks such as flight control and sensor management. Popular RTOS choices, including &lt;a href="https://www.st.com/content/st_com/en/support/learning/stm32-education/stm32-moocs/freertos-common-microcontroller-software-interface-standard-osv2.html" rel="noopener noreferrer"&gt;FreeRTOS&lt;/a&gt;, &lt;a href="https://hmchung.gitbooks.io/stm32-tutorials/content/nuttx-installation.html" rel="noopener noreferrer"&gt;NuttX&lt;/a&gt;, &lt;a href="https://www.chibios.org/dokuwiki/doku.php?id=chibios:documentation:start" rel="noopener noreferrer"&gt;ChibiOS&lt;/a&gt;, &lt;a href="https://docs.zephyrproject.org/latest/boards/index.html" rel="noopener noreferrer"&gt;Zephyr&lt;/a&gt; and &lt;a href="https://www.rt-thread.io/board.html" rel="noopener noreferrer"&gt;RT-Thread&lt;/a&gt; offer varying strengths in terms of size, security, and hardware support, catering to diverse UAV projects.&lt;/p&gt;

&lt;h2&gt;
  
  
  STM32: A Preferred MCU for UAV Development
&lt;/h2&gt;

&lt;p&gt;The STM32 family of MCUs has garnered widespread acclaim in the realm of UAV development due to its versatility and performance capabilities. With a plethora of options catering to diverse application scenarios, STM32 MCUs offer seamless integration with various RTOS options, thereby enhancing flexibility and scalability in UAV development endeavors.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hardware Abstraction Layers: Facilitating Portability and Focus
&lt;/h2&gt;

&lt;p&gt;Hardware Abstraction Layers (HALs) play a pivotal role in bridging the firmware and hardware components of UAV systems. By encapsulating low-level hardware details and providing a standardized interface, HALs facilitate portability, allowing firmware such as Ardupilot to run seamlessly across different MCUs and RTOSes. Furthermore, HALs enable firmware developers to focus on high-level tasks such as navigation and sensor fusion, thereby enhancing development efficiency and code maintainability.&lt;/p&gt;

&lt;h2&gt;
  
  
  Vendors' Role in HAL Provisioning
&lt;/h2&gt;

&lt;p&gt;Semiconductor vendors, exemplified by STMicroelectronics for the STM32 MCUs family, play a crucial role in providing and maintaining Hardware Abstraction Layers (HALs). One of the pivotal reasons for the widespread adoption of STM32 microcontrollers in civilian drone applications is &lt;a href="https://www.st.com/resource/en/user_manual/dm00173145-description-of-stm32l4-l4-hal-and-low-layer-drivers-stmicroelectronics.pdf" rel="noopener noreferrer"&gt;🗎 their robust support&lt;/a&gt; for various communication buses and protocols, which are essential for facilitating seamless integration with a wide range of peripheral devices and external sensors.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.st.com/en/microcontrollers-microprocessors/stm32-32-bit-arm-cortex-mcus.html" rel="noopener noreferrer"&gt;STM32 MCUs&lt;/a&gt; boast extensive support for industry-standard communication interfaces, including Universal Asynchronous Receiver-Transmitter (UART), Serial Peripheral Interface (SPI), Inter-Integrated Circuit (I2C), Controller Area Network (CAN), and USB. These communication interfaces enable UAV developers to establish reliable and high-speed data exchange with external components, such as GPS modules, inertial measurement units (IMUs), cameras, and telemetry systems.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhz7cev9kx1bqrdgyjo2z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhz7cev9kx1bqrdgyjo2z.png" alt=" " width="800" height="835"&gt;&lt;/a&gt;&lt;br&gt;
&lt;small&gt;&lt;em&gt;Pic source: st.com&lt;/em&gt;&lt;/small&gt; 🔎&lt;/p&gt;

&lt;p&gt;Furthermore, STM32 microcontrollers feature built-in support for popular communication protocols commonly used in UAV applications. This includes protocols such as MAVLink, which facilitates communication between onboard flight controllers and ground control stations, as well as protocols like I2C and SPI for interfacing with peripheral sensors and devices.&lt;/p&gt;

&lt;p&gt;By offering comprehensive support for communication buses and protocols, STMicroelectronics empowers drone-makers to build highly interconnected and interoperable UAV systems. This enables seamless integration of diverse sensor arrays, payload systems, and communication modules, thereby enhancing the functionality, versatility, and performance of civilian drones. &lt;/p&gt;

&lt;p&gt;With STM32 MCUs as the backbone of UAV development, drone-makers can involve a rich ecosystem of communication interfaces and protocols to realize their vision of advanced and mission-critical drone applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Zynq UltraScale+ platform, developed by Xilinx (now AMD)
&lt;/h2&gt;

&lt;p&gt;This solution offers several distinct advantages for drone making, particularly in scenarios that demand high computational power, flexibility, and integration of custom hardware accelerators. Below are some key advantages of the Zynq platform for drone development:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.xilinx.com/products/silicon-devices/soc/zynq-ultrascale-mpsoc.html" rel="noopener noreferrer"&gt;Zynq UltraScale+&lt;/a&gt; combines the processing capabilities of Cortex-A53 application processors with the programmable logic of FPGA (Field-Programmable Gate Array) fabric on a single chip. This hybrid architecture &lt;a href="https://linuxgizmos.com/drone-controller-board-runs-linux-on-zynq-ultrascale/" rel="noopener noreferrer"&gt;enables developers to implement custom hardware accelerators&lt;/a&gt; in the FPGA fabric to offload computationally intensive tasks from the CPU, thereby enhancing overall system performance and efficiency.&lt;/p&gt;

&lt;p&gt;Being built on the industry success of the Zynq 7000 SoC family, the UltraScale+ MPSoC architecture extends AMD SoCs to enable true heterogeneous multi-processing with ‘the right engines for the right tasks’ for smarter systems&lt;/p&gt;

&lt;p&gt;The ARM Cortex-A53 processors integrated into the Zynq UltraScale+ provide significant computational power, enabling drones to execute complex algorithms for tasks such as image processing, computer vision, sensor fusion, and autonomous navigation. This high computational capability is crucial for enabling advanced drone functionalities, including obstacle detection and avoidance, object tracking, and environmental mapping.&lt;/p&gt;

&lt;p&gt;The programmable logic fabric of the Zynq platform allows developers to implement custom hardware accelerators tailored to specific drone applications. The flexibility of FPGAs allows developers to customize algorithms and processing pipelines, unlocking unique capabilities for specialized drone missions. &lt;/p&gt;

&lt;p&gt;Additionally, the reconfigurability of FPGAs enables rapid prototyping and iteration, facilitating agile development processes in the fast-paced UAV industry.&lt;/p&gt;

&lt;p&gt;The Zynq platform offers low-latency processing capabilities, making it suitable for real-time applications in drone control and navigation. By deploying critical control and decision-making algorithms on the ARM processors and offloading latency-sensitive tasks to the FPGA fabric, developers can achieve high responsiveness and stability in drone flight operations.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9a6ina95ffsianoufz9q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9a6ina95ffsianoufz9q.png" alt=" " width="800" height="677"&gt;&lt;/a&gt;&lt;br&gt;
&lt;small&gt;&lt;em&gt;Pic source: &lt;a href="https://linuxgizmos.com/drone-controller-board-runs-linux-on-zynq-ultrascale/" rel="noopener noreferrer"&gt;linuxgizmos.com&lt;/a&gt;&lt;/em&gt;&lt;/small&gt;&lt;/p&gt;

&lt;p&gt;The platform features a rich set of peripheral interfaces, including GPIOs, UARTs, SPI, I2C, USB and MIPI facilitating seamless integration with a wide range of sensors, actuators, communication modules, and external devices. This extensive peripheral support simplifies the development of fully integrated drone systems and enables interoperability with existing UAV components and standards.&lt;/p&gt;

&lt;p&gt;The Zynq platform is available in various configurations with different processing capabilities and FPGA resources, allowing developers to choose the optimal combination of performance and cost for their drone applications. Whether designing lightweight drones for aerial photography or high-end UAVs for surveillance and reconnaissance missions, developers can select the Zynq device that best aligns with their performance requirements and budget constraints.&lt;/p&gt;

&lt;p&gt;Xilinx (the maker of Zynq UltraScale+ devices) &lt;a href="https://docs.amd.com/r/en-US/oslib_rm" rel="noopener noreferrer"&gt;provides a comprehensive HAL&lt;/a&gt; as part of their software development tools and frameworks. The primary HAL access point is usually through the Xilinx SDK. It includes libraries and drivers for the various hardware blocks within Zynq UltraScale+ SoCs, including the ARM processor cores, programmable logic, and peripherals.&lt;/p&gt;

&lt;p&gt;A talented Javanese engineer &lt;a href="https://github.com/ikwzm/ZynqMP-FPGA-Linux" rel="noopener noreferrer"&gt;Ichiro Kawazome has composed the repository&lt;/a&gt; which provides a Linux boot image (U-boot bootloader, kernel, RootFS) for Zynq UltraScale+ MPSoC.&lt;/p&gt;

&lt;h2&gt;
  
  
  Target Applications
&lt;/h2&gt;

&lt;p&gt;STM32 microcontrollers are ideal for lightweight drones, flight controllers, and embedded systems where power efficiency, real-time responsiveness, and cost-effectiveness are paramount.&lt;/p&gt;

&lt;p&gt;Zynq is suitable for drone applications that require high computational power, flexibility, and customization, such as autonomous navigation, advanced image processing, and real-time decision-making.&lt;/p&gt;

&lt;p&gt;The choice between Zynq and STM32 depends on the specific requirements of the drone application, including computational complexity, power efficiency, real-time performance, and system integration needs. While STM32 MCUs excel in low-power operation and real-time responsiveness, making them suitable for a wide range of embedded applications, including drones, Zynq offers higher computational power and hardware customization capabilities.  &lt;/p&gt;

&lt;p&gt;Zynq offers significantly higher computational power compared to STM32 microcontrollers, thanks to its ARM application processors and FPGA fabric.&lt;/p&gt;

&lt;p&gt;Developers can create customized Linux distributions tailored for Zynq-based drones, integrating necessary drivers, libraries, and applications for drone control, sensor interfacing, and communication. This approach offers flexibility and control over the software stack but requires significant development effort.&lt;/p&gt;

&lt;h2&gt;
  
  
  Delineating OS and Firmware: A Conceptual Framework
&lt;/h2&gt;

&lt;p&gt;In the architectural hierarchy of UAV systems, the RTOS serves as the foundational layer, orchestrating task scheduling, resource allocation, and timing management. RTOSes can be remarkably small, especially ones designed for the strict memory constraints of embedded systems.&lt;/p&gt;

&lt;p&gt;The HAL, influenced by the MCU vendor, provides a standardized interface for firmware interaction, encapsulating hardware intricacies and enhancing portability.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdlszwhh2apoijjwkaljj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdlszwhh2apoijjwkaljj.png" alt=" " width="704" height="453"&gt;&lt;/a&gt;&lt;br&gt;
&lt;small&gt;&lt;em&gt;The most common structure of the existing flight controller firmware, which consists of layers and modules. Pic source: &lt;a href="https://www.mdpi.com/2226-4310/9/2/62" rel="noopener noreferrer"&gt;Gyeongsang National University, Rep. of Korea&lt;/a&gt;&lt;/em&gt;&lt;/small&gt;&lt;/p&gt;

&lt;p&gt;Firmware, typified by Ardupilot or PX4, operates at a higher level, focusing on flight control, navigation, and hardware interfacing, thereby delineating the boundaries between OS and application-specific functionalities.&lt;/p&gt;

&lt;p&gt;ChibiOS is hidden under the hood of Ardupilot, while what's in the same role for PX4 is NuttX.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft2mwi7bihmfaaz1s5wjk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft2mwi7bihmfaaz1s5wjk.png" alt=" " width="800" height="718"&gt;&lt;/a&gt;&lt;br&gt;
&lt;small&gt;&lt;em&gt;A  high level overview of a typical "simple" PX4 system based around a flight controller. Pic source: &lt;a href="https://docs.px4.io/main/en/concept/px4_systems_architecture.html" rel="noopener noreferrer"&gt;docs.px4.io&lt;/a&gt;&lt;/em&gt;&lt;/small&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Is There a Place for Linux Above the Ground?
&lt;/h2&gt;

&lt;p&gt;While Real-Time Operating Systems (RTOS) like FreeRTOS, NuttX, and others have traditionally dominated the realm of civilian drone development due to their suitability for real-time responsiveness and resource optimization, the use of Linux-based platforms, particularly the Zynq platform, has also gained traction in certain niche applications within the UAV ecosystem.&lt;/p&gt;

&lt;p&gt;Linux offers several advantages for civilian drone applications, especially in scenarios where complex computational tasks, such as image processing, data analysis, or machine learning, are required. The Zynq platform, which combines the flexibility and ease of use of an ARM processor with the programmable logic capabilities of an FPGA, presents an attractive option for UAV developers looking to leverage the power of Linux in conjunction with customizable hardware acceleration.&lt;/p&gt;

&lt;p&gt;One area where Linux-based platforms like Zynq have found utility is in high-level mission planning, data processing, and decision-making tasks. For instance, Linux enables developers to deploy sophisticated algorithms for autonomous navigation, obstacle avoidance, and environmental mapping, leveraging the extensive software libraries and development tools available within the Linux ecosystem.&lt;/p&gt;

&lt;p&gt;Additionally, Linux-based platforms offer robust networking capabilities, allowing drones to communicate with ground control stations, cloud services, and other drones in a distributed manner. This facilitates collaborative missions, swarm behavior, and real-time data sharing, thereby expanding the scope of civilian drone applications beyond individual flight operations.&lt;/p&gt;

&lt;p&gt;However, it's essential to acknowledge that Linux-based solutions may not be suitable for all drone applications, particularly those that prioritize real-time responsiveness, low latency, and deterministic behavior. In such cases, RTOSes remain the preferred choice due to their ability to guarantee timing constraints and optimize resource utilization.&lt;/p&gt;

&lt;p&gt;Saying briefly, while RTOSes continue to dominate the civilian drone landscape, Linux-based platforms like Zynq offer a compelling alternative for certain niche applications that require advanced computational capabilities, networking features, and flexibility. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;As the UAV industry evolves and the demand for more sophisticated autonomous capabilities grows, the integration of Linux-based solutions alongside traditional RTOSes is likely to become increasingly prevalent, driving innovation and expanding the horizons of civilian drone technology.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The Spirit of Open-Source
&lt;/h2&gt;

&lt;p&gt;The following projects have become very significant within the discussed area of development and have gained a wide community over the past ten years:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ardupilot.org/" rel="noopener noreferrer"&gt;ArduPilot&lt;/a&gt; is a widely used open-source autopilot system for UAVs. It offers similar features to PX4, including flight control, mission planning, and telemetry support. ArduPilot supports a variety of airframes and can run on microcontroller-based flight controllers like Arduino boards.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://px4.io/" rel="noopener noreferrer"&gt;PX4 Autopilot&lt;/a&gt; is another popular open-source autopilot system for UAVs. It provides a complete set of flight control algorithms, mission planning tools, and communication protocols. PX4 supports a wide range of airframes and is highly customizable, making it suitable for both hobbyist and commercial UAV applications.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://mavlink.io/en/" rel="noopener noreferrer"&gt;MAVLink&lt;/a&gt; is an open-source communication protocol used for exchanging telemetry and control messages between UAVs and ground control stations. It provides a lightweight, efficient messaging format and supports various transport protocols, including serial, UDP, and TCP/IP.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://mavsdk.mavlink.io/main/en/index.html" rel="noopener noreferrer"&gt;MAVSDK&lt;/a&gt; (MAVLink Software Development Kit) is a cross-platform, open-source SDK for accessing MAVLink-based UAV systems programmatically. It provides APIs in multiple programming languages, including C++, Python, and Swift, making it suitable for a wide range of UAV applications.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://opencv.org/" rel="noopener noreferrer"&gt;OpenCV&lt;/a&gt; (Open Source Computer Vision Library) is a popular open-source computer vision library that is widely used in UAV applications for tasks such as object detection, tracking, and image processing. It provides a comprehensive set of algorithms and tools for working with visual data. The reader definitely have to take a look at &lt;a href="https://github.com/Kenil16/master_project" rel="noopener noreferrer"&gt;Kenni Nilsson's project&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://wiki.ros.org/" rel="noopener noreferrer"&gt;ROS&lt;/a&gt; (Robot Operating System) is an open-source robotics middleware framework that provides libraries and tools for building robotic systems. It includes packages for tasks such as sensor integration, localization, mapping, and path planning, &lt;a href="https://robots.ros.org/category/aerial/" rel="noopener noreferrer"&gt;which are applicable to UAVs as well&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://librepilot.atlassian.net/wiki/spaces/LPDOC/pages/2818105/Welcome" rel="noopener noreferrer"&gt;LibrePilot&lt;/a&gt;, an open-source flight control software for UAVs that offers a range of features including stabilization, navigation, and telemetry. It is designed to work with a variety of hardware platforms and offers extensive configurability and customization options.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.expresslrs.org/" rel="noopener noreferrer"&gt;ExpressLRS (ELRS)&lt;/a&gt; is a rapidly growing open-source radio control link designed to surpass the performance limitations of traditional systems. It prioritizes long range, low latency, and high update rates for applications like FPV drone racing and long-range aircraft. Users have extensive control over the firmware, allowing them to fine-tune parameters like transmission power, frequency bands, telemetry options, and much more. This level of customization caters to a variety of use cases.&lt;/p&gt;

&lt;h2&gt;
  
  
  Future Trajectory of Drone Software
&lt;/h2&gt;

&lt;p&gt;The trajectory of drone software is poised for significant advancements, propelled by burgeoning research endeavors in secure software engineering, artificial intelligence (AI), and programming language design. &lt;/p&gt;

&lt;p&gt;Anticipated advancements encompass the integration of AI algorithms for onboard decision-making, adoption of safer programming languages to mitigate system vulnerabilities, and enhancements in software security mechanisms to fortify UAV resilience against adversarial threats.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In conclusion, the selection of an appropriate MCU or SoC and the deployment of a tailored operating system constitute foundational pillars underpinning the efficacy and reliability of UAV systems. &lt;/p&gt;

&lt;p&gt;By embracing Real-Time Operating Systems (RTOS) and leveraging Hardware Abstraction Layers (HALs), developers can navigate the intricate landscape of UAV software development with confidence, ushering in a new era of innovation and transformative potential across diverse industry verticals.&lt;/p&gt;

&lt;p&gt;It is also difficult to overestimate the contribution of the open source community in popularizing drone-centric development!&lt;/p&gt;

&lt;p&gt;Soft landings and clear skies to everyone!&lt;/p&gt;

&lt;p&gt;&lt;small&gt;&lt;em&gt;Most sources are quite fully identified with links given inside the article.&lt;br&gt;Cover pic by Marian A. Juwan, Pixabay.&lt;/em&gt;&lt;/small&gt;&lt;/p&gt;

&lt;p&gt;&lt;small&gt;&lt;em&gt;See also: &lt;a href="https://www.digikey.co.il/en/maker/projects/getting-started-with-stm32-introduction-to-freertos/ad275395687e4d85935351e16ec575b1" rel="noopener noreferrer"&gt;'Getting Started with STM32 - Introduction to FreeRTOS'&lt;/a&gt;, a blog post by Shawn Hymel @ maker.io / DigiKey.&lt;/em&gt;&lt;/small&gt;&lt;/p&gt;

</description>
      <category>embedded</category>
      <category>drones</category>
      <category>stm32</category>
      <category>zynq</category>
    </item>
    <item>
      <title>32 Kernel’s Teeth for “Chewing” the Network Stack on Linux</title>
      <dc:creator>Roman Belshevitz</dc:creator>
      <pubDate>Mon, 29 May 2023 17:02:03 +0000</pubDate>
      <link>https://dev.to/rbelshevitz/32-kernels-teeth-for-chewing-the-network-stack-on-linux-lnc</link>
      <guid>https://dev.to/rbelshevitz/32-kernels-teeth-for-chewing-the-network-stack-on-linux-lnc</guid>
      <description>&lt;p&gt;The topic of tuning the network stack is very narrow and complex the same time. Today, many tips either do not match the current default settings. Some mechanisms are already included in modern kernels. Below is my compilation of what seems to be relevant at the moment. It's mostly about timeouts and memory consumption. There are a lot of them now and they are cheap.&lt;/p&gt;

&lt;p&gt;In this article I provide a set of recommended network configuration settings for optimizing TCP connections on a server. The suggested settings include adjusting parameters related to orphaned TCP sockets, reducing the timeout for sockets in the &lt;code&gt;FIN-WAIT-2&lt;/code&gt; state, configuring TCP keepalive checks, managing memory allocation for TCP connections, disabling syncookies, selecting a congestion control algorithm, expanding the local port range, enabling protection against &lt;code&gt;TIME_WAIT&lt;/code&gt; attacks, increasing the maximum number of open sockets, adjusting buffer sizes for connections, and optionally disabling local ICMP packet redirects. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;These discussed settings aim to improve performance, memory usage, and security on powerful and busy servers.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  1
&lt;/h3&gt;

&lt;p&gt;⚙️ Increase the value of &lt;code&gt;tcp_max_orphans&lt;/code&gt;, which determines the maximum number of orphaned (not associated with any process) TCP sockets. Each socket consumes approximately &lt;code&gt;64 KB&lt;/code&gt; of memory. Therefore, the parameter should be matched with the available memory on the server.&lt;br&gt;
&lt;code&gt;net.ipv4.tcp_max_orphans = 65536&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2
&lt;/h3&gt;

&lt;p&gt;⚙️ Decrease &lt;code&gt;tcp_fin_timeout&lt;/code&gt; (default is &lt;code&gt;60&lt;/code&gt;). This parameter determines the maximum time a socket can remain in the &lt;code&gt;FIN-WAIT-2&lt;/code&gt; state. This state is used when the other party does not close the connection. Each socket occupies about &lt;code&gt;1.5 KB&lt;/code&gt; of memory, which can consume memory when there are many of them.&lt;br&gt;
&lt;code&gt;net.ipv4.tcp_fin_timeout = 10&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3
&lt;/h3&gt;

&lt;p&gt;⚙️ Parameters related to TCP connection checks in the &lt;code&gt;SO_KEEPALIVE&lt;/code&gt; status: &lt;code&gt;keepalive_time&lt;/code&gt; specifies the time after which checks will begin after the last activity on the connection, &lt;code&gt;keepalive_intvl&lt;/code&gt; determines the interval between checks, and &lt;code&gt;keepalive_probes&lt;/code&gt; specifies the number of checks.&lt;br&gt;
&lt;code&gt;net.ipv4.tcp_keepalive_time = 1800&lt;/code&gt;&lt;br&gt;
&lt;code&gt;net.ipv4.tcp_keepalive_intvl = 15&lt;/code&gt;&lt;br&gt;
&lt;code&gt;net.ipv4.tcp_keepalive_probes = 5&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  4
&lt;/h3&gt;

&lt;p&gt;⚙️ Pay attention to the parameters &lt;code&gt;net.ipv4.tcp_mem&lt;/code&gt;, &lt;code&gt;net.ipv4.tcp_rmem&lt;/code&gt;, and &lt;code&gt;net.ipv4.tcp_wmem&lt;/code&gt;. They heavily depend on the memory available on the server and are automatically calculated during system load. In general, it is not necessary to modify them, but sometimes it is possible to manually adjust them to increase the values.&lt;/p&gt;

&lt;h3&gt;
  
  
  5
&lt;/h3&gt;

&lt;p&gt;⚙️ Disable (enabled by default) the transmission of syncookies to the host in case of &lt;code&gt;SYN&lt;/code&gt; packet queue overflow for a specific socket.&lt;br&gt;
&lt;code&gt;net.ipv4.tcp_syncookies = 0&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  6
&lt;/h3&gt;

&lt;p&gt;⚙️ Special attention should be given to the congestion control algorithm used in TCP networks. There are many algorithms (&lt;code&gt;cubic&lt;/code&gt;, &lt;code&gt;htcp&lt;/code&gt;, &lt;code&gt;bic&lt;/code&gt;, &lt;code&gt;westwood&lt;/code&gt;, etc.), and it is difficult to definitively say which one is better to use. Algorithms show different results in different load scenarios. The kernel parameter tcp_congestion_control controls this:&lt;br&gt;
&lt;code&gt;net.ipv4.tcp_congestion_control = cubic&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  7
&lt;/h3&gt;

&lt;p&gt;⚙️ When the server has a large number of outbound connections, there may not be enough local ports for them. By default, the range &lt;code&gt;32768-60999&lt;/code&gt; is used. It can be expanded:&lt;br&gt;
&lt;code&gt;net.ipv4.ip_local_port_range = 10240 65535&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  8
&lt;/h3&gt;

&lt;p&gt;⚙️ Enable protection against &lt;code&gt;TIME_WAIT&lt;/code&gt; attacks. By default, it is disabled.&lt;br&gt;
&lt;code&gt;net.ipv4.tcp_rfc1337 = 1&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  9
&lt;/h3&gt;

&lt;p&gt;⚙️ The maximum number of open sockets waiting for connections has a relatively low default value. In kernels prior to 5.3, it is &lt;code&gt;128&lt;/code&gt;, which was increased to &lt;code&gt;4096&lt;/code&gt; in kernel 5.4. It makes sense to increase it on busy and powerful servers:&lt;br&gt;
&lt;code&gt;net.core.somaxconn = 16384&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  10
&lt;/h3&gt;

&lt;p&gt;⚙️ On powerful and busy servers, you can increase the default buffer size values for both receiving and transmitting for all connections. This parameter is measured in bytes. By default, it is &lt;code&gt;212992&lt;/code&gt; or &lt;code&gt;208 KB&lt;/code&gt;.&lt;br&gt;
&lt;code&gt;net.core.rmem_default = 851968&lt;/code&gt;&lt;br&gt;
&lt;code&gt;net.core.wmem_default = 851968&lt;/code&gt;&lt;br&gt;
&lt;code&gt;net.core.rmem_max = 12582912&lt;/code&gt;&lt;br&gt;
&lt;code&gt;net.core.wmem_max = 12582912&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  11
&lt;/h3&gt;

&lt;p&gt;⚙️ Disable local ICMP packet redirects. This should only be done if your server does not act as a router, i.e., if you have a regular web server.&lt;br&gt;
&lt;code&gt;net.ipv4.conf.all.accept_redirects = 0&lt;/code&gt;&lt;br&gt;
&lt;code&gt;net.ipv4.conf.all.secure_redirects = 0&lt;/code&gt;&lt;br&gt;
&lt;code&gt;net.ipv4.conf.all.send_redirects = 0&lt;/code&gt;&lt;br&gt;
Additionally, you can completely disable kernel-level responses to ICMP requests. It is not a common practice.&lt;/p&gt;

&lt;h3&gt;
  
  
  12
&lt;/h3&gt;

&lt;p&gt;Increase the value of &lt;code&gt;tcp_max_orphans&lt;/code&gt;, which determines the maximum number of orphaned (not associated with any process) TCP sockets. Each socket consumes approximately &lt;code&gt;64 KB&lt;/code&gt; of memory. Therefore, the parameter should be matched with the available memory on the server.&lt;br&gt;
&lt;code&gt;net.ipv4.tcp_max_orphans = 65536&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  13
&lt;/h3&gt;

&lt;p&gt;⚙️ Decrease &lt;code&gt;tcp_fin_timeout&lt;/code&gt; (default is &lt;code&gt;60&lt;/code&gt;). This parameter determines the maximum time a socket can remain in the &lt;code&gt;FIN-WAIT-2&lt;/code&gt; state. This state is used when the other party does not close the connection. Each socket occupies about &lt;code&gt;1.5 KB&lt;/code&gt; of memory, which can consume memory when there are many of them.&lt;br&gt;
&lt;code&gt;net.ipv4.tcp_fin_timeout = 10&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  14
&lt;/h3&gt;

&lt;p&gt;⚙️ Parameters related to TCP connection checks in the &lt;code&gt;SO_KEEPALIVE&lt;/code&gt; status: keepalive_time specifies the time after which checks will begin after the last activity on the connection, keepalive_intvl determines the interval between checks, and keepalive_probes specifies the number of checks.&lt;br&gt;
&lt;code&gt;net.ipv4.tcp_keepalive_time = 1800&lt;/code&gt;&lt;br&gt;
&lt;code&gt;net.ipv4.tcp_keepalive_intvl = 15&lt;/code&gt;&lt;br&gt;
&lt;code&gt;net.ipv4.tcp_keepalive_probes = 5&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  15
&lt;/h3&gt;

&lt;p&gt;⚙️ Pay attention to the parameters &lt;code&gt;net.ipv4.tcp_mem&lt;/code&gt;, &lt;code&gt;net.ipv4.tcp_rmem&lt;/code&gt;, and &lt;code&gt;net.ipv4.tcp_wmem&lt;/code&gt;. They heavily depend on the memory available on the server and are automatically calculated during system load. In general, it is not necessary to modify them, but sometimes it is possible to manually adjust them to increase the values.&lt;/p&gt;

&lt;h3&gt;
  
  
  16
&lt;/h3&gt;

&lt;p&gt;⚙️ Disable (enabled by default) the transmission of syncookies to the host in case of &lt;code&gt;SYN&lt;/code&gt; packet queue overflow for a specific socket.&lt;br&gt;
&lt;code&gt;net.ipv4.tcp_syncookies = 0&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  17
&lt;/h3&gt;

&lt;p&gt;⚙️ Special attention should be given to the congestion control algorithm used in TCP networks. There are many algorithms (cubic, htcp, bic, westwood, etc.), and it is difficult to definitively say which one is better to use. Algorithms show different results in different load scenarios. The kernel parameter tcp_congestion_control controls this:&lt;br&gt;
&lt;code&gt;net.ipv4.tcp_congestion_control = cubic&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  18
&lt;/h3&gt;

&lt;p&gt;⚙️ When the server has a large number of outbound connections, there may not be enough local ports for them. By default, the range &lt;code&gt;32768-60999&lt;/code&gt; is used. It can be expanded:&lt;br&gt;
&lt;code&gt;net.ipv4.ip_local_port_range = 10240 65535&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  19
&lt;/h3&gt;

&lt;p&gt;⚙️ Enable protection against &lt;code&gt;TIME_WAIT&lt;/code&gt; attacks. By default, it is disabled.&lt;br&gt;
&lt;code&gt;net.ipv4.tcp_rfc1337 = 1&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  20
&lt;/h3&gt;

&lt;p&gt;⚙️ The maximum number of open sockets waiting for connections has a relatively low default value. In kernels prior to 5.3, it is &lt;code&gt;128&lt;/code&gt;, which was increased to 4096 in kernel 5.4. It makes sense to increase it on busy and powerful servers:&lt;br&gt;
net.core.somaxconn = 16384&lt;/p&gt;

&lt;h3&gt;
  
  
  21
&lt;/h3&gt;

&lt;p&gt;⚙️ On powerful and busy servers, you can increase the default buffer size values for both receiving and transmitting for all connections. This parameter is measured in bytes. By default, it is &lt;code&gt;212992&lt;/code&gt; or &lt;code&gt;208 KB&lt;/code&gt;.&lt;br&gt;
&lt;code&gt;net.core.rmem_default = 851968&lt;/code&gt;&lt;br&gt;
&lt;code&gt;net.core.wmem_default = 851968&lt;/code&gt;&lt;br&gt;
&lt;code&gt;net.core.rmem_max = 12582912&lt;/code&gt;&lt;br&gt;
&lt;code&gt;net.core.wmem_max = 12582912&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  22
&lt;/h3&gt;

&lt;p&gt;⚙️ Disable local ICMP packet redirects. This should only be done if your server does not act as a router, i.e., if you have a regular web server.&lt;br&gt;
&lt;code&gt;net.ipv4.conf.all.accept_redirects = 0&lt;/code&gt;&lt;br&gt;
&lt;code&gt;net.ipv4.conf.all.secure_redirects = 0&lt;/code&gt;&lt;br&gt;
&lt;code&gt;net.ipv4.conf.all.send_redirects = 0&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Additionally, you can completely disable kernel-level responses to ICMP requests. I usually don't Increase the value of &lt;code&gt;tcp_max_orphans&lt;/code&gt;, which determines the maximum number of orphaned (not associated with any process) TCP sockets. &lt;/p&gt;

&lt;p&gt;Each socket consumes approximately &lt;code&gt;64 KB&lt;/code&gt; of memory. Therefore, the parameter should be matched with the available memory on the server.&lt;br&gt;
&lt;code&gt;net.ipv4.tcp_max_orphans = 65536&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  23
&lt;/h3&gt;

&lt;p&gt;⚙️ Decrease tcp_fin_timeout (default is &lt;code&gt;60&lt;/code&gt;). This parameter determines the maximum time a socket can remain in the FIN-WAIT-2 state. This state is used when the other party does not close the connection. Each socket occupies about &lt;code&gt;1.5 KB&lt;/code&gt; of memory, which can consume memory when there are many of them.&lt;br&gt;
&lt;code&gt;net.ipv4.tcp_fin_timeout = 10&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  24
&lt;/h3&gt;

&lt;p&gt;⚙️ Parameters related to TCP connection checks in the &lt;code&gt;SO_KEEPALIVE&lt;/code&gt; status: &lt;code&gt;keepalive_time&lt;/code&gt; specifies the time after which checks will begin after the last activity on the connection, keepalive_intvl determines the interval between checks, and keepalive_probes specifies the number of checks.&lt;br&gt;
&lt;code&gt;net.ipv4.tcp_keepalive_time = 1800&lt;/code&gt;&lt;br&gt;
&lt;code&gt;net.ipv4.tcp_keepalive_intvl = 15&lt;/code&gt;&lt;br&gt;
&lt;code&gt;net.ipv4.tcp_keepalive_probes = 5&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  25
&lt;/h3&gt;

&lt;p&gt;⚙️ Pay attention to the parameters net.ipv4.tcp_mem, net.ipv4.tcp_rmem, and net.ipv4.tcp_wmem. They heavily depend on the memory available on the server and are automatically calculated during system load. In general, it is not necessary to modify them, but sometimes it is possible to manually adjust them to increase the values.&lt;/p&gt;

&lt;h3&gt;
  
  
  26
&lt;/h3&gt;

&lt;p&gt;⚙️ Disable (enabled by default) the transmission of syncookies to the host in case of &lt;code&gt;SYN&lt;/code&gt; packet queue overflow for a specific socket.&lt;br&gt;
&lt;code&gt;net.ipv4.tcp_syncookies = 0&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  27
&lt;/h3&gt;

&lt;p&gt;⚙️ Special attention should be given to the congestion control algorithm used in TCP networks. There are many algorithms (cubic, htcp, bic, westwood, etc.), and it is difficult to definitively say which one is better to use. Algorithms show different results in different load scenarios. The kernel parameter &lt;code&gt;tcp_congestion_control&lt;/code&gt; controls this:&lt;br&gt;
&lt;code&gt;net.ipv4.tcp_congestion_control = cubic&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  28
&lt;/h3&gt;

&lt;p&gt;⚙️ When the server has numerous outbound connections, there may not be enough local ports for them. By default, the range 32768-60999 is used. It can be expanded:&lt;br&gt;
&lt;code&gt;net.ipv4.ip_local_port_range = 10240 65535&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  29
&lt;/h3&gt;

&lt;p&gt;⚙️ Enable protection against &lt;code&gt;TIME_WAIT&lt;/code&gt; attacks. By default, it is disabled.&lt;br&gt;
&lt;code&gt;net.ipv4.tcp_rfc1337 = 1&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  30
&lt;/h3&gt;

&lt;p&gt;⚙️ The maximum number of open sockets waiting for connections has a relatively low default value. In kernels prior to 5.3, it is 128, which was increased to &lt;code&gt;4096&lt;/code&gt; in kernel 5.4. It makes sense to increase it on busy and powerful servers:&lt;br&gt;
&lt;code&gt;net.core.somaxconn = 16384&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  31
&lt;/h3&gt;

&lt;p&gt;⚙️ On powerful and busy servers, you can increase the default buffer size values for both receiving and transmitting for all connections. This parameter is measured in bytes. By default, it is &lt;code&gt;212992&lt;/code&gt; or &lt;code&gt;208 KB&lt;/code&gt;.&lt;br&gt;
&lt;code&gt;net.core.rmem_default = 851968&lt;/code&gt;&lt;br&gt;
&lt;code&gt;net.core.wmem_default = 851968&lt;/code&gt;&lt;br&gt;
&lt;code&gt;net.core.rmem_max = 12582912&lt;/code&gt;&lt;br&gt;
&lt;code&gt;net.core.wmem_max = 12582912&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  32
&lt;/h3&gt;

&lt;p&gt;⚙️ Disable local ICMP packet redirects. This should only be done if your server does not act as a router, i.e., if you have a regular web server.&lt;br&gt;
&lt;code&gt;net.ipv4.conf.all.accept_redirects = 0&lt;/code&gt;&lt;br&gt;
&lt;code&gt;net.ipv4.conf.all.secure_redirects = 0&lt;/code&gt;&lt;br&gt;
&lt;code&gt;net.ipv4.conf.all.send_redirects = 0&lt;/code&gt;&lt;br&gt;
Additionally, you can completely disable kernel-level responses to ICMP requests. It is not a common practice.&lt;/p&gt;

&lt;p&gt;Sources:&lt;br&gt;
a. &lt;a href="https://man7.org/linux/man-pages/man7/tcp.7.html" rel="noopener noreferrer"&gt;https://man7.org/linux/man-pages/man7/tcp.7.html&lt;/a&gt;&lt;br&gt;
b. &lt;a href="https://cr.yp.to/syncookies.html" rel="noopener noreferrer"&gt;https://cr.yp.to/syncookies.html&lt;/a&gt;&lt;br&gt;
c. &lt;a href="https://blog.cloudflare.com/when-tcp-sockets-refuse-to-die/" rel="noopener noreferrer"&gt;https://blog.cloudflare.com/when-tcp-sockets-refuse-to-die/&lt;/a&gt;&lt;br&gt;
d. &lt;a href="https://blog.cloudflare.com/unbounded-memory-usage-by-tcp-for-receive-buffers-and-how-we-fixed-it/" rel="noopener noreferrer"&gt;https://blog.cloudflare.com/unbounded-memory-usage-by-tcp-for-receive-buffers-and-how-we-fixed-it/&lt;/a&gt;&lt;br&gt;
e. &lt;a href="https://www.geeksforgeeks.org/tcp-connection-termination/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/tcp-connection-termination/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks to Mike Freemon and Marek 🐦@majek04 Majkowski.&lt;/p&gt;

</description>
      <category>kernel</category>
      <category>tuning</category>
      <category>networking</category>
      <category>linux</category>
    </item>
    <item>
      <title>Liveness Probes: Feel the Pulse of the App</title>
      <dc:creator>Roman Belshevitz</dc:creator>
      <pubDate>Mon, 28 Nov 2022 13:30:16 +0000</pubDate>
      <link>https://dev.to/otomato_io/liveness-probes-feel-the-pulse-of-the-app-133e</link>
      <guid>https://dev.to/otomato_io/liveness-probes-feel-the-pulse-of-the-app-133e</guid>
      <description>&lt;p&gt;This article will provide some helpful examples as the author  examines probes in Kubernetes. A correct probe definition can increase pod availability and resilience!&lt;/p&gt;

&lt;h2&gt;
  
  
  A Kubernetes Liveness Probe: What Is It?
&lt;/h2&gt;

&lt;p&gt;Based on a given test, the Liveness probe makes sure that an application inside a container is active and working.&lt;/p&gt;

&lt;h3&gt;
  
  
  ⚙️ Liveness probes
&lt;/h3&gt;

&lt;p&gt;They are used by the &lt;code&gt;kubelet&lt;/code&gt; to determine when to restart a container. Applications that crash or enter broken states are detected and, in many cases, can be rectified by restarting them.&lt;/p&gt;

&lt;p&gt;A successful configuration of the liveness probe results in no action being taken and no logs being kept. If it fails, the event is recorded, and the container is killed by the &lt;code&gt;kubelet&lt;/code&gt; in accordance with the &lt;code&gt;restartPolicy&lt;/code&gt; settings.&lt;/p&gt;

&lt;p&gt;When a pod might seem to be running, but the application might not be working properly, a liveness probe should be utilized. During a standstill, as an illustration. The pod might be operational, but it is ineffective since it cannot handle traffic.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fik5g939olte88z1gpa24.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fik5g939olte88z1gpa24.png" alt=" " width="800" height="515"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;🖼️ Pic source: K21Academy&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Since the &lt;code&gt;kubelet&lt;/code&gt; will check the &lt;code&gt;restartPolicy&lt;/code&gt; and restart the container automatically if it is set to &lt;code&gt;Always&lt;/code&gt; or &lt;code&gt;OnFailure&lt;/code&gt;, they are not required when the application is configured to crash the container on failure. The NGINX application, &lt;a href="https://serverfault.com/questions/1003361/how-to-automatically-restart-nginx-when-it-goes-down" rel="noopener noreferrer"&gt;for example&lt;/a&gt;, launches rapidly and shuts down if it encounters a problem that prevents it from serving pages. You are not in need of a liveness inquiry in this instance.&lt;/p&gt;

&lt;p&gt;There are common adjustable fields for every type of probe:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;initialDelaySeconds&lt;/code&gt;: Probes start running after initialDelaySeconds after container is started (default: 0)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;periodSeconds&lt;/code&gt;: How often probe should run (default: 10)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;timeoutSeconds&lt;/code&gt;: Probe timeout (default: 1)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;successThreshold&lt;/code&gt;: Required number of successful probes to mark container healthy/ready (default: 1)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;failureThreshold&lt;/code&gt;: When a probe fails, it will try failureThreshold times before deeming unhealthy/not ready (default: 3)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;code&gt;periodSeconds&lt;/code&gt; field in each of the examples below says that the &lt;code&gt;kubelet&lt;/code&gt; should run a liveness probe every 5 seconds. The &lt;code&gt;initialDelaySeconds&lt;/code&gt; field instructs the &lt;code&gt;kubelet&lt;/code&gt; to delay the first probe for 5 seconds.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;timeoutSeconds&lt;/code&gt; option (Time to wait for the reply), &lt;code&gt;successThreshold&lt;/code&gt; (Number of successful probe executions to mark the container healthy), and &lt;code&gt;failiureThreshold&lt;/code&gt; (Number of failed probe executions to mark the container unhealthy), among other options, can also be customized, if desired.&lt;/p&gt;

&lt;p&gt;All different liveness probes can use these five parameters.&lt;/p&gt;
&lt;h2&gt;
  
  
  What other Kubernetes probes are available?
&lt;/h2&gt;

&lt;p&gt;Although the use of Liveness probes will be the main emphasis of this article, you should be aware that Kubernetes also supports the following other types of probes:&lt;/p&gt;
&lt;h3&gt;
  
  
  ⚙️ Startup probes
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;kubelet&lt;/code&gt; uses startup probes to help it determine when a container application has begun. When enabled, these make sure startup probes don't obstruct the application startup by disabling liveness and readiness checks until they are successful.&lt;/p&gt;

&lt;p&gt;These are especially helpful for slow-starting containers since they prevent the &lt;code&gt;kubelet&lt;/code&gt; from killing them before they have even started when a liveness probe fails. Set the startup probe's &lt;code&gt;failureThreshold&lt;/code&gt; greater if liveness probes are used on the same endpoint in order to enable lengthy startup periods.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;apps/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deployment&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;test-api-deployment&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;test-api&lt;/span&gt;
    &lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;test-api&lt;/span&gt;
        &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;myrepo/test-api:0.1&lt;/span&gt;
        &lt;span class="na"&gt;startupProbe&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;httpGet&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/health/startup&lt;/span&gt;
            &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;80&lt;/span&gt;
          &lt;span class="na"&gt;failureThreshold&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;30&lt;/span&gt;
          &lt;span class="na"&gt;periodSeconds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When a Pod starts and the probe fails, Kubernetes will try &lt;code&gt;failureThreshold&lt;/code&gt; times before giving up. Giving up in case of liveness probe means restarting the Pod. In case of readiness probe, the Pod will be marked &lt;code&gt;Unready&lt;/code&gt;. Defaults to &lt;code&gt;3&lt;/code&gt;. The minimum value is &lt;code&gt;1&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Some startup probe's math: why it is important?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;0 - 10 s: the container has been spun up but the &lt;code&gt;kubelet&lt;/code&gt; doesn't do anything waiting for the &lt;code&gt;initalDelaySeconds&lt;/code&gt; to pass&lt;/li&gt;
&lt;li&gt;10 - 20 s: the first probe request is sent but no response is sent back, this is because the app hasn’t stood up the APIs yet, this is either a failure due to 2 seconds timeout or an immediate TCP connection error&lt;/li&gt;
&lt;li&gt;20 - 30 s: the app has got up but has only started fetching credentials, configurations and so on, so the response to the probe request is 5xx&lt;/li&gt;
&lt;li&gt;30 - 210 s: the kubelet has been probing but the success response didn’t come and is reaching the limit set by the &lt;code&gt;failureThreshold&lt;/code&gt;. In this case, as per the deployment configuration for the startup probe, the pod will be restarted after roughly 212 seconds.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj1cficnbhlf0oqjn15ak.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj1cficnbhlf0oqjn15ak.png" alt=" " width="800" height="305"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;🖼️ Pic source: Wojciech Sierakowski (HMH Engineering)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;It might be a little excessive to wait more than 3 minutes for the app to launch locally with faked dependencies!&lt;/p&gt;

&lt;p&gt;🎯 It might be also better to shorten this interval if you are absolutely certain that, for example, reading secrets, credentials, and establishing connections with DBs and other data sources shouldn't take so long. Doing so will slow down the deployment speed.&lt;/p&gt;

&lt;p&gt;Maybe it’s important to figure out if you even need more nodes. You don’t want to waste your money on resources you don’t need. Take a look at &lt;code&gt;kubectl top&lt;/code&gt; nodes to see if you even need to scale the nodes.&lt;/p&gt;

&lt;p&gt;🚧 If probe fails, the event is recorded, and the container is killed by the &lt;code&gt;kubelet&lt;/code&gt; in accordance with the &lt;code&gt;restartPolicy&lt;/code&gt; settings.&lt;/p&gt;

&lt;p&gt;When a container gets restarted you usually want to check the logs why the application went unhealthy. You can do this with the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl logs &amp;lt;pod-name&amp;gt; --previous
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ⚙️ Readiness probes
&lt;/h3&gt;

&lt;p&gt;Readiness probes keep track of the application's availability. No traffic will be forwarded to the pod if it fails. These are employed when an application requires configuration before it is usable. Additionally, an application may experience traffic congestion and cause the probe to malfunction, stopping further traffic from being routed to it and allowing it to recover. The endpoints controller takes the pod out if it fails.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;apps/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deployment&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;test-api-deployment&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;test-api&lt;/span&gt;
    &lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;test-api&lt;/span&gt;
        &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;myrepo/test-api:0.1&lt;/span&gt;
        &lt;span class="na"&gt;readinessProbe&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;httpGet&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/ready&lt;/span&gt;
            &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;80&lt;/span&gt;
          &lt;span class="na"&gt;successThreshold&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;kubelet&lt;/code&gt; finds that the container is not yet prepared to receive network traffic, but is making progress in that direction if the readiness probe fails but the liveness probe succeeds.&lt;/p&gt;

&lt;h2&gt;
  
  
  The operation of Kubernetes probes
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;kubelet&lt;/code&gt; controls the probes. The main "node agent" that executes on each node is the &lt;code&gt;kubelet&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsrzal6zufqn9o5ivc2as.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsrzal6zufqn9o5ivc2as.png" alt=" " width="800" height="418"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;🖼️ Pic source: Andrew Lock (Datadog). SVG is &lt;a href="https://andrewlock.net/content/images/2020/k8s_probes.svg" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The application needs to support one of the following handlers in order to use a K8S probe effectively:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;ExecAction&lt;/code&gt; handler: Executes a command inside the container. If the command returns a status code of &lt;code&gt;0&lt;/code&gt;, the diagnosis is successful.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;TCPSocketAction&lt;/code&gt; handler tries to establish a TCP connection to the pod's IP address on a particular port. If the port is discovered to be open, the diagnostic is successful.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Using the IP address of the pod, a particular port, and a predetermined destination, the &lt;code&gt;HTTPGetAction&lt;/code&gt; handler sends an &lt;code&gt;HTTP GET&lt;/code&gt; request. If the response code given falls between &lt;code&gt;200&lt;/code&gt; and &lt;code&gt;399&lt;/code&gt;, the diagnostic is successful.&lt;/p&gt;

&lt;p&gt;Before version 1.24 Kubernetes did not support gRPC health checks natively. This left the gRPC developers with the following three approaches when they deploy to Kubernetes:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2d3lx0swx49kxm1qjn54.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2d3lx0swx49kxm1qjn54.png" alt=" " width="800" height="286"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;🖼️ Pic source: Ahmet Alp Balkan (Twitter, ex-Google)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As of Kubernetes version 1.24, gRPC handler &lt;a href="https://kubernetes.io/blog/2022/05/13/grpc-probes-now-in-beta/" rel="noopener noreferrer"&gt;can be configured&lt;/a&gt; to be used by &lt;code&gt;kubelet&lt;/code&gt; for application liveness checks if your application implements the gRPC Health Checking Protocol. To configure checks that use gRPC, you must enable the &lt;code&gt;GRPCContainerProbe&lt;/code&gt; &lt;a href="https://kubernetes.io/docs/reference/command-line-tools-reference/feature-gates/" rel="noopener noreferrer"&gt;feature gate&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;When the &lt;code&gt;kubelet&lt;/code&gt; conducts a probe on a container, it answers with &lt;code&gt;Success&lt;/code&gt;, &lt;code&gt;Failure&lt;/code&gt;, or &lt;code&gt;Unknown&lt;/code&gt;, depending on whether the diagnostic was successful, unsuccessful, or incomplete for some other reason.&lt;/p&gt;
&lt;h2&gt;
  
  
  So, how rushy to track the pulse?
&lt;/h2&gt;

&lt;p&gt;You should examine the system behavior and typical starting timings of the pod and its containers before defining a probe so that you can choose the appropriate thresholds. Additionally, as the infrastructure or application changes, the probe choices should be changed. For instance, a pod's configuration to use more system resources can have an impact on the values that need to be configured for the probes.&lt;/p&gt;
&lt;h2&gt;
  
  
  Handlers in action: some examples
&lt;/h2&gt;
&lt;h3&gt;
  
  
  &lt;code&gt;ExecAction&lt;/code&gt; handler: how can it be useful in practice?
&lt;/h3&gt;

&lt;p&gt;🎯 It allows you to use commands inside containers to control the status of life of a counter in pods. With the help of this option, you may examine several aspects of container's operation, such as the existence of files, their contents, and other choices (accessible at the command level).&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ExecAction&lt;/code&gt; is executed in pod’s shell context and is deemed  failed if the execution returns any result code different from &lt;code&gt;0&lt;/code&gt; (zero).&lt;/p&gt;

&lt;p&gt;The example below demonstrates how to use the &lt;code&gt;exec&lt;/code&gt; command with the cat command to see if a file exists at the path &lt;code&gt;/usr/share/liveness/html/index.html&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Pod&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;test&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;liveness&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;liveness-exec&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;liveness&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;registry.k8s.io/liveness:0.1&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;containerPort&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8080&lt;/span&gt;
    &lt;span class="na"&gt;livenessProbe&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;exec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;command&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;cat&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;/usr/share/liveness/html/index.html&lt;/span&gt;
      &lt;span class="na"&gt;initialDelaySeconds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5&lt;/span&gt;
      &lt;span class="na"&gt;periodSeconds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🚧 The container will be restarted if there is no file and the liveness probe will fail.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;TCPSocketAction&lt;/code&gt; handler: how can it be useful in practice?
&lt;/h3&gt;

&lt;p&gt;In this use case, the liveness probe makes use of the TCP handler to determine whether port &lt;code&gt;8080&lt;/code&gt; is active and open. With this configuration, your container will try to connect to the &lt;code&gt;kubelet&lt;/code&gt; by opening a socket on the designated port.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Pod&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;liveness&lt;/span&gt;
  &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;liveness-tcp&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;liveness&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;registry.k8s.io/liveness:0.1&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;containerPort&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8080&lt;/span&gt;
    &lt;span class="na"&gt;livenessProbe&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;tcpSocket&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8080&lt;/span&gt;
      &lt;span class="na"&gt;initialDelaySeconds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5&lt;/span&gt;
      &lt;span class="na"&gt;periodSeconds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🚧 The container will restart if the socket is dead and liveness probe fails.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;HTTPGetAction&lt;/code&gt; handler: how can it be useful in practice?
&lt;/h3&gt;

&lt;p&gt;This case demonstrates the HTTP handler that will send an HTTP GET request to the &lt;code&gt;/health&lt;/code&gt; path on port &lt;code&gt;8080&lt;/code&gt;. A value between &lt;code&gt;200&lt;/code&gt; and &lt;code&gt;400&lt;/code&gt; indicates that the probe was successful.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Pod&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;test&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;liveness&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;liveness-http&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;liveness&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;registry.k8s.io/liveness:0.1&lt;/span&gt;
    &lt;span class="na"&gt;livenessProbe&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;httpGet&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/health&lt;/span&gt;
        &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8080&lt;/span&gt;
        &lt;span class="na"&gt;httpHeaders&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Custom-Header&lt;/span&gt;
          &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ItsAlive&lt;/span&gt;
      &lt;span class="na"&gt;initialDelaySeconds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5&lt;/span&gt;
      &lt;span class="na"&gt;periodSeconds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🚧 The probe fails, and the container is restarted if a code outside this range is received. Any custom headers you want to transmit can be defined using the &lt;code&gt;httpHeaders&lt;/code&gt; option.&lt;/p&gt;

&lt;h3&gt;
  
  
  gRPC handler: how can it be useful in practice?
&lt;/h3&gt;

&lt;p&gt;gRPC protocol is on its way to becoming the &lt;em&gt;lingua franca&lt;/em&gt; for communication between cloud-native microservices. If you are deploying gRPC applications to Kubernetes today, you may be wondering about the best way &lt;a href="https://github.com/grpc/grpc/blob/master/doc/health-checking.md" rel="noopener noreferrer"&gt;to configure health checks&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This example demonstrates how to check port &lt;code&gt;2379&lt;/code&gt; responsiveness using the gRPC health checking protocol. A port must be specified in order to use a gRPC probe. You must also specify the service if the &lt;a href="https://kubernetes.io/docs/reference/using-api/health-checks/" rel="noopener noreferrer"&gt;health endpoint&lt;/a&gt; is set up on a non-default service.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Pod&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;test&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;liveness&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;liveness-gRPC&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;liveness&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;registry.k8s.io/liveness:0.1&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;containerPort&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2379&lt;/span&gt;
    &lt;span class="na"&gt;livenessProbe&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;grpc&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2379&lt;/span&gt;
      &lt;span class="na"&gt;initialDelaySeconds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5&lt;/span&gt;
      &lt;span class="na"&gt;periodSeconds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🚧 The container will restart if the gRPC socket is dead and liveness probe fails.&lt;/p&gt;

&lt;p&gt;Since there are no &lt;a href="https://grpc.github.io/grpc/core/md_doc_statuscodes.html" rel="noopener noreferrer"&gt;error codes&lt;/a&gt; for gRPC built-in probes, all errors are regarded as probe failures.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using liveness probes in the wrong way can lead to disaster
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Please remember that the container will be restarted if the liveness probe fails. It is not conventional to examine dependencies in a liveness probe, unlike a readiness probe. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To determine whether the container itself has stopped responding, a liveness probe should be utilized.&lt;/p&gt;

&lt;p&gt;A liveness probe has the drawback of maybe not verifying the service's responsiveness. For instance, if a service maintains two web servers, one for service routes and the other for status routes, such as readiness and liveness probes or metrics gathering, the service may be delayed or inaccessible while the liveness probe route responds without any issues. The liveness probe must use the service in a comparable way to dependent services for it to be effective.&lt;/p&gt;

&lt;p&gt;Like the readiness probe, it's crucial to take into account dynamics that change over time. A slight increase in response time, possibly brought on by a brief rise in load, could force the container to restart if the liveness-probe timeout is too short. The restart might put even more strain on the other pods supporting the service, leading to a further cascade of liveness probe failures and worsening the service's overall availability. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fox7ypl60h7ocwj3csckv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fox7ypl60h7ocwj3csckv.png" alt=" " width="720" height="483"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;🖼️ Pic source: Wojciech Sierakowski (HMH Engineering)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;These cascade failures can be prevented by configuring liveness probe timeouts on the order of client timeouts and employing a forgiving &lt;code&gt;failureThreshold&lt;/code&gt; count.&lt;/p&gt;

&lt;p&gt;Liveness probes may have a small issue with the container startup latency varying over time (see above about the math). Changes in resource allocation, network topology changes, or just rising load as your service grows could all contribute to this. &lt;/p&gt;

&lt;p&gt;If the &lt;code&gt;initialDelaySeconds&lt;/code&gt; option is insufficient and a container is restarted as a result of a Kubernetes node failure or a liveness probe failure, the application may never start or may start partially before being repeatedly destroyed and restarted. The container's maximum initialization time should be greater than the &lt;code&gt;initialDelaySeconds&lt;/code&gt; option. &lt;/p&gt;

&lt;h2&gt;
  
  
  Some notable suggestions are:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Keep dependencies out of liveness probes. Liveness probes should be reasonably priced and have consistent response times.&lt;/li&gt;
&lt;li&gt;So that system dynamics can alter temporarily or permanently without causing an excessive number of liveness probe failures, liveness probe timeouts should be conservatively set. Consider setting client timeouts and liveness-probe timeouts to the same value.&lt;/li&gt;
&lt;li&gt;To ensure that containers can be restarted with reliability even if starting dynamics vary over time, the initialDelaySeconds option should be set conservatively.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The inevitable summary
&lt;/h2&gt;

&lt;p&gt;By causing an automatic restart of a container after a failure of a particular test is discovered, the proper integration of liveness probes with readiness and startup probes can increase pod resilience and availability. It is necessary to comprehend the application in order to specify the appropriate alternatives for them.&lt;/p&gt;

&lt;p&gt;The author is thankful to Guy Menachem from Komodor for inspiration! Stable applications in the clouds to you all,  folks!&lt;/p&gt;

&lt;h3&gt;
  
  
  More to read:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Traefik &lt;a href="https://doc.traefik.io/traefik/user-guides/grpc/#grpc-examples" rel="noopener noreferrer"&gt;docs&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Kubernetes &lt;a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#probe-v1-core" rel="noopener noreferrer"&gt;API reference&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Guy's &lt;a href="https://komodor.com/blog/kubernetes-health-checks-everything-you-need-to-know/" rel="noopener noreferrer"&gt;post&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devops</category>
      <category>kubernetes</category>
      <category>api</category>
    </item>
    <item>
      <title>Kubernetes TLS, Demystified</title>
      <dc:creator>Roman Belshevitz</dc:creator>
      <pubDate>Tue, 11 Oct 2022 18:16:13 +0000</pubDate>
      <link>https://dev.to/otomato_io/possible-paths-2hfc</link>
      <guid>https://dev.to/otomato_io/possible-paths-2hfc</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This is the anniversary 10th article in this series.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;🛡️ It is more than obvious a secured connection to any exposed service running in Kubernetes cluster is important. &lt;/p&gt;

&lt;p&gt;The supposition for this article is that you wish to set up TLS (Transport Layer Security) realm for your &lt;a href="https://docs.nginx.com/nginx-ingress-controller/" rel="noopener noreferrer"&gt;ingress resource&lt;/a&gt; and that you already have a functioning ingress controller established in your cluster.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The SSL replacement technology is called Transport Layer Security (TLS) today. An enhanced version of SSL is TLS. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Similar to how SSL operates, it uses encryption to safeguard the transmission of data and information. Although SSL is still commonly utilized in the industry, the &lt;em&gt;two names are frequently used interchangeably&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting a certificate: what paths can be taken?
&lt;/h2&gt;

&lt;p&gt;A TLS/SSL certificate is the fundamental prerequisite for ingress TLS. These certificates are available to you in the following ways.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Path one&lt;/strong&gt;. Self-signed certificates: Our own Certificate Authority (root CA) &lt;a href="https://www.ibm.com/docs/en/api-connect/10.0.1.x?topic=overview-generating-self-signed-certificate-using-openssl" rel="noopener noreferrer"&gt;created and signed&lt;/a&gt; the TLS certificate. It is a well-known, stunt choice for &lt;em&gt;testing scenarios&lt;/em&gt; where you can "collaborate" on the root CA so that browsers will accept the certificate. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx8ol9xl8v4idbbuh8ahf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx8ol9xl8v4idbbuh8ahf.png" alt=" " width="450" height="310"&gt;&lt;/a&gt;&lt;br&gt;
🖼️ &lt;em&gt;Pic source: Bizagi&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Path two&lt;/strong&gt;. Get an SSL certificate: for production use cases, you must &lt;a href="https://www.google.com/search?q=buy+ssl+certificate" rel="noopener noreferrer"&gt;purchase&lt;/a&gt; an SSL certificate from a reputable certificate authority that operating systems and browsers trust. But you must bear in mind that a so-called &lt;em&gt;wildcard certificate&lt;/em&gt; suitable to protect all subdomains in a domain can cost $300+/year from major commercial issuers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Path three&lt;/strong&gt;. Use a Let's Encrypt certificate: Let's Encrypt is a reputable certificate authority that issues &lt;em&gt;free&lt;/em&gt; TLS certificates. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  A few words about Let's Encrypt
&lt;/h3&gt;

&lt;p&gt;It is a non-profit organization founded by &lt;a href="https://letsencrypt.org/2022/09/12/remembering-peter-eckersley.html" rel="noopener noreferrer"&gt;enthusiasts&lt;/a&gt; in the field of struggle for privacy and security in 2014. &lt;/p&gt;

&lt;p&gt;The challenge–response protocol used to automate enrolling with the certificate authority is called Automated Certificate Management Environment (&lt;a href="https://letsencrypt.org/how-it-works/" rel="noopener noreferrer"&gt;ACME&lt;/a&gt;). It can query either Web servers or DNS servers controlled by the domain covered by the certificate to be issued.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuzzu0229x0x0tye8d3fk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuzzu0229x0x0tye8d3fk.png" alt=" " width="689" height="380"&gt;&lt;/a&gt;&lt;br&gt;
🖼️ &lt;em&gt;Pic source: Let's Encrypt&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you are interested in the implementation of the protocol, read what &lt;a href="https://blog.acolyer.org/2020/02/12/lets-encrypt-an-automated-certificate-authority-to-encrypt-the-entire-web/" rel="noopener noreferrer"&gt;Adrian Colyer&lt;/a&gt; from SpringSource writes about them.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Each SSL certificate has an &lt;em&gt;expiration date&lt;/em&gt;. So, before the certificate expires, you need to &lt;em&gt;rotate&lt;/em&gt; it. For instance, Let's Ecrypt certificates have a &lt;em&gt;three-month&lt;/em&gt; expiration date (and &lt;a href="https://letsencrypt.org/2015/11/09/why-90-days.html" rel="noopener noreferrer"&gt;here&lt;/a&gt; they tell why).&lt;/p&gt;

&lt;p&gt;This way, below in this article series, the author will dwell on the &lt;strong&gt;third path&lt;/strong&gt; further in detail. Why? Well, since this path is interesting for its relative self-sufficiency and [relative] independence from commercial / state-owned certificate issuers. In general, the motto of this path is: "If made something with your hands, you know how it works - you're more adapted to survival!"&lt;/p&gt;

&lt;p&gt;Of course, Let's Encrypt approach does not &lt;em&gt;always&lt;/em&gt; fit needs, but for academic purposes and for startups it works.&lt;/p&gt;

&lt;p&gt;But let's look at the situation "in manual mode" - just try to associate a certificate with a protected application. So, &lt;/p&gt;
&lt;h3&gt;
  
  
  Chicken or egg?
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;ingress controller&lt;/em&gt;, not the ingress resource, is in charge of SSL. In other words, the ingress controller &lt;em&gt;accesses&lt;/em&gt; the TLS certificates you provide to the ingress resource as a Kubernetes &lt;code&gt;secret&lt;/code&gt; and incorporates them into its configuration.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs68iypo5revwa9w665am.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs68iypo5revwa9w665am.png" alt=" " width="768" height="467"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Setup TLS/SSL certificates for ingress
&lt;/h2&gt;

&lt;p&gt;Let's examine the procedures for setting up TLS for ingress. We'll start by launching a test application on the cluster. This application will be used to test our TLS-secured ingress.&lt;/p&gt;

&lt;p&gt;Establish the new namespace, &lt;code&gt;trial&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl create namespace trial
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keep this as &lt;code&gt;hello-app.yaml&lt;/code&gt;. The &lt;code&gt;Deployment&lt;/code&gt; and &lt;code&gt;Service&lt;/code&gt; objects are present.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;apps/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deployment&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;hello-app&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;trial&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;matchLabels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;hello&lt;/span&gt;
  &lt;span class="na"&gt;replicas&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;hello&lt;/span&gt;
    &lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;hello&lt;/span&gt;
        &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;rbalashevich/hello-app:2.0"&lt;/span&gt;
&lt;span class="nn"&gt;---&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Service&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;hello-service&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;trial&lt;/span&gt;
  &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;hello&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ClusterIP&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;hello&lt;/span&gt;
  &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;80&lt;/span&gt;
    &lt;span class="na"&gt;targetPort&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8080&lt;/span&gt;
    &lt;span class="na"&gt;protocol&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;TCP&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Deploy the application with a command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl apply -f hello-app.yaml -n trial
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Create a Kubernetes TLS Secret
&lt;/h3&gt;

&lt;p&gt;It is necessary to make the SSL certificate a Kubernetes secret. It will subsequently be directed to the &lt;code&gt;tls&lt;/code&gt; block for &lt;code&gt;Ingress&lt;/code&gt; resources.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;server.crt&lt;/code&gt; (CA trust chain) and &lt;code&gt;server.key&lt;/code&gt; (private key) SSL files are assumed to be available from a Certificate Authority, your company, or self-signed, as a last resort.&lt;/p&gt;

&lt;p&gt;⚠️ A private key is created by you (the certificate owner) when you request your certificate with a Certificate Signing Request (CSR). Saying other words, you receive a private key when generate a CSR. You submit the CSR code to the certificate authority and keep private key in a safe place. &lt;/p&gt;

&lt;p&gt;As for the big three public cloud providers, they have instructions for exporting certificates: &lt;a href="https://docs.aws.amazon.com/acm/latest/userguide/export-private.html" rel="noopener noreferrer"&gt;AWS CM&lt;/a&gt;, &lt;a href="https://cloud.google.com/sdk/gcloud/reference/privateca/certificates" rel="noopener noreferrer"&gt;GCP CAS&lt;/a&gt;, &lt;a href="https://learn.microsoft.com/en-us/azure/key-vault/certificates/how-to-export-certificate?tabs=azure-cli" rel="noopener noreferrer"&gt;Azure KV&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It is necessary to make the SSL certificate a Kubernetes secret. It will subsequently be directed to the &lt;code&gt;tls&lt;/code&gt; block for &lt;code&gt;Ingress&lt;/code&gt; resources.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;And yes, keep the private key (&lt;code&gt;server.key&lt;/code&gt;)!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let's use the &lt;code&gt;server.crt&lt;/code&gt; and &lt;code&gt;server.key&lt;/code&gt; files to construct a Kubernetes secret of &lt;code&gt;tls&lt;/code&gt; type (SSL certificates). In the &lt;code&gt;trial&lt;/code&gt; namespace, where the &lt;code&gt;hello-app&lt;/code&gt; deployment is located, we are creating the secret.&lt;/p&gt;

&lt;p&gt;Run the &lt;code&gt;kubectl&lt;/code&gt; command listed below from the directory where your server is located. Supply the &lt;em&gt;absolute path&lt;/em&gt; to the files or the &lt;code&gt;.crt&lt;/code&gt; and &lt;code&gt;.key&lt;/code&gt; files. The name &lt;code&gt;hello-app-tls&lt;/code&gt; is made up.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl create secret tls hello-app-tls \
    --namespace trial \
    --key server.key \
    --cert server.crt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The comparable YAML file, where you must include the contents of the &lt;code&gt;.crt&lt;/code&gt; and &lt;code&gt;.key&lt;/code&gt; files, is provided below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Secret&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;hello-app-tls&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;trial&lt;/span&gt;
&lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;kubernetes.io/tls&lt;/span&gt;
&lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;server.crt&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
       &lt;span class="s"&gt;&amp;lt;crt contents here&amp;gt;&lt;/span&gt;
  &lt;span class="na"&gt;server.key&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
       &lt;span class="s"&gt;&amp;lt;private key contents here&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A Kubernetes ingress is &lt;a href="https://kubernetes.io/docs/concepts/services-networking/ingress/" rel="noopener noreferrer"&gt;a set of rules&lt;/a&gt; that can be configured to give services externally reachable URLs. Based on this understanding, to turn on secure connection, we should add &lt;code&gt;tls&lt;/code&gt; block to &lt;code&gt;Ingress&lt;/code&gt; object.  So, in the &lt;code&gt;trial&lt;/code&gt; namespace, we create the sample ingress TLS-capable resource:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;networking.k8s.io/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Ingress&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;hello-app-ingress&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;trial&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;ingressClassName&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx&lt;/span&gt;
  &lt;span class="na"&gt;tls&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;hosts&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;app.hosting.cloudprovider.com&lt;/span&gt;
    &lt;span class="na"&gt;secretName&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;hello-app-tls&lt;/span&gt;
  &lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;host&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;app.hosting.cloudprovider.com"&lt;/span&gt;
    &lt;span class="na"&gt;http&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;paths&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;pathType&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Prefix&lt;/span&gt;
          &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/"&lt;/span&gt;
          &lt;span class="na"&gt;backend&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="na"&gt;service&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
              &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;hello-service&lt;/span&gt;
              &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
                &lt;span class="na"&gt;number&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;80&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;⚠️ Replace &lt;code&gt;app.hosting.cloudprovider.com&lt;/code&gt; to your actual hostname. The &lt;code&gt;host(s)&lt;/code&gt; should be the same in both the &lt;code&gt;rules&lt;/code&gt; and &lt;code&gt;tls&lt;/code&gt; blocks in the &lt;code&gt;Ingress&lt;/code&gt; manifest. In other words, they must match.&lt;/p&gt;

&lt;p&gt;In case of using NGINX ingress, you can add the supported annotation by the ingress controller you are using if you want a &lt;em&gt;strict&lt;/em&gt; SSL. For instance, you can use the &lt;a href="https://github.com/kubernetes/ingress-nginx/blob/main/docs/user-guide/nginx-configuration/annotations.md" rel="noopener noreferrer"&gt;annotation&lt;/a&gt; &lt;code&gt;nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"&lt;/code&gt; in the Nginx ingress controller to permit SSL traffic up until the application.&lt;/p&gt;

&lt;h3&gt;
  
  
  The way to make sure
&lt;/h3&gt;

&lt;p&gt;Let's check with &lt;code&gt;curl https://app.hosting.cloudprovider.com -kv&lt;/code&gt;, is the connection to the app secure now:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server accepted to use h2
* Server certificate:
*  subject: CN=app.hosting.cloudprovider.com
*  start date: Oct 6 15:35:07 2022 GMT
*  expire date: Oct 6 15:35:07 2023 GMT
*  issuer: CN=Go Daddy Secure Certificate Authority - G2,
              OU=http://certs.godaddy.com/repository/,
              O="GoDaddy.com, Inc.",L=Scottsdale,ST=Arizona,C=US
*  SSL certificate verify ok.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔒 If the certificate is valid, then the browser will not swear and there will be no frightening warnings either. Voilà, the connection to our app is secure!&lt;/p&gt;

&lt;p&gt;Okay, we've covered the situations for the first and second paths. The next step is pathfinding the third path involving Let's Encrypt certificate. &lt;/p&gt;

&lt;h2&gt;
  
  
  Estne vita vere brevis?
&lt;/h2&gt;

&lt;p&gt;Sed vita est cum dignitate vivendum. As the author noted above, the life of a certificate from a let's encrypt is &lt;a href="https://letsencrypt.org/2015/11/09/why-90-days.html" rel="noopener noreferrer"&gt;short&lt;/a&gt;. You have to pay for insolence. Accordingly, some solution is required that would automate the re-issuance of short-lived certificates, right? And such a solution exists, it is &lt;code&gt;cert-manager&lt;/code&gt;! It streamlines the process of getting, renewing, and using certificates by adding certificates and certificate issuers as &lt;em&gt;resource types&lt;/em&gt; in Kubernetes clusters.&lt;/p&gt;

&lt;p&gt;It can generate certificates from a number of supported sources, including Let's Encrypt.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2w3rx680y8nvz18b9ms8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2w3rx680y8nvz18b9ms8.png" alt=" " width="747" height="435"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Furthermore, it will check that certificates are current and valid and make an attempt to &lt;strong&gt;renew&lt;/strong&gt; them for a specified period &lt;strong&gt;before&lt;/strong&gt; they &lt;strong&gt;expire&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Install cert-manager on Kubernetes
&lt;/h3&gt;

&lt;p&gt;According to the official &lt;code&gt;cert-manager&lt;/code&gt; documentation, you can install it by using &lt;a href="https://cert-manager.io/docs/installation/kubectl/" rel="noopener noreferrer"&gt;kubectl&lt;/a&gt; or by the provided &lt;a href="https://cert-manager.io/docs/installation/helm/" rel="noopener noreferrer"&gt;helm&lt;/a&gt; chart.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Create a dedicated Kubernetes namespace for cert-manager
kubectl create namespace cert-manager

# Add official cert-manager repository to helm CLI
helm repo add jetstack https://charts.jetstack.io

# Update Helm repository cache (think of apt update)
helm repo update

# Install cert-manager on Kubernetes
## cert-manager relies on several Custom Resource Definitions (CRDs)
helm install certmgr jetstack/cert-manager \
    --set installCRDs=true \
    --version v1.9.1 \
    --namespace cert-manager
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;Issuer&lt;/code&gt; is responsible for issuing certificates. It is the signing authority and based on its configuration. The issuer knows how certificate requests are handled.  &lt;/p&gt;

&lt;p&gt;Cert-manager also creates several objects using different specifications such as &lt;code&gt;CertificateRequest&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;A &lt;code&gt;Certificate&lt;/code&gt; resource is a readable representation of a certificate request. Certificate resources are linked to an &lt;code&gt;Issuer&lt;/code&gt; who is responsible for requesting and renewing the certificate. &lt;/p&gt;

&lt;p&gt;To determine &lt;em&gt;if&lt;/em&gt; a certificate &lt;em&gt;needs to be re-issued&lt;/em&gt;, &lt;code&gt;cert-manager&lt;/code&gt; looks at the the &lt;code&gt;spec&lt;/code&gt; of &lt;code&gt;Certificate&lt;/code&gt; resource and latest &lt;code&gt;CertificateRequests&lt;/code&gt; as well as the data in &lt;code&gt;Secret&lt;/code&gt; containing the certificate.&lt;/p&gt;

&lt;h3&gt;
  
  
  Let's Encrypt: staging or production server?
&lt;/h3&gt;

&lt;p&gt;An &lt;code&gt;Issuer&lt;/code&gt; is a custom resource (CRD) which tells &lt;code&gt;cert-manager&lt;/code&gt; how to sign a &lt;code&gt;Certificate&lt;/code&gt;. Following &lt;a href="https://cert-manager.io/docs/tutorials/getting-started-with-cert-manager-on-google-kubernetes-engine-using-lets-encrypt-for-ingress-ssl/" rel="noopener noreferrer"&gt;this howto (section 7)&lt;/a&gt; the &lt;code&gt;Issuer&lt;/code&gt; will be configured to connect to the Let's Encrypt staging server, which allows us to test everything without using up your Let's Encrypt &lt;a href="https://letsencrypt.org/docs/rate-limits/" rel="noopener noreferrer"&gt;certificate quota&lt;/a&gt; for the domain name. &lt;/p&gt;

&lt;p&gt;After debugging, you can safely issue a certificate by using LE's production server.&lt;/p&gt;

&lt;p&gt;A video describing &lt;code&gt;cert-manager&lt;/code&gt; YAML syntax and recommended by the author of this article is &lt;a href="https://youtu.be/7m4_kZOObzw" rel="noopener noreferrer"&gt;📽️ Anton Putra's good one&lt;/a&gt;. &lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;SSL certificate acquisition was made simple by Let's Encrypt's reputation as a reliable certificate authority. Together with &lt;code&gt;cert-manager&lt;/code&gt; tool, ops can quickly and easily assure correct transport encryption and interoperability with already-existing parts like NGINX Ingress. In addition to the example mentioned above, &lt;code&gt;cert-manager&lt;/code&gt; can help with trickier situations like those involving wildcard SSL certificates.&lt;/p&gt;

&lt;p&gt;If you're interested in using letsencrypt outside of a kubernetes cluster, take a look at &lt;a href="https://github.com/caddyserver/caddy" rel="noopener noreferrer"&gt;Caddy&lt;/a&gt;, a 43k ⭐ open source web server, and also at Certbot, a 29k ⭐ ACME client which is open source, too.&lt;/p&gt;

&lt;p&gt;Ever tried using &lt;code&gt;wireshark&lt;/code&gt; to monitor web traffic? Follow &lt;a href="https://www.comparitech.com/net-admin/decrypt-ssl-with-wireshark/" rel="noopener noreferrer"&gt;Aaron Phillips&lt;/a&gt; from Comparitech to learn how.&lt;/p&gt;

&lt;p&gt;Safe connections to you!&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>ssl</category>
      <category>api</category>
      <category>crd</category>
    </item>
    <item>
      <title>Admission Controllers in Action: Datree's Approach</title>
      <dc:creator>Roman Belshevitz</dc:creator>
      <pubDate>Sun, 11 Sep 2022 09:19:45 +0000</pubDate>
      <link>https://dev.to/otomato_io/admission-controllers-in-action-datrees-approach-143d</link>
      <guid>https://dev.to/otomato_io/admission-controllers-in-action-datrees-approach-143d</guid>
      <description>&lt;p&gt;In the &lt;a href="https://dev.to/otomato_io/responsible-approach-to-communicating-with-the-api-server-admission-controllers-3b49"&gt;eighth part&lt;/a&gt;, the author talked about admission controllers. In this, the ninth, we will see how ACs can be used for practical purposes.&lt;/p&gt;

&lt;p&gt;At the same time, it may be considered that this is the second part of the &lt;a href="https://dev.to/otomato_io/datree-a-tool-which-really-shifts-your-cluster-security-even-more-left-1g20"&gt;review&lt;/a&gt;, so both of the parts will be marked with the appropriate &lt;code&gt;#datree&lt;/code&gt; tag.&lt;/p&gt;

&lt;h2&gt;
  
  
  The originality of Datree's approach
&lt;/h2&gt;

&lt;p&gt;In brief, &lt;a href="https://github.com/datreeio/admission-webhook-datree" rel="noopener noreferrer"&gt;Datree's integration&lt;/a&gt; enables you to check your resources against the defined policy &lt;strong&gt;a moment before&lt;/strong&gt; you put them into a cluster... by leveraging an admission webhook! 😎 &lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/datreeio/admission-webhook-datree/blob/main/kube/validating-webhook-configuration.yaml" rel="noopener noreferrer"&gt;The webhook&lt;/a&gt; implemented with &lt;code&gt;ValidatingWebhookConfiguration&lt;/code&gt; will detect &lt;a href="https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/#webhook-configuration" rel="noopener noreferrer"&gt;operations&lt;/a&gt; such as &lt;code&gt;CREATE&lt;/code&gt;, &lt;code&gt;UPDATE&lt;/code&gt; or &lt;code&gt;DELETE&lt;/code&gt;, and it will start a policy check against the configs related to each operation. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjvvkt02z3978vwpma40z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjvvkt02z3978vwpma40z.png" alt=" " width="427" height="127"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If any configuration errors are discovered, the webhook will refuse the action and show a thorough output with guidance on how to fix each error.&lt;/p&gt;

&lt;p&gt;Every cluster operation that is tied up once the webhook is installed will cause a Datree policy check. If there are no configuration errors, the resource will get a green light🚦 to be applied or updated. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🔬 Datree is functioning well in a full-scale cluster and also in a &lt;code&gt;k3s/k3d&lt;/code&gt;-baked one! It make a debugging process more suitable even for local development. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Let's go step by step
&lt;/h2&gt;

&lt;p&gt;Following the Software-as-a-Service paradigm, Datree provides their users access to the misconfigurations' database and to the personal workspace at their website, where all the checks initiated by the user become aggregated. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqeq74rpsh6peeouf91yo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqeq74rpsh6peeouf91yo.png" alt=" " width="800" height="398"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This cheeky astronaut design will brighten up your day.&lt;/p&gt;

&lt;h3&gt;
  
  
  🎯 Step 1. Access token
&lt;/h3&gt;

&lt;p&gt;They [want to] know everything about you! Well, relax, it is a joke. Sign up or &lt;a href="https://app.datree.io/login" rel="noopener noreferrer"&gt;log in&lt;/a&gt;, then grab your token to access &lt;code&gt;datree&lt;/code&gt; programmatically. API access tokens are widespread in 2022, aren't they? 🔏&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgx48pcy2urgxpngqbhzb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgx48pcy2urgxpngqbhzb.png" alt=" " width="711" height="283"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;💰 There is only one token available when using the so-called Free Plan, enough for evaluation purposes (up to 4 Kubernetes nodes are supported; service access logs will be stored for two weeks).&lt;/p&gt;

&lt;h3&gt;
  
  
  🎯 Step 2. Set up your CLI environment
&lt;/h3&gt;

&lt;p&gt;The following binaries must be installed on the machine: &lt;code&gt;kubectl&lt;/code&gt;, &lt;code&gt;openssl&lt;/code&gt; (required for creating a certificate authority, CA) and &lt;code&gt;curl&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Assume everything is in place. Let's run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ DATREE_TOKEN=[your-token] bash &amp;lt;(curl https://get.datree.io/admission-webhook)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What you should see and what should happen to your cluster (yes, API requests are additionally encrypted):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;🔑 Generating TLS keys...
Generating a RSA private key
Signature ok
subject=CN = webhook-server.datree.svc
Getting CA Private Key
/home/roman
🔗 Creating webhook secret tls...
secret "webhook-server-tls" deleted
secret/webhook-server-tls created
🔗 Creating core resources...
serviceaccount/webhook-server-datree created
clusterrolebinding.rbac.authorization.k8s.io/rolebinding:webhook-server-datree created
clusterrole.rbac.authorization.k8s.io/webhook-server-datree created
deployment.apps/webhook-server configured
service/webhook-server created
deployment "webhook-server" successfully rolled out
🔗 Creating validation webhook resource...
validatingwebhookconfiguration.admissionregistration.k8s.io/webhook-datree configured
🎉 DONE! The webhook server is now deployed and configured
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🎯 Step 3. Protect your access token
&lt;/h3&gt;

&lt;p&gt;Because your token is private and you don't want to store it in your repository, we advise setting or changing it using a different &lt;code&gt;kubectl patch&lt;/code&gt; command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl patch deployment webhook-server -n datree -p '
spec:
  template:
    spec:
      containers:
        - name: server
          env:
            - name: DATREE_TOKEN
              value: "&amp;lt;your-token&amp;gt;"'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🎯 Step 4. Deploy something: magic will work for you
&lt;/h3&gt;

&lt;p&gt;The author does not want to reinvent the wheel:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;apps/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deployment&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx-deployment&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;matchLabels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx&lt;/span&gt;
  &lt;span class="na"&gt;replicas&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx&lt;/span&gt;
    &lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx&lt;/span&gt;
        &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx:1.14.2&lt;/span&gt;
        &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;containerPort&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;80&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's focus and look at the &lt;code&gt;kubectl apply -f nginx-deployment.yaml&lt;/code&gt; routine's result (the deployment has been &lt;strong&gt;denied&lt;/strong&gt; by AC):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl apply -f nginx-deployment.yaml
Error from server: error when creating "nginx-deployment.yaml": admission webhook "webhook-server.datree.svc" denied the request: 
webhook-nginx-deployment-Deployment.tmp.yaml

[V] YAML validation
[V] Kubernetes schema validation

[X] Policy check

❌  Ensure each container has a configured CPU limit  [1 occurrence]
    - metadata.name: nginx-deployment (kind: Deployment)
💡  Missing property object `limits.cpu` - value should be within the accepted boundaries recommended by the organization

❌  Ensure each container has a configured CPU request  [1 occurrence]
    - metadata.name: nginx-deployment (kind: Deployment)
💡  Missing property object `requests.cpu` - value should be within the accepted boundaries recommended by the organization

❌  Ensure each container has a configured liveness probe  [1 occurrence]
    - metadata.name: nginx-deployment (kind: Deployment)
💡  Missing property object `livenessProbe` - add a properly configured livenessProbe to catch possible deadlocks

❌  Ensure each container has a configured memory limit  [1 occurrence]
    - metadata.name: nginx-deployment (kind: Deployment)
💡  Missing property object `limits.memory` - value should be within the accepted boundaries recommended by the organization

❌  Ensure each container has a configured memory request  [1 occurrence]
    - metadata.name: nginx-deployment (kind: Deployment)
💡  Missing property object `requests.memory` - value should be within the accepted boundaries recommended by the organization

❌  Ensure each container has a configured readiness probe  [1 occurrence]
    - metadata.name: nginx-deployment (kind: Deployment)
💡  Missing property object `readinessProbe` - add a properly configured readinessProbe to notify kubelet your Pods are ready for traffic

❌  Prevent workload from using the default namespace  [1 occurrence]
    - metadata.name: nginx-deployment (kind: Deployment)
💡  Incorrect value for key `namespace` - use an explicit namespace instead of the default one (`default`)


(Summary)

- Passing YAML validation: 1/1

- Passing Kubernetes (v1.21.5) schema validation: 1/1

- Passing policy check: 0/1

+-----------------------------------+-----------------------+
| Enabled rules in policy "Default" | 21                    |
| Configs tested against policy     | 1                     |
| Total rules evaluated             | 21                    |
| Total rules skipped               | 0                     |
| Total rules failed                | 7                     |
| Total rules passed                | 14                    |
| See all rules in policy           | https://app.datree.io |
+-----------------------------------+-----------------------+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Opening the link, you'll be redirected to your personal workspace. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6w70bgsoyktv1kyl8kxc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6w70bgsoyktv1kyl8kxc.png" alt=" " width="800" height="396"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  🎯 Step 5. Is such rigor necessary?
&lt;/h3&gt;

&lt;p&gt;You can audit &lt;a href="https://hub.datree.io/setup/centralized-policy" rel="noopener noreferrer"&gt;reactive policies&lt;/a&gt; and review invocation history. If checks are too strict, unset some of the policies. &lt;/p&gt;

&lt;p&gt;For example, not in every deployment you really need pre-configured container readiness probes [or CPU &amp;amp; memory limits].  &lt;/p&gt;

&lt;p&gt;Well, &lt;strong&gt;another tryout&lt;/strong&gt; will be on edited YAML (&lt;a href="https://k8syaml.com/" rel="noopener noreferrer"&gt;Octopus&lt;/a&gt; may be your fellow):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;apps/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deployment&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx-deployment&lt;/span&gt;
  &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;matchLabels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
       &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx&lt;/span&gt;
  &lt;span class="na"&gt;replicas&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;
  &lt;span class="na"&gt;strategy&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;RollingUpdate&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx&lt;/span&gt;
    &lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx&lt;/span&gt;
          &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx:1.14.2&lt;/span&gt;
          &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;containerPort&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;80&lt;/span&gt;
          &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="na"&gt;requests&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
              &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;100Mi&lt;/span&gt;
              &lt;span class="na"&gt;cpu&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;100m&lt;/span&gt;
            &lt;span class="na"&gt;limits&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
              &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;200Mi&lt;/span&gt;
              &lt;span class="na"&gt;cpu&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;1'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As we really want to use the &lt;code&gt;default&lt;/code&gt; namespace and have no fears with it, let's disable &lt;code&gt;Prevent workload from using the default namespace&lt;/code&gt; policy in Datree web UI. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzygl4h25ucxjlxnp20je.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzygl4h25ucxjlxnp20je.png" alt=" " width="685" height="42"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also we may want to liberate us from &lt;code&gt;Ensure each container has a configured readiness probe&lt;/code&gt; and &lt;code&gt;Ensure each container has a configured liveness probe policies&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Et voilà! 🎭&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl apply -f nginx-deployment-advanced.yaml
deployment.apps/nginx-deployment created
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now all checks are passed successfully and the admission controller have got us a green light🚦 and allowed the deployment!&lt;/p&gt;

&lt;h3&gt;
  
  
  🎯 Step 6. Hey, do not climb where it is not necessary
&lt;/h3&gt;

&lt;p&gt;If you want &lt;code&gt;datree&lt;/code&gt; to disregard a namespace, add the label &lt;code&gt;admission.datree/validate=skip&lt;/code&gt; to its configuration.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl label namespaces default "admission.datree/validate=skip"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How to wipe traces
&lt;/h2&gt;

&lt;p&gt;To delete the label and resume running the &lt;code&gt;datree&lt;/code&gt; webhook on the namespace again:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl label namespaces default "admission.datree/validate-"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Uninstall the webhook
&lt;/h2&gt;

&lt;p&gt;Copy the following command and run it in your terminal to remove the webhook:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ bash &amp;lt;(curl https://get.datree.io/admission-webhook-uninstall)
validatingwebhookconfiguration.admissionregistration.k8s.io "webhook-datree" deleted
service "webhook-server" deleted
deployment.apps "webhook-server" deleted
secret "webhook-server-tls" deleted
clusterrolebinding.rbac.authorization.k8s.io "rolebinding:webhook-server-datree" deleted
serviceaccount "webhook-server-datree" deleted
clusterrole.rbac.authorization.k8s.io "webhook-server-datree" deleted
namespace/kube-system unlabeled
namespace "datree" deleted
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Summing up what was said
&lt;/h2&gt;

&lt;p&gt;As you could understand, the possibilities of Kubernetes API are quite wide. The author hopes that he not only prepared an overview of a useful solution, but also explained the theoretical aspects of its functionality.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>kubernetes</category>
      <category>security</category>
      <category>datree</category>
    </item>
  </channel>
</rss>
