<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Arie Bregman on Medium]]></title>
        <description><![CDATA[Stories by Arie Bregman on Medium]]></description>
        <link>https://medium.com/@bregman.arie?source=rss-7ce43fdea353------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*HrN38YTy0I9iIelTZBb6Gg.jpeg</url>
            <title>Stories by Arie Bregman on Medium</title>
            <link>https://medium.com/@bregman.arie?source=rss-7ce43fdea353------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 13:24:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bregman.arie/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[10 Reasons You’re Not Getting the DevOps/SRE Job]]></title>
            <link>https://medium.com/@bregman.arie/10-reasons-youre-not-getting-the-devops-sre-job-a1fdc77700c6?source=rss-7ce43fdea353------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1fdc77700c6</guid>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[job-interview]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[sre]]></category>
            <category><![CDATA[candidates]]></category>
            <dc:creator><![CDATA[Arie Bregman]]></dc:creator>
            <pubDate>Fri, 01 Aug 2025 20:04:28 GMT</pubDate>
            <atom:updated>2025-08-01T20:04:28.799Z</atom:updated>
            <content:encoded><![CDATA[<p>To this day, I’ve interviewed thousands of engineers for roles like DevOps, SRE, and Support, and I’ve gone through my fair share of interviews as well. After reflecting on those experiences, I’ve noticed a consistent set of mistakes that many candidates make. Whether you’re aiming for a DevOps or SRE position, avoiding these can give you a real edge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GgMzAkCMDZL8QG5MqbW6qg.png" /></figure><h4>1. Skipping the Fundamentals</h4><p>Many candidates jump straight into popular platforms and concepts like Kubernetes, CI/CD pipelines, or infrastructure-as-code tools like Terraform, but when asked about more fundamental topics, like OS and networking, they stumble.<br>DevOps and SRE roles are built on solid technical fundamentals. If you don’t understand how the operating system handles processes, memory, or file systems, or how packets move through the network stack, you’ll struggle to diagnose real-world issues when things go wrong.<br>These fundamentals aren’t just trivia; they’re what help you interpret logs, debug production outages, and understand what your higher-level tools are doing behind the scenes. Without that foundational knowledge, you’re essentially flying blind, relying on tools and processes you don’t really understand fundamentally.</p><h4>2. Weak Troubleshooting Skills</h4><p>Troubleshooting is one of the most critical skills in any DevOps or SRE role. Yet, when presented with a common scenario — like “a service is slow” or “disk usage suddenly spiked” — many candidates resort to guessing or listing unrelated commands without a clear strategy.<br>Strong engineers approach problems methodically. They start by defining the symptoms, checking metrics to confirm the issue, diving into logs for context, and using traces or profiling tools to pinpoint the bottleneck. They know how to isolate variables, reproduce problems, and eliminate noise.<br> Troubleshooting isn’t about memorizing commands — it’s about structured thinking, forming hypotheses, and validating them with data. If you can’t clearly explain how you’d investigate a production issue under pressure, that’s a serious gap. Modern systems are complex, and random guessing wastes time and often leads you further from the root cause. Great SREs are calm under fire, ask smart questions, and follow a logical path toward resolution.</p><h4>3. Overemphasis on Tools, Not Principles and Experiences</h4><p>An interview is an opportunity to showcase your experience, but too often, candidates fall into the trap of listing tools like a checklist: “I’ve used Kubernetes, Terraform, Jenkins, Prometheus…” While it’s great to have hands-on experience with specific technologies, simply naming tools doesn’t demonstrate your depth of understanding or problem-solving ability, which is very important for SRE and DevOps roles.<br>What matters is how and why you used those tools. What specific problems were you trying to solve? Why did you choose one tool over another? Did you weigh the trade-offs? Could you have built something simpler or more reliable?<br>Too many candidates talk about tools without discussing the core principles that drive good infrastructure work, like automation, idempotency, system resilience, observability, or rollback strategies. These principles are what separate someone who builds reliable systems from someone who just applies tools.</p><h4>4. Neglecting Behavioral and Cultural Questions</h4><p>Some candidates ace the technical rounds but fall flat when asked about teamwork, ownership, or communication. Questions like:</p><ul><li>“How do you handle disagreements with engineers, managers, or PMs?”</li><li>“What’s your mindset when you’re on-call?”</li><li>“Tell me about a time you dealt with a production incident.”</li></ul><p>These aren’t fluff, they’re often the deciding factor. DevOps and SREs work under pressure, across teams, and need to communicate clearly and take ownership. Practice telling real stories. Be honest, own your mistakes, and show what you learned.</p><h4>5. “Do You Have Any Questions?”</h4><p>Aside from “Can you introduce yourself?”, this is the most common interview question — and one of the most misunderstood. You might think saying “No, I’m good” is harmless. It’s not.</p><p>Not asking questions signals a lack of curiosity or engagement. It can even suggest you don’t fully understand the role. Great candidates turn this into a conversation. Ask about the team’s structure, on-call expectations, how incidents are handled, or current technical challenges. It shows you’re thinking like someone who wants to <em>join</em> the team, not just land the job.</p><h4><strong>6. </strong>Leaning Too Much on Certificates or Side Projects</h4><p>Certifications, hackathons, and bootcamps have value — they show initiative. But they’re not what gets you hired.</p><p>I’ve interviewed candidates with advanced certifications — not the multiple-choice kind — who still couldn’t explain basic concepts. A certificate might mean you studied the topic, but it doesn’t prove you’ve applied it or understand it deeply.</p><p>Think of these extras as supplements, not substitutes. Experience, problem-solving, and clear thinking matter far more than badges on your résumé.</p><h4><strong>7. Just Say “I Don’t Know” — Really</strong></h4><p>A lot of candidates feel pressured to have an answer for everything -especially in technical interviews. But making stuff up is worse than admitting you’re unsure.</p><p>I often ask: <em>“You try to kill a process in Linux. It fails. Give me three possible reasons why.”</em> You’d be surprised how many people start guessing wildly instead of thinking it through or just saying, “I’m not sure.”</p><p>It’s okay not to know everything. A better response is: <em>“I’m not sure, but I’d check the process state, permissions, or logs to investigate.”</em> That shows honesty, humility, and most importantly, a problem-solving mindset.</p><h4><strong>8. Skipping Incident Reviews and Postmortems</strong></h4><p>If you’ve been on-call but can’t talk about what happened <em>after</em> the outage, that’s a red flag. DevOps and SRE roles aren’t just about firefighting; they’re about learning from failures and improving systems.</p><p>You should be able to describe how incidents led to changes: refining alerts, updating runbooks, automating recovery, or fixing root causes. If your mindset is just “get things back up,” you’re missing half the job. Interviewers look for people who close the loop, not just silence the pager.</p><h4><strong>9. Underestimating System Design Rounds</strong></h4><p>Many candidates focus only on scripting or tool-based questions, but system design often makes or breaks DevOps and SRE interviews.</p><p>You might be asked to design a CI/CD pipeline, a scalable logging system, or a deployment process with rollback and observability. These questions test your understanding of reliability, scalability, and real-world trade-offs not just your ability to write Terraform or bash scripts. If you treat design rounds as optional, you’re not ready for the core of the job.</p><h4><strong>10. Ignoring Observability</strong></h4><p>You say you build and run systems, but how do you know they’re working as expected? Too many candidates gloss over observability, treating it as an SRE-only concern. It’s not. Whether you’re in DevOps or SRE, you’re responsible for building systems that can be measured, monitored, and debugged effectively. That means thinking in terms of <strong>metrics, logs, and traces</strong>, not just spinning up infrastructure.</p><p>You should be able to answer questions like:</p><ul><li>What key metrics do you monitor?</li><li>How do you detect and respond to service degradation?</li><li>What makes a good alert vs. a noisy one?</li><li>Can you trace a request across microservices?</li></ul><p>If you can’t speak to how your systems are observed in production, or worse, you haven’t thought about it, you’re signaling a major gap. Observability isn’t optional. It’s what makes reliability, performance, and debugging even possible.</p><h4><strong>Summary</strong></h4><p>DevOps and SRE interviews aren’t just about knowing tools or passing coding rounds; they test how you think, troubleshoot, communicate, and design reliable systems under pressure.</p><p>This article highlights the most common and critical mistakes candidates make, from skipping the fundamentals and over-relying on certificates, to underestimating system design, ignoring observability, and failing to handle behavioral questions.</p><p>Avoiding these pitfalls and approaching interviews with curiosity, honesty, and a problem-solving mindset can set you apart from the crowd.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1fdc77700c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lessons Learned from Running Elasticsearch in Production]]></title>
            <link>https://medium.com/@bregman.arie/lessons-learned-from-running-elasticsearch-in-production-d4fa382ff479?source=rss-7ce43fdea353------2</link>
            <guid isPermaLink="false">https://medium.com/p/d4fa382ff479</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[production]]></category>
            <category><![CDATA[sre]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[reliability-engineering]]></category>
            <dc:creator><![CDATA[Arie Bregman]]></dc:creator>
            <pubDate>Fri, 10 Jan 2025 15:18:51 GMT</pubDate>
            <atom:updated>2025-01-10T15:18:51.119Z</atom:updated>
            <content:encoded><![CDATA[<p>Elasticsearch is an open source, distributed search and analytics engine based on Apache Lucene. It’s designed for speed, scale, and near-real-time search capabilities, making it ideal for tasks such as log analytics, full-text search, and data visualization. Its flexible schema and RESTful APIs allow developers to quickly index and query large volumes of data. Additionally, Elasticsearch’s ability to horizontally scale across clusters ensures reliability and responsiveness, making it a popular choice for critical production environments.</p><p>In a production environment, even small Elasticsearch misconfigurations can rapidly turn into system-wide issues. Drawing from multiple iterations and real-world experience, I’ll outline key lessons learned and offer practical guidance on managing Elasticsearch in production.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*5P5L2enwdE5s1tYfc4KEvQ.png" /></figure><p>Note that these suggestions aren’t universal or guaranteed to be optimal for your environment; factors like prioritizing fast writes or fast reads can drastically shift what works best. What follows reflects accumulated lessons from real-world deployments, but your mileage may vary based on specific operational needs.</p><h4>Heap Size Matters</h4><p>In Elasticsearch, the JVM heap stores and manages data at runtime — caching query data structures, handling in-flight aggregations, and managing internal objects essential to cluster operations. Correctly sizing the heap is critical: if it’s too small, Elasticsearch can run out of memory and crash or get bogged down by constant garbage collection; if it’s too large (above ~32 GB), you lose Java optimizations like compressed object pointers, and garbage collection can become significantly less efficient.</p><p>A widely recommended practice is to allocate about half of the system’s memory to the Elasticsearch heap, leaving enough room for the OS cache and other processes. This balance helps ensure smooth performance under typical workloads. Ultimately, you may need to adjust these guidelines based on your particular environment, workload patterns, and JVM metrics such as garbage collection times and memory usage.</p><h4>Deployment Architecture Design</h4><p>Elasticsearch can be deployed in a variety of ways, from running all components on a single VM to splitting them across multiple servers (master, data, ingest, etc.), or even using Kubernetes as a StatefulSet. There’s no universal “best” deployment strategy — it ultimately depends on factors like cost, reliability, and performance (both read and write).</p><p>For instance, a single node might handle both master and data roles under normal conditions, but when workloads spike, data-heavy tasks can overwhelm that node and slow cluster-state updates. This not only raises latency but could also lead to “split-brain” issues. By designating a separate master node, you isolate cluster-management tasks from data-intensive operations, improving stability and preventing crucial cluster-wide decisions from getting stuck behind indexing or search loads.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*u-9tdM2CZzJPIUgW9P73Jg.png" /></figure><p>There are also other deployment considerations, such as how to scale Elasticsearch. You might opt to scale vertically by increasing CPU and memory on existing nodes, or scale horizontally by adding more nodes to the cluster. In some situations, a hybrid approach works best, combining both methods for optimal performance and resilience.</p><h4>Limit Complex Queries</h4><p>In Elasticsearch, each token from indexed documents is stored as a term in the inverted index. Queries, especially wildcards or fuzzy logic, can match a large set of terms. Settings like max_clause_count help avoid performance degradation by limiting how many terms a query can expand into.<br>Low max_clause_count: May reject queries that expand into too many terms.<br>High max_clause_count: Allows more flexibility but risks heavier loads, potentially leading to DoS-like scenarios.<br>Striking a balance that suits your workload is key.</p><h4>Avoid Oversharding</h4><p>Each Elasticsearch shard operates as its own index, complete with independent segment files and metadata. When shards become too large — hundreds of gigabytes or more — recoveries and rebalancing grow slower, keeping the cluster in a degraded state for longer. Merges also take more time, consuming CPU and I/O resources, while a single massive shard can create a performance hotspot on whichever node it resides.</p><p>On the other hand, extremely small shards — just a few gigabytes — inflate the cluster-state overhead as each shard adds metadata the cluster must track. You end up using more file handles, memory, and CPU for merges and caching, even if the shards remain idle. A widely recommended approach is to keep individual shards in the tens-of-gigabytes range, helping strike a balance between avoiding prolonged recovery times and preventing the overhead of managing excessive numbers of tiny shards.</p><h4>Make use of Index Lifecycle Management (ILM)</h4><p>Index Lifecycle Management allows you to define policies that automatically transition your indices through different phases — Hot, Warm, Cold, and eventually Delete — based on the age or size of the data. Practically, this means your fresh data that’s frequently accessed remains on faster, more expensive nodes (Hot phase), while older indices roll over to cheaper, slower storage (Warm or Cold phases) once they’re not as actively queried. When the data is no longer needed at all, Elasticsearch automatically deletes it.</p><p>For real-world ops, ILM saves you the hassle of manually moving indices around or accidentally leaving old data on high-performance (and high-cost) hardware. If your business deals with time-series data like logs, metrics, or events, setting up ILM policies is a must. You can configure rollover conditions (e.g., index age or shard size) and ensure older data still remains searchable, albeit on less resource-intensive nodes. This not only helps with cost management but keeps your cluster’s Hot nodes free to handle current, high-volume writes without being bogged down by legacy data.</p><h4><strong>Refresh Interval Tuning</strong></h4><p>Elasticsearch uses a refresh mechanism to make newly indexed documents visible for searches. This occurs on a schedule known as the refresh interval, which is set to one second by default. If your use case doesn’t require near-real-time indexing — like typical log analytics — a longer refresh interval can improve performance by reducing the overhead of frequently updating search structures. Conversely, if you need immediate visibility into your data, you can lower the refresh interval, but that will come with higher resource usage. Striking a balance here is crucial to optimizing performance for your specific workflow.</p><h4>Dynamic Scripts Culprits</h4><p>Elasticsearch supports Painless scripts for runtime fields, scripted metrics, or update scripts. While incredibly useful, dynamic scripting can hammer CPU, especially if used in large aggregations or frequent updates.</p><p>To avoid it, try to cache scripts and test their performance with typical data sizes. Also, consider using stored fields or runtime fields only when absolutely necessary. Excessive scripted fields in large queries can quickly cause high CPU usage and cluster slowdowns.</p><h4>Index Sorting for Common Queries</h4><p>If your data is frequently queried by a specific field — often a date or timestamp for time-based indices — consider<strong> </strong>index sorting. When enabled, Elasticsearch physically stores documents in a presorted format, making certain queries and aggregations faster.</p><p>Practically, define index.sort.field and index.sort.order in your index settings if your data has a natural sort order. This can significantly cut down on query overhead, especially for time-range queries.</p><h4>Circuit Breakers</h4><p>Elasticsearch includes configurable “circuit breakers” that protect the cluster from running out of memory when processing large requests or handling heavy loads. For example, the<strong> </strong>parent circuit breaker tracks overall memory usage, and when it’s near capacity, it can start rejecting new requests to prevent an OOM crash. You can also tune specific breakers like the fielddata circuit breaker (for aggregations) and the request circuit breaker (for query rewrites or per-request data).</p><p>Make sure to check out your breaker settings (indices.breaker.* in elasticsearch.yml) and watch logs for circuit-breaker messages, which hint that queries or aggregations might be too large or unoptimized.</p><h3>Summary</h3><p>Elasticsearch is incredibly powerful but can get tricky fast if you’re not careful. Setting the JVM heap to the right size is a balancing act — go too low and you risk frequent crashes or rejections, go too high and you lose important Java optimizations. A thoughtful deployment architecture, like separating master and data nodes, helps keep the cluster stable under heavy workloads. Keep an eye on queries that expand wildly (like wildcards and fuzzies) by tweaking max_clause_count if needed, and don’t ignore shard sizes—giant shards slow down recoveries and merges, while too many tiny shards bloat your cluster state.</p><p>When you’re dealing with data over time, Index Lifecycle Management (ILM) can save you from babysitting old indices on expensive hardware. Tuning the refresh interval can also make a huge difference in balancing indexing throughput against near-real-time search needs. On the more technical side, watch out for dynamic scripting in large queries — it can chew through CPU like there’s no tomorrow. Index sorting can give big performance gains for time-based searches, so consider sorting by date if that’s your main query pattern. And finally, don’t forget Elasticsearch’s built-in circuit breakers; they’re your friend when it comes to keeping runaway queries from tanking the whole cluster. By mixing these tactics and adjusting for your specific setup, you’ll be well on your way to a smoother, more resilient Elasticsearch environment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d4fa382ff479" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Godot: Anchors]]></title>
            <link>https://medium.com/@bregman.arie/godot-anchors-39dacc55bd39?source=rss-7ce43fdea353------2</link>
            <guid isPermaLink="false">https://medium.com/p/39dacc55bd39</guid>
            <category><![CDATA[godot]]></category>
            <category><![CDATA[godot-4]]></category>
            <category><![CDATA[godot-engine]]></category>
            <dc:creator><![CDATA[Arie Bregman]]></dc:creator>
            <pubDate>Sun, 24 Nov 2024 22:31:23 GMT</pubDate>
            <atom:updated>2024-11-24T22:31:23.338Z</atom:updated>
            <content:encoded><![CDATA[<p>Let’s be honest — understanding ‘Anchors’ in Godot can feel like solving a puzzle. Just when you think you’ve figured them out, your app’s layout throws a curveball, leaving you back at square one, wondering how to properly use those small green markers. If you’ve ever been stuck in this cycle of confusion, don’t worry — you’re not alone. In this article, we’ll break down the concept of anchors and clear up the confusion once and for all.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MTDoLsliclErKfEvQ9qoEA.png" /></figure><h3>The Need for Anchors</h3><p>In the past, one of the most frustrating challenges developers faced when building UIs for games and apps was adapting them to different screen sizes. You’d send your game to various people, only to find that some had entirely different experiences — simply because they were using different devices.</p><p>Today, this challenge is more critical than ever. With your creations running on a vast array of devices — phones, tablets, TVs, and more — it’s essential to ensure your layouts adapt seamlessly.</p><p>This is where Godot’s ‘Anchors’ come to the rescue. Anchors make it possible to design layouts that automatically adjust to different window sizes and aspect ratios. Let’s dive in and see how to use them effectively</p><h3>Environment Setup</h3><p>As a wise person once said, the best way to learn is by doing. In the following sections, we’ll dive into the practical use of anchors and how they can help you create well-structured and predictable layouts. But first, let’s set up your environment.</p><p>Open Godot and add a <strong>Control</strong> node. This is the foundational node used for building any UI in Godot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/355/1*0d3NMWhu6jyvb5JbYRiqLg.png" /><figcaption>“ctrl/command+ a” to add Control node</figcaption></figure><p>Next, add a <strong>Panel</strong> node. A panel will make it easier to visualize and understand the effects of modifying anchors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/173/1*-z4rvOHgU5b0P5cW5qpCrA.png" /></figure><p>If you’ve completed these two simple steps, you’re ready to start exploring anchors! Your scene view should now look similar to the image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/859/1*qryvygUCpPepr6AitHC51w.png" /></figure><p>In the image, the small green markers you see are the anchors of the panel. The Control node also has its own anchors. If you select it, you’ll notice different anchors, most likely covering the entire game or app window (represented by the blue rectangle).</p><p>Now, as a final step, drag the panel to the center of the window. Notice that even after moving the panel, the anchors remain in the same position. This behaviour will be key as we explore how anchors work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*p5S7mMIe3of9i2kGUZHTgA.png" /></figure><h3>Anchors In Action</h3><p>With the panel centered in the window, let’s test how it behaves when we shrink the game window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/347/1*0WCcYd0CdmxLIcaoCYvsaw.png" /><figcaption>Shrinking the game window after running the game</figcaption></figure><p>Notice anything unusual? The panel disappears from view, as shown above. It’s still there, but its position is no longer visible within the resized window. So, how do we ensure the panel always stays centered, no matter the window size? The solution, as you may have guessed, lies in anchors.</p><p>Here’s how to fix it:</p><ol><li>Select the <strong>Panel</strong> node.</li><li>In the <strong>Inspector</strong>, set the <strong>Layout Mode</strong> to ‘Anchors.’</li><li>Then, use the <strong>Anchors Preset</strong> dropdown to select ‘Center.’</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/253/1*6GEUEjvzT7QgBksUsiJ6qg.png" /></figure><p>Alternatively, you can achieve the same result by using the anchor preset icon on the top toolbar, as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/177/1*PBmeGSA6ifWsoDnjpS5DKQ.png" /></figure><p>Once applied, you’ll notice a change in your scene view — the anchors have now moved to the center of the window, where the panel is.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/831/1*3AszKotLsiTtmpFQcwHtaw.png" /></figure><p>Now, when you shrink or expand the game window, the panel remains perfectly centered, regardless of the window size. This behavior demonstrates the power of properly configured anchors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/223/1*Tgzqvwj6foAwyg0Y0vDcqQ.png" /></figure><h3>The Fundamentals of Anchors</h3><p>Now that you’ve seen what anchors can do, let’s break down how they work.</p><p>Anchors are defined by four points: <strong>left</strong>, <strong>right</strong>, <strong>top</strong>, and <strong>bottom</strong>. This is why you always see four green markers, regardless of the preset you choose.</p><p>Each anchor point has a value between <strong>0</strong> and <strong>1</strong>, representing its relative position within the boundaries of your game or app window. To set precise anchor values, use the <strong>Custom</strong> anchors preset in the Inspector.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/346/1*qb6yT4X3Ilj1WUqePOfpig.png" /></figure><p>What happens if you set all anchor points to <strong>1</strong>? As shown in the image below, the panel moves to the bottom-right corner of the window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BMKLGqdH7cxq5L3kcc74CA.png" /></figure><p>Why does this happen? Remember, a value of <strong>1</strong> represents the maximum boundary of the window, while a value of <strong>0</strong> represents the minimum boundary. If you set all anchor points to <strong>0</strong>, the panel will align with the top-left corner of the window — the starting point of the anchors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*9q_lyteJIfjTFvAyTE2LWQ.png" /></figure><p>To test your understanding, try setting the anchor values so the panel covers the entire game window. If you’re unsure, the solution is shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0BSUfNWefUa_bLjbj8IBRA.png" /></figure><p>One final note: anchor points have logical constraints. For example, the <strong>left</strong> anchor cannot have a value greater than the <strong>right</strong> anchor, and the same applies to the <strong>top</strong> and <strong>bottom</strong> anchors. Keeping these rules in mind will ensure your layout behaves as expected.</p><h3>Anchors Offsets</h3><p>Anchor offsets define the distance (in pixels) between a node’s edges and its anchor points. For example, if you set an anchor offset to <strong>100px</strong>, the node will maintain a 100-pixel gap from its anchor point.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/924/1*yYo9mSQAkhOtFqsAru0OHw.png" /></figure><p>To configure anchor offsets, go to the Inspector. Just below the <strong>Anchor Points</strong> section, you’ll find the <strong>Anchor Offsets</strong> settings. These offsets are a powerful tool for creating visually appealing and well-structured layouts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M9b0PoP2cTnrSKgW98yR2w.png" /></figure><p>Here’s a quick challenge to test your understanding: Can you set offsets so the panel has a <strong>200px</strong> distance from every edge of the window? If you’re unsure, check out the solution in the image below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*upBoNEV8pX2mDqcFo9XF9g.png" /></figure><h3>Summary</h3><p>Anchors in Godot are a powerful tool for creating adaptable and visually consistent layouts across different screen sizes. By understanding the fundamentals of anchor points and offsets, you can ensure your UI elements remain positioned exactly where you want them, regardless of window size or aspect ratio. Whether it’s centering a panel, aligning it to specific edges, or creating dynamic layouts, anchors give you the flexibility to design with precision and confidence. Mastering these concepts will elevate the quality and reliability of your UI designs in any project.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39dacc55bd39" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Little Visual Lies in Data Visualization]]></title>
            <link>https://medium.com/@bregman.arie/little-visual-lies-in-data-visualization-34af2b0b8084?source=rss-7ce43fdea353------2</link>
            <guid isPermaLink="false">https://medium.com/p/34af2b0b8084</guid>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[visualization]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[dashboard]]></category>
            <dc:creator><![CDATA[Arie Bregman]]></dc:creator>
            <pubDate>Thu, 21 Nov 2024 20:40:24 GMT</pubDate>
            <atom:updated>2024-11-21T20:40:24.044Z</atom:updated>
            <content:encoded><![CDATA[<p>In observability, dashboards play a crucial role in bridging the gap between data collection and actionable insights. However, if not carefully crafted, these visual tools can unintentionally lead us astray, creating misleading interpretations and guiding us down the wrong path. In this article, I’ll reveal common pitfalls in data visualization that can easily distort our understanding and provide practical tips to avoid these ‘visual lies’ and ensure accurate insights</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4IDZ7DT7Z4W-vo3ktxEfZQ.png" /></figure><h4>Scale The Right Way</h4><p>When used correctly, a scale can make a visualization clear and decisive. But if misused, it can tell a misleading story. Take a look at the visualization below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*tkXUa6cnDiorwDNtdOs3KQ.png" /></figure><p>At a glance, it seems as though far more people dislike pineapple on pizza — yes, I know, hard to believe! But on closer inspection, the difference is only 1,000 votes out of a total of 161,000. This visualization sends a message that many more people oppose pineapple on pizza, which simply isn’t true.</p><p>The solution here is straightforward: use an accurate scale. This applies not just within a single visualization but also when comparing across different charts. By using consistent and accurate scales, you avoid misleading the audience and provide a true representation of the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*Aicjy_fUYkgGn0NmBE-Avw.png" /></figure><h4>Color Association</h4><p>In data visualization, even small details like color choices can greatly impact how the data is perceived. Take the example below: while most of us associate green with success and red with failure, this chart does the opposite.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*SZXiiqHbgx9eM_UjZV3saQ.png" /></figure><p>Many viewers will likely interpret this pie chart as showing a large portion of successes and a small portion of failures — an impression driven by color association, where green suggests positivity and red suggests negativity. Our minds are primed to interpret green as “good” and red as “bad,” which here leads to a misleading interpretation of the data.</p><p>The revised visualization below more accurately represents the data by marking failures in red and successes in green, aligning with common color associations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*y86TldU9PQSoNU_ZB5S09A.png" /></figure><h3>Cherry-Picking Data Points</h3><p>Selecting specific periods or data points can distort overall trends. For example, imagine a chart showing a sharp increase in sales by highlighting only the last month of the year, while ignoring previous fluctuations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*whYp12MIicHFJUJs6YqzKA.png" /></figure><p>By cherry-picking data, it’s easy to create a misleading narrative. Presenting the entire timeframe, however, gives a clearer picture</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zge8ZxZbQ8xL56U4urI7gg.png" /></figure><h4>Summary</h4><p>Data visualizations are powerful tools for conveying insights, but even subtle missteps can distort the story they tell. This article highlights common pitfalls, including inconsistent scales, misleading color associations, and specific data cherry-picking. By understanding these issues and implementing simple fixes — like accurate scaling, logical color choices, and picking the right time frame — you can ensure your visualizations are truthful and effective. Remember, the goal is not just to present data but to do so in a way that accurately informs and inspires confident decision-making.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34af2b0b8084" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Observability for The Absolute Beginner]]></title>
            <link>https://medium.com/@bregman.arie/observability-for-the-absolute-beginner-a3afbb274f02?source=rss-7ce43fdea353------2</link>
            <guid isPermaLink="false">https://medium.com/p/a3afbb274f02</guid>
            <category><![CDATA[logs]]></category>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[observability]]></category>
            <category><![CDATA[metrics]]></category>
            <dc:creator><![CDATA[Arie Bregman]]></dc:creator>
            <pubDate>Sun, 12 May 2024 15:42:50 GMT</pubDate>
            <atom:updated>2024-05-12T15:42:50.821Z</atom:updated>
            <content:encoded><![CDATA[<p>Observability is a crucial concept in managing and understanding the systems and applications you manage. It involves monitoring, tracking, and analyzing data to ensure everything operates smoothly and efficiently. This article is designed for absolute beginners, breaking down what observability means, why it matters, and how you can use it to gain insights into your systems. By the end, you’ll have a solid foundation on which to build your observability skills.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s9ZPNiA6T_BiFXmZ3beGWA.png" /></figure><p>The best way to explain observability is to compare it to something familiar. Imagine you’re driving a car. Observability is like having a well-designed dashboard along with the engine&#39;s sounds and the car&#39;s feel as you drive. Your dashboard shows you critical information like speed, fuel level, and engine temperature. You listen to the engine for any strange noises and feel the car for any unusual vibrations. All these signals help you understand the car&#39;s condition and whether anything needs attention. In the world of technology, observability works in a similar way. It provides you with different types of data systems so you can understand their health and performance at a glance, detect problems before they escalate, and keep everything running smoothly.</p><h4>The Benefits of Observability</h4><p>Embracing good observability practices transforms how teams manage and optimize their systems. It enables:</p><ul><li><strong>Rapid Troubleshooting</strong>: Enables teams to quickly identify and resolve issues, significantly reducing downtime and enhancing system reliability.</li><li><strong>Unified System Insight</strong>: Provides a consolidated view of all system activities, serving as a dependable reference for understanding events and diagnosing issues.</li><li><strong>Data-Driven Changes</strong>: Supports a scientific approach to system modifications by allowing teams to monitor and analyze the effects of changes, leading to more predictable and effective outcomes rather than one based on feelings.</li></ul><h3>Types of Monitoring Data</h3><p>In the field of observability, data is your best friend. It comes in various forms, each providing different insights into the health and performance of your systems. Broadly, this data can be categorized into three main types: metrics, logs, and traces. Each type serves a unique purpose and offers a different perspective on what’s happening inside your applications and infrastructure. Understanding these can help you pinpoint issues quickly, optimize performance, and ensure reliability.</p><h4>Metrics</h4><p>Metrics are numerical data that measure various aspects of system performance over time. Think of them as the continuous vital signs for your technology, similar to checking the pulse or blood pressure in medical terms. Metrics provide a quick overview of the health of your systems, such as CPU usage, memory consumption, and response times. They are typically collected at regular intervals and are invaluable for alerting and long-term performance analysis. By tracking metrics, you can detect trends, anticipate potential problems, and make informed decisions to maintain or improve system efficiency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MQy4KIrTgV6eVe6cMft3EA.png" /><figcaption>Widget displaying memory usage of an application using a metric called “memory_usage”</figcaption></figure><p>To get the most out of your metrics, keep these strategies in mind:</p><ul><li>Define Clear Metrics: Establish which metrics are most critical to your system’s performance and reliability. Focus on metrics that provide actionable insights and avoid collecting unnecessary data that can clutter your analysis.</li><li>Use Aggregation Wisely: Aggregate metrics to provide a clearer picture of trends and anomalies over time. This approach can help reduce noise in the data and make it easier to spot issues before they become critical.</li><li>Correlate Metrics with Business Outcomes: Connect the dots between system performance metrics and business impacts. This correlation can highlight the real-world effects of system behavior and drive more informed decision-making.</li></ul><h4>Logs</h4><p>Logs are the detailed diaries of your systems, recording everything that happens, much like a flight recorder on an airplane. Each log entry contains information about events, operations, and errors within your system, timestamped to the exact moment they occur. This makes logs incredibly valuable for debugging and troubleshooting, as they offer a granular, chronological trail of what happened and when. Logs provide the detailed context needed to make sense of the situation, whether you’re diagnosing a specific error, understanding a sequence of events leading up to an issue, or auditing system activity. By analyzing logs, you can uncover the root causes of problems and ensure that your systems are running as intended.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bfXOlRLJUr12L1Ru-uVuow.png" /><figcaption>A sample content of the log file dpkg.log</figcaption></figure><p>To manage logs effectively, consider these practical tips:</p><ul><li>Decide on Structure: Many standards and conventions outline how log messages should appear, and numerous libraries adhere to these guidelines. Opt for established practices rather than creating your own to ensure consistency and clarity in your logs.</li><li>Avoid Sensitive Data: Never include sensitive information in your logs. This might seem obvious, but it’s a common mistake that can lead to security vulnerabilities.</li><li>Match Log Level to Status Code: For applications like HTTP services, align your log levels with response status codes. For instance, log ‘info’ level for a 200 status, and ‘error’ level for any 5xx statuses. This alignment helps in quickly assessing the severity of issues based on log levels.</li><li>Be Wary of Large Objects: Logging huge objects can degrade performance, particularly as your system scales. Keep log entries concise and focused on relevant data.</li><li>Log Meaningful Events: Instead of just logging the final step or outcome, log significant events throughout the process. This approach gives a more comprehensive view of the sequence leading up to the final status, which can be invaluable for debugging and understanding system behavior.</li></ul><h4>Traces</h4><p>Traces provide a visual storyline of how requests travel through your systems, illustrating the journey of transactions or workflows across multiple services and components. Each trace is composed of several segments or spans, which document the time taken for each step or operation within a request. This detailed view is especially useful in complex, distributed environments where services are interconnected. By examining traces, you can identify bottlenecks, understand dependencies, and optimize performance across all parts of your system. Traces give you the ability to follow a user’s request from start to finish, offering insights into the overall user experience and pinpointing improvements for efficiency and speed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P1JNmnmMsrgNiIbHC9j7TQ.png" /><figcaption>trace of “keda-operator” which indicates the call /readyz return a successful response (200)</figcaption></figure><p>To optimize the use of traces in observability, consider these key strategies:</p><ul><li>Implement Comprehensive Tracing: Ensure that traces cover the entire journey of a request across all services and components. This full visibility is crucial for understanding system behavior and pinpointing issues in complex distributed systems.</li><li>Focus on Key Transactions: Prioritize tracing for critical transactions that are essential to your business operations. This focus helps in efficiently allocating resources and attention to areas with the highest impact.</li><li>Use Context-Rich Tracing: Enhance traces with contextual information such as user IDs, session details, and other relevant metadata. This enrichment provides deeper insights into user interactions and system performance, facilitating more effective troubleshooting.</li><li>Integrate with Logs and Metrics: Correlate traces with logs and metrics to get a holistic view of system performance. This integration allows for a multi-dimensional analysis of issues, combining the what, when, and why into a cohesive understanding.</li><li>Leverage Trace Sampling: In high-volume environments, capturing every single trace can be overwhelming and resource-intensive. Implement sampling techniques to capture a representative subset of traces, ensuring you get valuable insights without overloading your system.</li></ul><h4>Summary: Harnessing Observability for Enhanced System Performance</h4><p>As we’ve explored, observability is more than just a technical necessity; it’s a strategic asset that empowers teams to maintain and improve the health of their systems. By effectively managing logs, metrics, and traces, you can gain a comprehensive view of your infrastructure, allowing for rapid troubleshooting, informed decision-making, and proactive system management. Whether you’re just starting or looking to refine your approach, remember that good observability practices are key to achieving resilience and efficiency in today’s complex technological landscape. Embrace these tools and techniques to ensure your systems are not only performing well but are also robust and ready to meet future challenges.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a3afbb274f02" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kubernetes Services: The Practical Guide]]></title>
            <link>https://medium.com/@bregman.arie/kubernetes-services-the-practical-guide-8ea8f9b754a2?source=rss-7ce43fdea353------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ea8f9b754a2</guid>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[services]]></category>
            <dc:creator><![CDATA[Arie Bregman]]></dc:creator>
            <pubDate>Sat, 06 Apr 2024 10:44:03 GMT</pubDate>
            <atom:updated>2024-04-06T10:44:03.162Z</atom:updated>
            <content:encoded><![CDATA[<p>My aim in this article is to demystify Kubernetes services for you in a hands-on manner. We’ll kick things off by deploying a web server, and then delve into the different types of Kubernetes services, exploring their functionalities and how they operate in a live environment.</p><h4>Deploying a web server</h4><p>Let’s get our hands dirty by starting with a bare cluster. It could be on GKE, EKS, LKE, minikube, or any other — the type doesn’t matter. Ensure your Kubernetes cluster is up and running.</p><p>With your cluster ready, let’s create a new namespace for our project. Execute kubectl create ns web to establish a fresh namespace where we’ll orchestrate our setup.</p><p>Next up, let’s roll out a simple web application in the newly minted namespace. Deploy it by running the lines below. Just copy and paste it into your terminal.</p><pre>cat &lt;&lt;EOF | kubectl apply -n web -f -<br>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: webserver<br>spec:<br>  replicas: 1<br>  selector:<br>    matchLabels:<br>      app: webserver<br>  template:<br>    metadata:<br>      labels:<br>        app: webserver<br>    spec:<br>      containers:<br>      - name: nginx<br>        image: nginx:latest<br>        ports:<br>        - containerPort: 80<br>        volumeMounts:<br>        - name: web-content<br>          mountPath: /usr/share/nginx/html<br>      volumes:<br>      - name: web-content<br>        configMap:<br>          name: webserver-config<br>---<br>apiVersion: v1<br>kind: ConfigMap<br>metadata:<br>  name: webserver-config<br>data:<br>  index.html: |<br>    &lt;html&gt;<br>    &lt;head&gt;&lt;title&gt;Hello World&lt;/title&gt;&lt;/head&gt;<br>    &lt;body&gt;<br>    &lt;h1&gt;Hello, world!&lt;/h1&gt;<br>    &lt;/body&gt;<br>    &lt;/html&gt;<br>EOF</pre><p>Check if the web server deployed successfully by running kubectl get po -n web. This command lists the deployments in the web namespace. You should see an output similar to the following</p><pre>❯ kubectl get po -n web<br>NAME                         READY   STATUS    RESTARTS   AGE<br>webserver-7823kj2ka-32k23     1/1     Running   0          22s</pre><p>When you have executed the kubectl apply command, Kubernetes orchestrated the setup of our web server, following the path Deployment -&gt; Replica -&gt; Pod. This web server now serves a &#39;Hello, World&#39; message, which we defined in the ConfigMap. Below is a diagram illustrating the current setup</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*diMWexLDwiSsuyIgZ2RcKQ.png" /></figure><h4>Kubernetes Port Forward</h4><p>Now that our web server is up, let’s see it’s serving the content we’ve set up. We can quickly achieve this by using kubectl port-forward. Run the following command</p><pre>❯ kubectl port-forward pod/&lt;POD_NAME&gt; 8080:80 -n web                                                          <br>Forwarding from 127.0.0.1:8080 -&gt; 80<br>Forwarding from [::1]:8080 -&gt; 80</pre><p>Replace &lt;POD_NAME&gt; with your actual pod name. This will let you access the web server locally, through a tool like curl or a web browser. For example:</p><pre>❯ curl 127.0.0.1:8080<br>&lt;html&gt;<br>&lt;head&gt;&lt;title&gt;Hello World&lt;/title&gt;&lt;/head&gt;<br>&lt;body&gt;<br>&lt;h1&gt;Hello, world!&lt;/h1&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>While port-forward provides immediate access to the web server, it’s not a permanent solution. The forwarding stops when you terminate the command, and it only works in your local environment—others won&#39;t be able to access the web server using this method.</p><h4>Kubernetes Services</h4><p>In Kubernetes, a “Service” is an abstraction that defines a logical set of Pods (containers) and a policy by which to access them. This feature is key for maintaining stable and permanent networking. It does so by providing a consistent IP address (and optionally, a DNS name), ensuring the Pods remain accessible, even as they are updated or scaled. Your Kubernetes cluster might already have some services running, possibly set up by default. To check, simply execute kubectl get svc, and it will list the available services.</p><p>In Kubernetes, several types of services cater to different needs. In the following sections, we’ll delve into each type, explaining how they function and guiding you on when to utilize each one.</p><h4>ClusterIP Service</h4><p>A ClusterIP service will allow internal communication to your Pod. Yes, this is right, if you are looking to set up a service that will allow you external access to your app, this is not the right choice for you</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*s-93JjtPpFhhbVA_8avDig.png" /><figcaption>ClusterIP</figcaption></figure><p>Let’s set up a ClusterIP service. Paste the following YAML configuration into your terminal to create the service</p><pre>cat &lt;&lt;EOF | kubectl apply -n web -f -<br>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: webserver-service<br>  namespace: web<br>spec:<br>  type: ClusterIP<br>  selector:<br>    app: webserver<br>  ports:<br>  - port: 80<br>    targetPort: 80<br>EOF</pre><p>Now, you have a ClusterIP service running in your cluster. This service listens on port 80 and forwards traffic to the web server, also on port 80.</p><p>Since ClusterIP services are not accessible from outside the cluster, how do we verify it’s working? We can test it by setting up a Pod within the cluster and attempting to connect to our web server from there.</p><p>To test our setup, we’ll launch a container that will attempt to connect to our web service. Execute this command to start a temporary container using BusyBox with curl</p><pre>❯ kubectl run curlpod --image=radial/busyboxplus:curl -i --tty --rm --namespace web</pre><p>Now, let’s get to the crucial part — verifying internal access to our web server</p><pre>[ root@curlpod:/ ]$ wget -O- http://webserver-service:80<br>Connecting to webserver-service:80 (10.26.27.140:80)<br>&lt;html&gt;<br>&lt;head&gt;&lt;title&gt;Hello World&lt;/title&gt;&lt;/head&gt;<br>&lt;body&gt;<br>&lt;h1&gt;Hello, world!&lt;/h1&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;<br>- 100% |**************|    93   0:00:00 ETA</pre><p>Fantastic, it worked! However, remember the limitation of ClusterIP: it facilitates only internal network access. External access to the service would not be possible with this setup.</p><h4>NodePort Service</h4><p>A NodePort service opens a gateway for external access to your cluster and web application. It operates by exposing a specific port at the node level within Kubernetes. Traffic hitting this node port is then forwarded to the corresponding service, which in turn routes it to your web application.</p><p>Below is a diagram illustrating how the NodePort service functions within a Kubernetes cluster</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*Y4XqQwee6VDpe89jyeJUsQ.png" /></figure><p>First, let’s remove the existing service with the command kubectl delete svc webserver-service -n web</p><p>Now, we’ll establish a NodePort type of service. Copy and paste the following content into your terminal</p><pre>cat &lt;&lt;EOF | kubectl apply -n web -f -<br>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: webserver-nodeport<br>  namespace: web<br>spec:<br>  type: NodePort<br>  selector:<br>    app: webserver<br>  ports:<br>    - port: 80<br>      targetPort: 80<br>      nodePort: 30007<br>EOF</pre><p>To confirm our service is correctly set up and that the node port matches our configuration, run:</p><pre>❯ kubectl get service webserver-nodeport -n web -o=jsonpath=&#39;{.spec.ports[0].nodePort}&#39;<br><br>30007</pre><p>Great! To test external access to our web server, we need the node’s IP. Fetch it with the following command</p><pre>❯ kubectl get nodes -o wide<br><br>NAME                STATUS  AGE   VERSION          INTERNAL-IP   EXTERNAL-IP         <br>gke-pool-fajga-60d  Ready   20d   v1.27.8-gke.104  10.52.0.1    38.111.1.186 <br></pre><p>Now, with the node IP and port, let’s try accessing our web server</p><pre>curl http://38.111.1.186:30007<br><br>&lt;html&gt;<br>&lt;head&gt;&lt;title&gt;Hello World&lt;/title&gt;&lt;/head&gt;<br>&lt;body&gt;<br>&lt;h1&gt;Hello, world!&lt;/h1&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>If successful, you should see the ‘Hello, World’ page. If it doesn’t connect, check your network’s firewall rules to allow ingress on port 30007.</p><p>While NodePort enables quick external access, it’s typically not used in production due to its broad exposure and lack of load balancing. It exposes the same port across all cluster nodes, leading to potential traffic bottlenecks on a single node. Thus, NodePort is best suited for development and testing scenarios, where quick and easy external access is a priority.</p><h4>LoadBalancer Service</h4><p>Now that we’ve seen the limitations of ClusterIP for internal-only communication and NodePort’s shortcomings for production use due to its lack of traffic balancing, let’s explore the LoadBalancer service. As the name suggests, a LoadBalancer service in Kubernetes facilitates external access to your service through a cloud provider’s load balancer. This setup allows external traffic to be distributed efficiently to your service. Essentially, creating a LoadBalancer service in Kubernetes triggers the automatic provisioning of an external load balancer by your cloud provider, seamlessly integrating cloud infrastructure to manage traffic flow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*iiDh_9HCbo4mYYOwAcsw4w.png" /></figure><p>How does the LoadBalancer service work? It assigns a public IP address or DNS name to your service, making it accessible from outside the cluster. The LoadBalancer directs incoming traffic to the designated port on the service, which then efficiently routes it to the target pods. Let’s walk through the setup process.</p><p>First, we need to remove the existing NodePort service with kubectl delete svc webserver-nodeport --namespace=web . Next, let’s create a LoadBalancer service</p><pre>❯ kubectl apply -f - &lt;&lt;EOF<br>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: webserver-loadbalancer<br>  namespace: web<br>spec:<br>  type: LoadBalancer<br>  selector:<br>    app: webserver<br>  ports:<br>    - protocol: TCP<br>      port: 80<br>      targetPort: 80<br>EOF</pre><p>Applying this YAML doesn’t just create a service; it also signals your cloud provider to set up a load balancer. Initially, the EXTERNAL-IP field might show as &#39;pending&#39; while the load balancer is being provisioned.</p><pre> kubectl get svc -n web<br>NAME                     TYPE           CLUSTER-IP    EXTERNAL-IP   PORT(S)        AGE<br>webserver-loadbalancer   LoadBalancer   10.71.21.68   &lt;pending&gt;     80:31745/TCP   31s</pre><p>After the load balancer is up, its IP (listed under the EXTERNAL-IP column in the kubectl get svc output) allows external access to your web server. Try reaching it with the following command</p><pre>curl http://32.151.191.41:80   <br><br>&lt;html&gt;<br>&lt;head&gt;&lt;title&gt;Hello World&lt;/title&gt;&lt;/head&gt;<br>&lt;body&gt;<br>&lt;h1&gt;Hello, world!&lt;/h1&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>When you delete the LoadBalancer service using kubectl delete svc webserver-loadbalancer -n web, the associated load balancer will be removed as well.</p><p>While LoadBalancer might seem ideal for many scenarios, like NodePort, it’s often not the preferred choice for production. A more common approach in production environments involves using ‘ingress’ — a powerful concept that we’ll explore in a dedicated article, given its complexity and the scope of this guide.</p><h3>Wrapping Up Kubernetes Services</h3><p>In this guide, we’ve journeyed through the practical aspects of Kubernetes services, starting from the basic ClusterIP for internal communication, advancing to NodePort for external access with its inherent limitations, and culminating with the LoadBalancer service, which integrates with cloud provider capabilities for more efficient traffic management. While each service type has its unique use case and limitations, understanding them lays the foundation for more advanced networking solutions in Kubernetes, such as ingress, which we’ll explore in future discussions. This practical exploration serves as a stepping stone to mastering Kubernetes networking, enabling you to make informed decisions about the right service type for your applications</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ea8f9b754a2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kubernetes Upgrades & PDB]]></title>
            <link>https://medium.com/@bregman.arie/kubernetes-upgrades-pdb-41a5de597a62?source=rss-7ce43fdea353------2</link>
            <guid isPermaLink="false">https://medium.com/p/41a5de597a62</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[sre]]></category>
            <category><![CDATA[pdb]]></category>
            <category><![CDATA[gke]]></category>
            <dc:creator><![CDATA[Arie Bregman]]></dc:creator>
            <pubDate>Sat, 01 Apr 2023 18:30:17 GMT</pubDate>
            <atom:updated>2023-04-01T18:30:17.050Z</atom:updated>
            <content:encoded><![CDATA[<p>If you read my previous <a href="https://medium.com/@bregman.arie/elevating-your-kubernetes-clusters-resilience-pod-disruption-budget-43979a1cf104">articles on PDB</a> you know that PDB is a great mechanism for dealing with disruptions in Kubernetes. You tell it how many replicas of your application should exist by minimum, or the other way around — how many replicas of your application can be unavailable, and it makes sure to protect your application from disruptions given the set conditions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*1RNNzlsINcetTL2G8QTrag.png" /><figcaption>Completely random image by Arie Bregman</figcaption></figure><h3>Challenges of Kubernetes Cluster Upgrades and PDB</h3><p>The problem is, it sometimes interferes with existing planned disruptions that you won’t necessarily want it to interfere with. One common example would be Kubernetes upgrades. Let’s take the following environment as an example:</p><ul><li>You control when to perform Kubernetes upgrades (= manual Kubernetes upgrades)</li><li>You have PDB that allows zero disruptions on some of your workloads and those workloads have one replica</li></ul><p>In this case, whenever you try to perform an upgrade, the upgrade won’t be able to complete successfully immediately. To understand why, let’s discuss for a moment how an upgrade works — when you start a GKE upgrade what it does is cordon existing nodes and drain them in order to evict the Pods to the new nodes it has set up, with the newer Kubernetes version. But PDB prevents the eviction due to zero allowed disruptions so when it tries to drain the node and evict the Pods, it will simply loop over and over again, telling you it’s unable to evict some of the Pods.</p><p>Fortunately, some public cloud providers, like Google, understood that stuck upgrades are a bad thing and came up with ideas like the following idea: remove the node completely, with or without PDB, after one hour</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VJyHDQGd7Ne-8yGbwTMPvw.png" /><figcaption>A note on PDB and GKE upgrades from GCP’s documentation</figcaption></figure><p>This is good because that means you won’t have upgrades stuck forever. On the other hand, waiting one hour for an upgrade to unblock itself is far from optimal, especially if you have planned maintenance for these upgrades with limited time.</p><h3>Unblock Kubernetes Cluster Upgrades</h3><p>So now we understand the obstacles of upgrading Kubernetes clusters with PDB applied in certain conditions, let’s discuss some of the options of how to overcome them.</p><h4>Remove PDB before an upgrade and create it again once completed</h4><p>Yes, I know, far from being optimal. Some will argue it’s even a valid option. Not only does it requires intervention before and after an upgrade, but also if you manage your PDB through GitOps-based projects like ArgoCD, you have to make sure to stop and resume the synching of the PDB object(s). I would definitely choose this as the last resort if you aim for somewhat automated processes.</p><h4>Force upgrade of a node pool</h4><p>Some public cloud providers, like AWS, provide you with a way to enforce an upgrade in their Kubernetes flavor</p><blockquote>You can force the update if Amazon EKS is unable to drain the nodes as a result of a pod disruption budget issue</blockquote><p>Using this option will enforce the upgrade process, whether PDB exists or not. Unfortunately, this doesn’t exist in every Kubernetes flavor. GKE (Google Kubernetes Engine) has no force flag you can use. It has more aggressive options like deleting an instance group member during the upgrade.</p><h4>Re-creation of the node pool</h4><p>You might be managing upgrades (and your infra in general) through configuration management technologies like Ansible, Chef, etc., Or perhaps IaC technologies such as Pulumi, Terraform, etc. If you do, that unlocks a way for you to upgrade your cluster without any extra steps except changing the Kubernetes version.</p><p>I will mention that this way I’m about to show is quite aggressive since it doesn’t really disable PDB or anything similar to that, but it changes the upgrade method from “upgrade node by node” to “remove completely the node pool and create a new one”.</p><p>Let’s see how exactly it works with Terraform for example</p><pre>resource &quot;terraform_data&quot; &quot;kubernetes_worker_nodes_version&quot; {<br>  input = var.kubernetes_version<br>}<br><br>resource &quot;google_container_node_pool&quot; &quot;worker-nodes&quot; {<br>  name               = var.node_pool_name<br>  location           = var.region<br>  cluster            = data.google_container_cluster.cluster.name<br>  version            = var.kubernetes_version<br><br>  ...<br><br>  lifecycle {<br>      replace_triggered_by = [<br>        terraform_data.kubernetes_worker_nodes_version<br>      ]<br>    }<br>  }<br>}</pre><p>If you are familiar with Terraform, most of the configuration above probably seems pretty standard except perhaps for the lifecycle block. What that does is tell Terraform that this resource (Kubernetes node pool of the workers&#39; nodes) has to be completely replaced (as in deleted and created) instead of being updated. PDB can’t block any operation if the whole node pool is removed. Yes, as I said, this is quite aggressive, and yet, a good option to use if you don’t want to remove and create PDB or wait a whole hour before the upgrade is forced by GCP.</p><h4>Summary</h4><p>While PDB is a great mechanism for preventing disruptions to your workloads, sometimes it would actually interfere with processes we wouldn’t want it to interfere with, like Kubernetes cluster upgrades. Luckily, there are many ways to overcome this obstacle. In general, it highly depends on how you manage your upgrades, how your PDB is configured, and what flavor of Kubernetes you are using, but nonetheless, it’s likely there is a way for you to still keep using PDB while allowing exceptions in some cases.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41a5de597a62" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pod Disruption Budget: The Practical Guide]]></title>
            <link>https://medium.com/@bregman.arie/pod-disruption-budget-the-practical-guide-1eb4ff78b6c9?source=rss-7ce43fdea353------2</link>
            <guid isPermaLink="false">https://medium.com/p/1eb4ff78b6c9</guid>
            <category><![CDATA[devops-practice]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[pdb]]></category>
            <category><![CDATA[sre]]></category>
            <dc:creator><![CDATA[Arie Bregman]]></dc:creator>
            <pubDate>Sun, 19 Mar 2023 20:20:14 GMT</pubDate>
            <atom:updated>2023-03-19T20:20:14.179Z</atom:updated>
            <content:encoded><![CDATA[<p>In my <a href="https://medium.com/@bregman.arie/elevating-your-kubernetes-clusters-resilience-pod-disruption-budget-43979a1cf104">previous article</a> on Pod Disruption Budget, we mostly explored PDB theoretically. Now it’s time to get our hands dirty and see not only how to create PDB but also put it to a test and see if it actually protects our Pods from disruptions as expected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*ZG1ap0q9YG6HRnAh2XPcTw.png" /><figcaption>A completely random image by Arie Bregman</figcaption></figure><h3>What are the requirements for being able to use “Pod Disruption Budget”?</h3><p>Let’s start from the very beginning — what exactly do you need in order to use PDB? well the list is quite short</p><ul><li>Kubernetes ≥ 1.21</li><li>To create and apply PDB you have to specify on which Pods to apply it. Make sure you label your Pods accordingly so it’s easy to mark those that PDB should be applied on</li></ul><h3>How to create PDB?</h3><p>We’ll mention some of the ways that exist to create a PDB object.</p><h4>Kubectl Create</h4><p>To immediately apply PDB on a certain workload, run the following kubectl command</p><pre>kubectl create poddisruptionbudget app-pdb --min-available=1 \<br>                                           --selector=app=super-critical-app</pre><p>Let’s break it down:</p><ul><li>poddisruptionbudget is the Kubernetes API resource type we would like to create which is the “Pod Disruption Budget” resource. You could also use the short namepdb</li><li>app-pdb is the name of the PDB resource we created for the app super-critical-app</li><li>--min-available=1 makes sure 1 replica of our app is always available</li><li>--selector=app=super-critical-app is how we target which Pods should have the PDB applied on</li></ul><p>Another way to apply the very same thing, assuming you have 1 replica, is to use max-unavailable this way</p><pre>kubectl create poddisruptionbudget app-pdb --max-unavailable=0 \<br>                                           --selector=app=super-critical-app</pre><p>Why is it the same? Because if you have 1 replica and it can’t be unavailable, then you allow by max to have 0 replicas unavailable</p><h4>YAML definition</h4><p>Another way of course to create PDB objects is using YAML files describing the configuration of the PDB. Let’s see an example of the very same PDB from the previous section, using minAvailable</p><pre>apiVersion: policy/v1<br>kind: PodDisruptionBudget<br>metadata:<br>  name: app-pdb<br>spec:<br>  minAvailable: 1<br>  selector:<br>    matchLabels:<br>      app: super-critical-app</pre><p>Running kubectl apply -f &lt;YAML_FILE&gt; will create the very same PDB. Let’s see also an example of using maxUnavailable</p><pre>apiVersion: policy/v1<br>kind: PodDisruptionBudget<br>metadata:<br>  name: app-pdb<br>spec:<br>  maxUnavailable: 0<br>  selector:<br>    matchLabels:<br>      app: super-critical-app</pre><h4>Helm Charts</h4><p>If you are using Helm charts, you should know some charts support creating PDB built-in by modifying the chart’s values. For example both mongodb and rabbitmq charts support the following values to create PDB for their workloads</p><pre>pdb:<br>  create: true<br>  minAvailable: 1<br>  maxUnavailable: 0</pre><p>When deploying the charts with the values above, it will create the very same PDB we saw earlier, but applied specifically on the app deployed by the chart.</p><h3>Verify PDB created and applied</h3><p>Let’s start with listing our PDB objects. There should be one, the one created in the previous section called app-pdb</p><pre>$ kubectl get pdb</pre><pre>NAME        MIN AVAILABLE   MAX UNAVAILABLE   ALLOWED DISRUPTIONS   AGE<br>app-pdb         1              0                      0      </pre><p>Great, we have PDB in our cluster and it is set to make sure our application has a minimum of 1 replica. Since we run 1 replica by default, only 1 replica can be unavailable (or else our application will stop running).</p><p>Question is, how do we know it actually applied on our Application Pod? to answer that, let’s first check our PDB definition</p><pre>$ kubectl describe pdb app-pdb<br><br>Name:           app-pdb<br>Namespace:      my-namespace<br>Min available:  1<br>Selector:       app=super-criticalp-app<br>Status:<br>    Allowed disruptions:  0<br>    Current:              1<br>    Desired:              1<br>    Total:                1</pre><p>We can see our PDB is applied on Pods that have the label app=super-critical-app . Let’s see if we can actually find a Pod with this label</p><pre>$ kubectl get pods -l  &quot;app=super-critical-app&quot;<br><br>NAME                    READY   STATUS    RESTARTS   AGE<br>super-critical-app      1/1    Running      0       17h</pre><p>Great! we see that our PDB actually applies to an existing running Pod. Now let’s proceed to prove that PDB actually does what it is supposed to do.</p><h3>Test out PDB</h3><p>To fully understand PDB’s power, the best thing you can do is to actually put it to the test with different scenarios where it is supposed to “protect” the app from going under a certain number of replicas.</p><h4>Node Drain</h4><p>Let’s start with draining a node and not just any node, but the node on which our app replicas are running. A node drain will evacuate all the Pods from a certain node after marking it as “cordoned” which means no new Pods can be scheduled on that node.</p><p>Let’s say we executed kubectl get po -o wide | grep -i super-critical-app and we found out the node name is some-node-name (yes, original name, I know). Let’s drain that node.</p><pre>$ kubectl drain some-node-name --ignore-daemonsets</pre><pre>node/some-node cordoned</pre><p>That’s a good start. First, we see our node is cordoned which means no new workloads will be scheduled there. Let’s see how the output continues</p><pre>evicting pod default/some-app<br>evicting pod default/super-critical-app<br>evicting pod default/meh-app</pre><p>Interesting. all the Pods on the node are going to be evicted. But don’t be mistaken, this doesn’t mean PDB doesn’t work. That’s just a message on what it plans to do. Let’s see what comes next</p><pre>evicting pod default/super-critical-app<br>error when evicting pods/&quot;super-critical-app&quot; -n &quot;default&quot; (will retry after 5s): Cannot evict pod as it would violate the pod&#39;s disruption budget.<br>evicting pod default/telegraf-bb85f9d4-pkhcp<br>error when evicting pods/&quot;super-critical-app&quot; -n &quot;default&quot; (will retry after 5s): Cannot evict pod as it would violate the pod&#39;s disruption budget.</pre><p>PDB to the rescue! Kubernetes is unable to evict the Pod (the one our newly created PDB targets) from the node because it evaluates the defined PDB and reaches the conclusion that if it evacuates it, the available number of Pods won’t be 1 anymore but 0 instead (and that lower than minAvailable=1)</p><h4>Kubernetes Node Pool Upgrade</h4><p>Let’s test PDB as part of another workflow — upgrading a node pool of a GKE cluster in GCP (Google Cloud Platform) with one node and minAvailable=1 . The way such a process usually works is by marking nodes with cordoned (so no new workloads scheduled on them) and then applying drain to move workloads to the new node with the updated Kubernetes version. In theory, PDB should prevent it, as it means the number of replicas will reduce to 0 when evicting the Pods from one node to another. Let’s test it out.</p><p>First, upgrade the Kubernetes version. This is can be done easily through the web UI (GKE -&gt; Node Pool -&gt; Edit -&gt; Change under “Node Version”) or using the gcloud CLI gcloud container clusters upgrade CLUSTER_NAME --node-pool=NODE_POOL_NAME --cluster-version VERSION .</p><p>And the result is…no upgrade! well, not really. Yes, at first your workload will not move to the new node and basically will be the only thing remaining on the old node (assuming you don’t have PDB on other workloads). But see this interesting message you get from GCP</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2v8zHoQkcOjY4m9fA3eisg.png" /></figure><p>When going to documentation to learn more, you’ll notice the following sentence “During automatic or manual node upgrades, <a href="https://kubernetes.io/docs/tasks/run-application/configure-pdb/">PodDisruptionBudgets (PDBs)</a> and <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-termination">Pod termination grace period</a> are respected for a maximum of 1 hour.” In other words, it’s fine you used PDB to prevent disruptions, but after one hour we are going to pretend it’s not there. An interesting case in my opinion, because it shows some exceptions always exist and so you shouldn’t assume any solution is completely bulletproof.</p><h4>More scenarios to test out!</h4><p>Want to keep playing with PDB? Up to the challenge of running more complex scenarios? good, here are a couple of proposals (hint: PDB won’t work for every scenario listed here!)</p><ul><li>Node Memory Pressure</li><li>Kubectl Pod Delete</li><li>Complete Node (or Node Pool) Removal</li></ul><h3>Summary</h3><p>While in the <a href="https://medium.com/@bregman.arie/elevating-your-kubernetes-clusters-resilience-pod-disruption-budget-43979a1cf104">previous article</a> we mostly deep-dived into the theoretical part of PDB, understanding what is it exactly and when should it be (or not) used, in this article, we got our hands dirty and to be more specific, we did not only demonstrated how to create it but also we’ve put it to the test to see how it plays in different scenarios. Overall, PDB is a powerful concept and can help you tremendously in making your Kubernetes cluster more resilient than ever.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1eb4ff78b6c9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Elevating your Kubernetes Cluster’s Resilience: Pod Disruption Budget]]></title>
            <link>https://medium.com/@bregman.arie/elevating-your-kubernetes-clusters-resilience-pod-disruption-budget-43979a1cf104?source=rss-7ce43fdea353------2</link>
            <guid isPermaLink="false">https://medium.com/p/43979a1cf104</guid>
            <category><![CDATA[pdb]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[sre]]></category>
            <category><![CDATA[pod-disruption-budget]]></category>
            <category><![CDATA[pods]]></category>
            <dc:creator><![CDATA[Arie Bregman]]></dc:creator>
            <pubDate>Sun, 19 Mar 2023 18:56:14 GMT</pubDate>
            <atom:updated>2023-03-19T20:22:04.519Z</atom:updated>
            <content:encoded><![CDATA[<p>One of the challenges in managing Kubernetes clusters is ensuring high availability and fault tolerance. While the concept of replicas is useful for making sure multiple instances of your application exist, it doesn’t guarantee your application will always run without disruptions. This is where Pod Disruption Budget (PDB) comes into play. PDB is a Kubernetes feature that helps maintain the stability of an application by setting rules regarding how many disruptions your application can deal with. In this article, we’ll deep dive into PDB and learn what is it exactly, when should you use it, and why. The practical aspect of this topic is covered in a <a href="https://medium.com/@bregman.arie/pod-disruption-budget-the-practical-guide-1eb4ff78b6c9">separate article</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*R6hikOFBqX07f9QKM5A_Yw.png" /><figcaption>A completely random image created by Arie Bregman</figcaption></figure><h3>What is a “Pod Disruption”?</h3><p>A Pod disruption describes any scenario that impacts the running state of a Pod and causes it to be unavailable. It’s commonly divided into two types of disruptions:</p><ol><li><strong>Involuntary Disruptions</strong>: Any unplanned scenario where our control to manage it is either limited or doesn’t exist. For example, hardware failures and kernel panic situations.</li><li><strong>Voluntary Disruptions</strong>: Planned actions performed by the cluster admin or application owner. For example, starting a node drain or upgrading manually a cluster.</li></ol><h3>What is a “Pod Disruption Budget”?</h3><p>So now that you know what is Pod disurption, let’s discuss the mechanism that is supposed to help us manage it. Simply put, A Pod Disruption Budget, or PDB, allows you to manage the number of replicas that should be available at any given point in time. When defining PDB for an app, you specify one of the following:</p><ul><li>The minimum number of replicas of a Pod that must be available at all times. Also known as <strong>min available</strong>.</li><li>The maximum number of replicas that can be unavailable. Also known as <strong>max unavailable</strong>.</li></ul><p>Practically, that means that if for example your application has 6 replicas but you set a PDB of a minimum available 3 replicas, PDB won’t have any effect on your application as long as three replicas of your application are running. When getting to a lower number of replicas than 3, this is where some Kubernetes operations will be stopped — for example the scale down of your cluster will be stopped if it means that less than 3 replicas will exist as a result of the scale down of the cluster</p><p>The following output is of kubectl get pdb which lists what PDBs we have defined in our cluster. Assuming app-1 and app-2 both have one replica each, the PDBs will achieve the very same thing, one using the “Min Available” (minimal available number of replicas) and “Max Unavailable” (maximum number of replicas that can’t be unavailable).</p><pre>$ kubectl get pdb<br><br>NAME       MIN AVAILABLE   MAX UNAVAILABLE   ALLOWED DISRUPTIONS   AGE<br>app-1-pdb      N/A             0                 0                 3h53m<br>app-2-pdb       1             N/A                0                 3h53m</pre><h3>Is PDB the optimal solution for ensuring your application is always running?</h3><p>Shortly, No. PDB isn’t your new all-can-do solution for making sure your application runs 100% of the time. Not only because technically it isn’t bulletproof, but also because sometimes, other methods should be applied to make sure your application keeps running properly all the time. Let’s discuss some examples.</p><p>Let’s start with a simple example — let’s say you have a Pod called my-app with one replica and PDB applied with minAvailable=1 which means there must be always one replica running and so no disruptions to the pod are allowed. Now what would you think will happen if you go and run kubectl delete po my-app ? if your answer was “it will be deleted” then you are correct. PDB won’t prevent the Pod from being deleted although it violates the disruption budget for the simple reason that directly deleting a Pod with kubectl is considered an administrative operation called directly by the admin rather than an operation administrated by Kubernetes services themselves and so PDB has no effect when the admin directly removes a Pod.</p><p>Let’s take another example — a node that gets drained in order to be upgraded. You have more than one node in your cluster and your application is highly available, but every time the cluster goes through an upgrade all nodes get “drained” at the same time and so your application is down. Should PDB be your default way to manage it? not exactly. There are many, much more “subtle”, solutions before applying PDB in this case. One example would be to make sure replicas are running each on a separate node (Pod anti-affinity rules) and set a different upgrade strategy where each node gets upgraded one at a time.</p><p>Do not tempt to immediately go and apply PDB. Understand your environment and conditions so you can find a best-fit solution. PDB has pitfalls and hidden costs which one should be aware of because choosing it to manage any Pod disruption.</p><h3>The pitfalls of PDB</h3><p>Let’s mention what it actually costs to use PDB in your cluster</p><ul><li>PDB will block certain operations from being fully completed. Let’s say you would like to drain a certain node from all of its workloads. In certain conditions, having PDB will block this operation from completing which results in having a node with applications that can’t be evicted due to PDB. It is true that sometimes this is exactly what you want to happen because that’s the reason you set PDB in the first place — to make sure your application is running the whole time, but if not planned accordingly, PDB may interrupt some existing processes you have in your environment</li><li>While some operations will not be completely blocked by PDB, it will <strong>delay</strong> them. Remember the node drain example? well, one of the processes that is using node drain is Kubernetes version upgrades. In GCP (Google Cloud Platform) for example, when upgrading the version of a certain GKE node pool, the nodes are cordoned and drained. While PDB will at first prevent the upgrade from completely draining your nodes, eventually it will happen, as GKE performs the operation eventually after one hour, even with PDB set. So PDB not only won’t prevent your applications from going down but it will actually delay this whole process of upgrading the node pool.</li><li>PDB can affect your cluster&#39;s ability to scale down. Imagine two nodes. Each with completely different applications, so if one node is down, some of the applications will be impacted. But what if I tell you that all the applications can run on the same node and Kubernetes would scale down your cluster if it could? The problem: it will cause a disruption that will impact your application availability and so PDB will prevent it from happening. You will then pay more for your cluster in the price of your application reliability.</li></ul><h3>PDB use-cases</h3><p>Once we clarified PDB isn’t the answer to every scenario of Pod disruption and that using it should be thoroughly considered, let’s mention some of the use cases where you would want to actually use PDB</p><ul><li>Your application can’t be highly available for different reasons (e.g. cost considerations) but you would like to have autoscaling enabled. In this case, you need to make sure that the node that scales down isn’t the one where your non-highly-available application is running. PDB is a good option to deal with this scenario.</li><li>Your application is highly available, but some operations you run on your cluster nodes bring down all replicas of your application at the same time and cause disruption. PDB can help you ensure these operations happen gradually so each node is treated separately in its own turn, in a way that doesn’t impact your application availability.</li><li>You have an application with multiple replicas, but when you update the application it takes down all the replicas at the same time, impacting the application’s availability. You can enforce rolling updates to the application by using PDB, stating that only a specific number of replicas can be down at any given point of time (or the other way around — specify how many should be available by minimum)</li></ul><h3>Prevent or won’t prevent?</h3><p>So far we mentioned a lot of theoretical conditions and workflows in which PDB can help. To summarize the topic of PDB, let’s mention clearly some scenarios in Kubernetes and whether PDB will be helpful in each (If you would like to do a self-check of your knowledge on the topic, I recommend to try and answer before reading the content of each scenario).</p><h4>Direct removal of a Pod with “kubectl delete pods”</h4><p>Remember, directly removing a Pod is considered an “administrative operation” which isn’t part of the workflows triggered by Kubernetes API hence, PDB won’t prevent from the Pod being deleted</p><h4>Eviction of Pods due to node memory pressure</h4><p>When a node in Kubernetes reaches high utilization of memory, it’s called “node memory pressure” and to make sure some Pods won’t start getting OOM killed (killed due to out of memory), Kubernetes starts to evict them to another node. In the case of PDB, Kubernetes won’t be able to move a Pod if that is considered a violation of the PDB set, so PDB will be useful for preventing it.</p><h4>Complete Removal of the Node</h4><p>When a node is completely removed for whatever reason, all the workloads on it will be removed as well and PDB won’t stop the removal of the node.</p><h4>Kubernetes Node Pool Upgrade</h4><p>The way a node pool is usually upgraded is by applying a cordon &amp; drain on a node. PDB will prevent disruption on your Pods caused by a drain operation</p><h3>Summary</h3><p>In this article, we covered PDB — the feature in Kubernetes to manage your application resiliency in case of disruptions. We started with explaining what a Pod disruption even means and then deep-dived into what PDB is and when you should use it (or not). Ready to get your hands dirty by experimenting with PDB? jump to the <a href="https://medium.com/@bregman.arie/pod-disruption-budget-the-practical-guide-1eb4ff78b6c9">practical guide</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=43979a1cf104" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Yet another introduction to Go]]></title>
            <link>https://medium.com/@bregman.arie/yet-another-introduction-to-go-1c09de8f3183?source=rss-7ce43fdea353------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c09de8f3183</guid>
            <category><![CDATA[go]]></category>
            <category><![CDATA[101]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[introduction]]></category>
            <dc:creator><![CDATA[Arie Bregman]]></dc:creator>
            <pubDate>Sat, 04 Mar 2023 21:13:02 GMT</pubDate>
            <atom:updated>2023-03-04T21:13:02.040Z</atom:updated>
            <content:encoded><![CDATA[<p>The following is intended for anyone who starts his or her journey of learning Go. It isn’t full of details on how things work. It mostly aims at providing a short, concise summary of everything you need to know to start writing and running Go programs. In the end, you’ll also be provided with a list of resources you can use to keep developing your Go knowledge and skills.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*MqCGPwXlQJdskH04U-MKoQ.png" /><figcaption>Image by Arie Bregman</figcaption></figure><p>If you are asking your self “Why another introduction to Go when there are so many resources already out there?” That’s a legitimate question and you are not wrong that there are out there many Go introductions at this point, but admittedly, I felt like there is a place for another introduction and wanted to provide my own interpretation of what you need to be familiar with when you start with Go.</p><h3>So, what is Go?</h3><p>Go, also known as Golang, is a modern programming language designed to be simple, fast, and efficient. It was created by Google in 2009 and has gained popularity due to its built-in concurrency features and low memory footprint.</p><p>Some popular projects that have been built with Go include Docker, Kubernetes, and the popular open-source database CockroachDB. Go’s simplicity and speed make it a great choice for building scalable and high-performance applications, particularly in the world of cloud computing and distributed systems.</p><h3>What should I be using to write Go code?</h3><p>Quite a common question by junior developers, but for me, the answer is always really “whatever you find more comfortable”. Let’s be honest, there many really good IDEs there. I wouldn’t take seriously any opinion saying there is only one good IDE for Go. Let’s mention some of the common options out there</p><ul><li><strong>Visual Studio Code</strong> — A great IDE for Go, but also many other languages. What makes Visual Studio Code great is all the extensions it supports, built by not only the vscode team itself but by the community as well.</li><li><strong>GoLand</strong> — While I personally didn’t use GoLand, my team members really like this IDE and this is also a GO-specific IDE that supports mean Go-specific features.</li><li><strong>Vim — </strong>don’t raise your eyebrow so fast. I know, probably not a common option and also not an IDE per se, but <strong>Vim </strong>is great for small-scale Go projects and scripts in my opinion and I personally will keep using it ;)</li></ul><h3>Run your first Go program</h3><p>Let’s get straight to the business! Create a new directory and in that directory, an empty file called my_first_program.go . I’ll do it using Linux commands, but you can use any method you prefer</p><pre>mkdir go_projects &amp;&amp; cd go_projects<br>touch my_first_program.go</pre><p>Now, save the following to the file we created which is called my_first_program.go</p><pre>// This is a comment. What this program does is to print a string.<br><br>// main is the a name of the package. In Go everything is made of packages<br>package main   <br><br>// fmt is the package we&#39;ll use to print a string and this is why we import it<br>import &quot;fmt&quot;   <br><br>// main function is the main entry point of our program<br>func main() {<br>    // Printlin used to print the string and this is where we use fmt package<br>    fmt.Println(&quot;My first Go program! Amazing!&quot;)<br>}</pre><p>Run the go program we’ve written with go run my_first_program.go</p><pre>$ go run my_first_program.go<br><br>My first Go program! Amazing!</pre><p>Great! it worked. You’ve written and executed your first Go program and we saw the output My first Go program! Amazing! as expected.</p><h4>Formatting your Go Code</h4><p>Formatting your code is important. One of its clear benefits is it makes your code much more readable. Fortunately, Go provides you with built-in tooling to make sure your code is properly formatted. Let’s test it.</p><p>Let’s modify our previously written code to the following code</p><pre>package main                                    <br>import &quot;fmt&quot;                                    <br>func main() {                                   <br>    fmt.Println(&quot;My first Go program! Amazing!&quot;)}</pre><p>We removed break lines between the package, import, and func calls, and put the closing brackets on the same line as the Println function call. Is it still readable? depends on who you ask but even with a very simple program you can see the difference from a well-formatted code.</p><p>Now let’s use the built-in formatting tooling and see what it does</p><pre>$ go fmt my_first_program.go<br>$ cat my_first_program.go<br><br>package main<br><br>import &quot;fmt&quot;<br><br>func main() {<br> fmt.Println(&quot;My first Go program! Amazing!&quot;)<br>}</pre><p>Amazing! back to readable and well-formatted code. Get used to running go fmt every time you write Go code to have readable and well-formatted code.</p><h4>Third-Party Go Packages</h4><p>The Go community keeps growing every year and many great Go projects are being developed. Luckily Go allows you to install these Go projects quite easily with go install</p><p>For example, golangci-lint is a popular project for linting in Go. Let’s install and use it</p><pre>$ go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest<br><br>$ golangci-lint run my_first_program.go</pre><p>When you run golangci-lint and you don’t get any output, that’s a good thing and it means you don’t have any issues to address with your code styling.</p><p>If you wonder where Go installs the packages then, the simple answer is, it depends. If you have theGOPATH variable defined, then it installs the packages there. If you don’t then have it set, it installs the packages to $HOME/go . I highly recommend you’ll add it to your path in your shell startup file. I&#39;m using zsh so in my case that would be~/.zshrc . If you are using Bash then that would be ~/.bashrc in your case.</p><p>You should also know that if you would simply want to download the projects, but not install them, you could use go get instead of go install .</p><h4>Linting</h4><p>In the previous section, we installed a Go linting project. Linting is used by developers to ensure they follow certain common style guidelines. To understand the potential power of linting, let’s modify our code a little bit and run golangci-lint again</p><pre>                                                                            <br>package main<br> <br>import &quot;fmt&quot;<br> <br>func yay() { // new function added<br>}<br> <br>func main() {<br>    fmt.Println(&quot;My first Go program! Amazing!&quot;)<br>}</pre><p>Notice we added a function that isn’t used anywhere called yay . Let’s run golangci-lint and see what we get this time as a result</p><pre>$ golangci-lint run my_first_program.go <br><br>my_first_program.go:7:6: func `yay` is unused (unused)<br>func yay() {<br>     ^</pre><p>You can see it tells us we defined a function calledyay on line 7, but it’s unused. This is great, because as a developer I know I can remove the function yay, reduce the number of lines in the program and not impact it in any way.</p><p>As your programs grow and things get complex, linting becomes much more crucial in making sure your programs are following common styling guidelines.</p><h3>Sharing your Go programs</h3><p>At some point, you’ll share your code and program with others. Not only because “sharing is caring” but because it’s likely not everything you’ll develop will be a solo endeavor and built specifically for your personal purpose. Let’s look at some of the methods available to properly share your code and automate the process of building and running your program</p><h4>Build a binary out of your program</h4><p>Most of the time, when publishing your programs and sharing with others, you won’t share the actual .go files. Instead, you’ll share one binary that the user can easily run which invokes your code. To create such a binary all you have to do is to run go build &lt;GO program&gt; . This is how we’ll apply to the program we’ve written above</p><pre>$ go build my_first_program.go<br>$ ./my_first_program<br><br>My first Go program! Amazing!</pre><p>Great, now we have a binary called my_first_program and we could potentially share the binary itself with other users.</p><h4>Makefiles</h4><p>Make and Makefiles are not Go concepts and existed long before Go. Makefiles are also less about direct sharing and more about automating the operations you commonly run on your code. Such operations include testing and building your code.</p><p>Let’s for example set up a Makefile for our code</p><pre>.DEFAULT_GOAL := build<br>        <br>fmt: <br>    go fmt ./...<br>.PHONY:fmt<br>        <br>lint: fmt <br>    golangci-lint run my_first_program.go                                                                                                               <br>.PHONY:lint<br>        <br>build:<br>    go build my_first_program.go<br>.PHONY:build</pre><p>Now, you (and others using your code) can easily run different operations on the code. For example for anyone who would like to run lint tests on the code, they can simply run make lint, and the details of what it does exactly don’t matter to the common user/developer and can include additional commands in the future. It doesn’t matter how many lines you’ll add there, the end command will remain the same — make lint .</p><p>.DEFAULT_GOAL := build means that by default anyone running make will actually execute make build .</p><h3>I would like to learn more! Where should I go next?</h3><p>That’s it. That was our intro for Go. Nothing too fancy or detailed, but exactly what you need to start your actual journey with Go (at least in my opinion). Let’s talk about your next steps.</p><p>Different people have different preferences as to how to learn something new. This is why I’ll separate this section into categories of “practice” and “reading”. In my opinion, you should combine the two for an optimal learning experience, but that’s really up to you of course.</p><h4>Practicing</h4><ul><li><a href="https://exercism.org/">Exercism</a> — If you read other stuff I’ve written, you probably know at this point I really like Exercism for many reasons — it allows you to build your knowledge gradually by solving actual exercises and you can choose whether you do it online or from your own IDE or terminal. I would definitely give it a try.</li><li><a href="https://github.com/bregman-arie/go-exercises">Go Exercises</a> — Disclaimer: It’s a repository I’ve created. I’ve created it so users can practice the different concepts of Go and eventually become better at it.</li><li>Build projects — easier said than done but writing programs and building projects (doesn’t matter if small or big) is probably one of the best ways to learn. Don’t be discouraged if you feel stuck sometimes. It’s always hard at first but as you keep practicing, you’ll get the hang of it.</li></ul><h4>Reading</h4><ul><li><a href="https://go.dev/tour/welcome/1">A Tour of Go</a> — Great way to learn about the different Go concepts. I should mention it could potentially be in the previous section as it allows you to modify the examples you’ll read about.</li><li><a href="https://go.dev/doc/effective_go">Effective Go</a> — A great document with tips, guidelines, and examples on how to write effective Go. I would read it after writing a couple of simple programs. It will be much more effective ;)</li><li><a href="https://github.com/golang/go/wiki/CodeReviewComments">Go Code Review Comments</a> — A collection of common comments made during the review of the Go code. In general, a great way to learn is by submitting code and getting reviews on it. So in this link, you’ll find some of the most common comments that will help you write effective Go code.</li><li><a href="https://go.dev/ref/spec">The Go Programming Language Specification</a> — Not the first resource I would read and to be honest, I would practice Go for some time before reading Go’s specification. But, if you are serious about Go, you definitely want to read it at least once at some point.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c09de8f3183" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>