<?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 Ana Cozma on Medium]]></title>
        <description><![CDATA[Stories by Ana Cozma on Medium]]></description>
        <link>https://medium.com/@ana.cozma?source=rss-c58698151430------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*pA5ZxjdRrWizmL5JaQbS3w.jpeg</url>
            <title>Stories by Ana Cozma on Medium</title>
            <link>https://medium.com/@ana.cozma?source=rss-c58698151430------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 15:28:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ana.cozma/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[How to Check TLS Configuration of URLs with Curl and Bash Script]]></title>
            <link>https://medium.com/@ana.cozma/how-to-check-tls-configuration-of-urls-with-curl-and-bash-script-fe0889598f93?source=rss-c58698151430------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe0889598f93</guid>
            <category><![CDATA[bash]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[tls]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Ana Cozma]]></dc:creator>
            <pubDate>Mon, 19 Aug 2024 13:25:12 GMT</pubDate>
            <atom:updated>2024-08-20T14:19:44.061Z</atom:updated>
            <content:encoded><![CDATA[<p>If you are working in an Azure environment and you are using Azure Availability Tests you might run into the following Health Advisory event:</p><blockquote>On 31 October 2024, in alignment with the Azure wide legacy TLS deprecation, TLS 1.0/1.1 protocol versions and the below listed TLS 1.2/1.3 legacy Cipher suites and &gt; Elliptical curves will be retired for Application Insights availability tests.</blockquote><p>For a list of deprecated versions and remaining supported versions have a look over the official documentation <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/app/availability?tabs=standard#deprecating-tls-configuration">here</a>.</p><p>But how do you quickly check which endpoint in your availability tests is impacted?</p><p>This was the initial scenario that led me to create and ultimately write this blog post, but these checks can be applied to any case where you need to retrieve and verify the TLS configuration of URLs.</p><p>Whether you’re ensuring compliance with security standards, troubleshooting connection issues, or simply gathering information for audits, the script can help you get the information you need.</p><h3>Using Curl for one URL</h3><p>You can use the curl command with the -v (verbose) option to see detailed information about the TLS handshake, including the TLS version by running the command below:</p><pre>curl -s -v https://example.com 2&gt;&amp;1 | grep &quot;SSL connection using&quot;</pre><p>Explanation of the command and its parameters:</p><ul><li>Use curl to make a request to the specified URL.</li><li>The -s option makes curl silent, except for errors.</li><li>The -v option outputs verbose information.</li><li>The 2&gt;&amp;1 redirects the standard error (where verbose output is written) to standard output, allowing grep to filter it.</li><li>The grep &quot;SSL connection using&quot; command filters out the line containing the TLS version.</li></ul><p>By running the command the output will be something like this:</p><pre>* SSL connection using TLSv1.2 / ECDHE_RSA_AES_256_GCM_SHA384</pre><p>But what if you have more than one URL you need to check? Running this command manually can be tiring and it will involve a lot of copy-pasting which can be time-consuming. So let’s look into saving up some time.</p><h3>Using Curl and a Bash script to loop through a list of URLs</h3><p>We can take this a step further and create a script that will accept a list of URLs, loop through them and output the information we need. You can achieve this by following the steps below:</p><p><strong>1. Create the file:</strong></p><p>First, let’s create a file check_tls_version.sh or you can name it however you want:</p><pre>touch check_tls_version.sh</pre><p><strong>2. Make the Script Executable:</strong></p><pre>chmod +x check_tls_details.sh</pre><p><strong>3. Create the Script:</strong></p><pre>vi check_tls_version.sh</pre><p>You can use vi, nano or just open in any Editor of your choice and paste inside the newly created file the code below:</p><pre>#!/bin/bash<br><br># Check if a file was provided as an argument<br>if [ -z &quot;$1&quot; ]; then<br>  echo &quot;Usage: $0 &lt;file_with_urls&gt;&quot;<br>  exit 1<br>fi<br><br># Read the file line by line<br>while IFS= read -r url; do<br>  # Make sure the line is not empty<br>  if [ -n &quot;$url&quot; ]; then<br>    echo &quot;Checking $url...&quot;<br><br>    # Use curl to fetch the TLS details<br>    output=$(curl -s -v &quot;$url&quot; 2&gt;&amp;1)<br><br>    # Extract the TLS version<br>    tls_version=$(echo &quot;$output&quot; | grep &quot;SSL connection using&quot; | awk &#39;{print $5}&#39;)<br><br>    # Extract the cipher suite<br>    cipher_suite=$(echo &quot;$output&quot; | grep &quot;SSL connection using&quot; | awk -F&#39;/&#39; &#39;{print $2}&#39; | xargs)<br><br>    # Extract the elliptic curve (if available)<br>    elliptic_curve=$(echo &quot;$output&quot; | grep &quot;SSL certificate verify&quot; | grep -o &#39;(?&lt;=using ).*(?= curve)&#39;)<br><br>    # Output the results<br>    echo &quot;URL: $url&quot;<br>    echo &quot;TLS Version: ${tls_version:-Could not retrieve TLS version}&quot;<br>    echo &quot;Cipher Suite: ${cipher_suite:-Could not retrieve cipher suite}&quot;<br>    if [ -n &quot;$elliptic_curve&quot; ]; then<br>      echo &quot;Elliptic Curve: $elliptic_curve&quot;<br>    else<br>      echo &quot;Elliptic Curve: Could not retrieve elliptic curve or not applicable&quot;<br>    fi<br>    echo &quot;&quot;<br>  fi<br>done &lt; &quot;$1&quot;</pre><p>In the sample above, I added comments on what each line does, but feel free to modify it to extract more or less of the information you are interested in.</p><p><strong>4. Prepare a File with URLs:</strong></p><p>Create a text file with one URL per line, e.g., urls.txt:</p><pre>https://example.com<br>https://anotherexample.com</pre><p><strong>5. Run the Script:</strong></p><p>Having both the script ( heck_tls_details.sh) and our list of URLs we need to check( urls.txt), we can now run the script we created:</p><pre>./check_tls_details.sh urls.txt</pre><p><strong>6. Sample Output:</strong></p><p>The script will have an output similar to this one for each URL you provided:</p><pre>Checking https://example.com...<br>URL: https://example.com<br>TLS Version: TLSv1.3<br>Cipher Suite: AEAD-AES128-GCM-SHA256<br>Elliptic Curve: X25519<br><br>Checking https://anotherexample.com...<br>URL: https://anotherexample.com<br>TLS Version: TLSv1.2<br>Cipher Suite: ECDHE-RSA-AES256-GCM-SHA384<br>Elliptic Curve: prime256v1</pre><p>Explanation of the output parameters:</p><p><em>URL:</em> The URLs being checked — the ones you provide in the urls.txt file.<br><em>TLS Version:</em> The TLS version used by the URL.<br><em>Cipher Suite:</em> The cipher suite used for the connection.<br><em>Elliptic Curve:</em> The elliptic curve used, if applicable.</p><p>Now that you have your data you can simply compare the TLS version, Cipher Suite or Elliptic Curve against the deprecated or supported versions and take appropriate actions to update them.</p><p>Lastly, I have used curl on Mac, but you can use the same on Windows by installing it from <a href="https://curl.se/windows/">here</a>.</p><p><em>Thank you for reading and I hope this helps someone out there with your use case!</em></p><p><em>Originally published at </em><a href="https://coffeewithana.cloud/posts/get-tls-details-bash-script/"><em>https://coffeewithana.cloud</em></a><em> on August 19, 2024.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe0889598f93" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OpenSSH CVE-2024–6387 Vulnerability and your AKS VMSS node images]]></title>
            <link>https://medium.com/@ana.cozma/openssh-cve-2024-6387-vulnerability-and-your-aks-vmss-node-images-8b4cb0f4a779?source=rss-c58698151430------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b4cb0f4a779</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[azure-kubernetes-service]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Ana Cozma]]></dc:creator>
            <pubDate>Wed, 17 Jul 2024 08:07:15 GMT</pubDate>
            <atom:updated>2024-07-17T12:45:41.980Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2TuH4_E9ejb0mszemtGcSw.jpeg" /><figcaption>Image generated with Bing AI</figcaption></figure><p>Recently a new vulnerability in OpenSSH has been identified and the first question that popped into my mind was: <em>How do I make sure my nodes are not affected by _this vulnerability</em>?</p><p>In this blog post, I wanted to go over what the vulnerability is, how it can be exploited, explain how you can check if your Azure Kubernetes Service (AKS) is vulnerable to CVE-2024–6387 and what you can do about it, including different options for upgrading the VMSS image and how to choose between them.</p><h3>Understand the vulnerability</h3><p><a href="https://nvd.nist.gov/vuln/detail/CVE-2024-6387">CVE-2024–6387</a> is a critical unauthenticated RCE-as-root vulnerability that was identified in the OpenSSH server, sshd, in glibc-based Linux systems. If exploited, this vulnerability grants full root access, affects the default configuration and does not require user interaction thus it is classified as a <strong>High Severity</strong>.</p><p>This was identified on the 1st of July 2024.</p><p>The researchers who discovered it also noted that in 2006 OpenSSH faced this vulnerability known as <a href="https://security-tracker.debian.org/tracker/CVE-2006-5051">CVE-2006–5051</a>. While the 2006 one was patched, the bug has reappeared. This is why the latest, CVE-2024–6387, vulnerability is dubbed the “regreSSHion bug”: we see a reintroduction of an issue that was fixed due to code changes.</p><p>CVE-2024–6387 vulnerability impacts the following OpenSSH server versions:</p><ul><li>Open SSH version between 8.5p1 - 9.8p1 (excluding)</li><li>Open SSH versions earlier than 4.4p1, if they&#39;ve not backport-patched against CVE-2006-5051 or patched against CVE-2008-4109</li></ul><p>As of the 9th of July another vulnerability has been discovered: <a href="https://nvd.nist.gov/vuln/detail/CVE-2024-6409">CVE-2024–6409</a>.</p><p>This is a distinct vulnerability from the regreSSHion bug. The vulnerability allows an attacker to execute code within the <em>privsep</em> child process. This child process is a part of OpenSSH that runs with restricted privileges to limit the damage that can be done if it is compromised.</p><p>The vulnerability is caused by a race condition related to how signals are handled. This means that the <em>privsep</em> child process can be exploited because the timing of signal handling operations can be manipulated, leading to unintended behavior that allows code execution.</p><p><strong>Impact</strong> OpenSSH versions 8.7p1 and 8.8p1 shipped with Red Hat Enterprise Linux 9.</p><p>Machines patched for CVE-2024–6387 will also be patched for CVE-2024–6409.</p><h3>Suggested actions against the vulnerability</h3><p>To protect against this vulnerability the main suggestion is to upgrade the package version using a command like or similar to apt upgrade opensshh-sftp-server, but if you cannot do this and you need a quick workaround then an option would be to set the LoginGraceTime SSH configuration parameter to 0 as recommended by <a href="https://ubuntu.com/blog/ubuntu-regresshion-security-fix">Ubuntu</a>.</p><p>Let’s look into both recommendations and understand them a bit more and let’s start with the workaround:</p><p>OpenSSH allows remote connections to the server machines. LoginGraceTime SSH server configuration parameter specifies <em>the time allowed for successful authentication to the server</em>.</p><p>This means that setting a longer Grace time period allows for more open unauthenticated connections to be made. Setting a shorter Grace time period can protect against a brute force attack in certain cases.</p><p>In the context of the identified vulnerability, this is important because the vulnerable code is called only when the LoginGraceTime timer triggers. So the reasoning is that by setting it to 0, which means no timeout, you prevent the timer from firing, the code will not be called and thus the vulnerability is eliminated.</p><p>But there is a caveat here.</p><p>While you eliminate the risk of calling the vulnerable code, and you are protected against brute force attacks, by setting this to 0 you are making sshd vulnerable to denial of service attacks. So it&#39;s good to consider your options carefully and the tradeoff when you are configuring these settings.</p><p><strong>Denial of Service through MaxStartups Exhaustion Explained</strong></p><p>MaxStartups is another sshd configuration that limits the number of concurrent unauthenticated connections.</p><p>If LoginGraceTime is set to 0, attackers can open numerous connections without being timed out. Since these connections won&#39;t be closed due to timeout, they will remain open indefinitely.</p><p>This can exhaust the allowed number of connections specified by MaxStartups, preventing legitimate users from accessing the SSH service.</p><p>Essentially, the server becomes overwhelmed with these open connections, leading to a denial of service for legitimate users (hence the denial of service).</p><p>This is why the main recommendation is to upgrade to a patched version of sshd where the underlying vulnerability has been addressed. This ensures that LoginGraceTime can be set to a reasonable value, and the server can handle connection attempts appropriately without being vulnerable to a DoS attack via MaxStartups exhaustion.</p><h3>Upgrade to a patched version of sshd</h3><p>Now onto the main fix and what this means for your virtual machine scale sets (VMSS) in the AKS context. When running AKS, modifying the VMSS yourself is generally not recommended due to the following reasons:</p><ul><li><em>Managed Service:</em> AKS is a <strong>managed</strong> Kubernetes service, meaning Microsoft handles most of the underlying infrastructure management for you. Directly modifying VMSS configurations can interfere with the automated management and updates provided by AKS.</li><li><em>Configuration Consistency:</em> AKS maintains certain configurations to ensure the cluster operates correctly. Manual modifications to the VMSS could lead to a configuration drift, where the manually set configurations diverge from the managed state AKS expects and maintains.</li><li><em>Stability and Reliability:</em> Direct modifications can lead to instability or unexpected behavior within your cluster. This includes potential issues during upgrades, scaling operations, or applying patches.</li></ul><p>Because of these reasons handling the fix for the vulnerability means waiting for the Azure release team to provide us with a patched image.</p><p>When you upgrade Kubernetes it also upgrades the node images so a good place to start is to identify the version of Kubernetes your AKS clusters are running. You can do this through the Azure portal, CLI, or API.</p><p><strong>Azure Portal:</strong></p><p>Navigate to your AKS cluster resource and check the version information in the <em>Overview</em> section.</p><p><strong>Azure CLI:</strong></p><pre>az aks show --resource-group &lt;ResourceGroupName&gt; --name &lt;AKSClusterName&gt; --query kubernetesVersion</pre><p><em>Note: Replace </em><em>ResourceGroupName and </em><em>AKSClusterName with your actual resource group and AKS cluster names.</em></p><p>Then by making use of kubectl command line, you can retrieve the exact version of the node images you are using:</p><p>By running these commands you will know your Kubernetes version and also the OS Image version your nodes are running on. Now you can compare your node image version against the versions mentioned in the CVE details as vulnerable to know if you are running the nodes on an image that has a vulnerable version of sshd.</p><h3>Check and upgrade the AKS VMSS node image</h3><p>Azure Kubernetes Service regularly provides new node images, so it’s good to upgrade your node images frequently to take advantage of the latest AKS features. Linux node images are updated weekly, and Windows node images are updated monthly.</p><p>For Azure, and AKS more specifically, you should perform the following checks:</p><p><strong>Tip</strong>: It is also a good practice in general to check the release page for announcements on upcoming releases and the fixes they include and keep your node images up to date to protect against the latest vulnerabilities.</p><p>At the time of the writing of the current article, we’ll be looking out for the rollout of the image with version: <strong>202407.08.0</strong>.</p><p>Generally, when you upgrade the Kubernetes version the images will be upgraded as well, but when you have a security patch you might want to upgrade only the image and not the Kubernetes version.</p><p>Please consider carefully before upgrading a node image version because it’s not possible to downgrade it afterward!</p><p>In order to <strong>check for available node image upgrades</strong> for the nodes in your node pool simply run the following command:</p><pre>az aks nodepool get-upgrades --nodepool-name mynodepool --cluster-name myAKSCluster --resource-group myResourceGroup</pre><p>In the JSON output, check the latestNodeImageVersion parameter which indicates the version of the latest image available that the nodes can be upgraded to.</p><p>Then, you want to check the actual node image you are running on (can be done via Azure Portal or CLI). If you’re using CLI for this command as well then just run:</p><pre>az aks nodepool show --resource-group myResourceGroup --cluster-name myAKSCluster --name mynodepool --query nodeImageVersion</pre><p>Simply compare the two image versions. If there is a difference this means there is an upgrade available for your nodes. If not, you are already running on the latest and you should check the releases for the rollout of the image you are interested in upgrading to.</p><p>Having the image version available in your region, the next step will be <strong>performing the actual node image upgrade</strong>. There are several ways of handling this depending on your scenario which I will detail below.</p><h3>Upgrade all node images in all node pools</h3><p><strong>CLI Command:</strong> az aks upgrade --node-image-only<br><strong>Scope:</strong> This command applies the upgrade to all node pools in the specified AKS cluster.<br><strong>Use Case:</strong> Use this when you want to ensure that all nodes in your entire cluster are updated to the latest node image version.</p><p>Use the az aks upgrade command with the --node-image-only flag to upgrade the node images across all node pools in the AKS cluster. This command ensures that only the node image is upgraded without altering the Kubernetes version.</p><pre>az aks upgrade \<br>    --resource-group myResourceGroup \<br>    --name myAKSCluster \<br>    --node-image-only</pre><p>After initiating the upgrade, you can verify the status of the node images using the kubectl get nodes command with a specific JSONPath query to output the node names and their image versions.</p><pre>kubectl get nodes -o jsonpath=&#39;{range .items[*]}{.metadata.name}{&quot;\t&quot;}{.metadata.labels.kubernetes\.azure\.com\/node-image-version}{&quot;\n&quot;}{end}&#39;</pre><p>Once the upgrade is complete, you can retrieve the updated details of the node pools, including the current node image version, using the az aks show command.</p><pre>az aks show \<br>    --resource-group myResourceGroup \<br>    --name myAKSCluster</pre><h3>Upgrade a specific node pool</h3><p><strong>CLI Command:</strong> az aks nodepool upgrade --node-image-only<br><strong>Scope:</strong> This command targets a specific node pool within the AKS cluster, identified by the -name parameter.<br><strong>Use Case:</strong> Use this when you need to upgrade the node image for only one particular node pool, perhaps for testing or staggered rollout purposes.</p><p>If you want to upgrade the node image of a specific node pool without affecting the entire cluster, use the az aks nodepool upgrade command with the --node-image-only flag.</p><pre>az aks nodepool upgrade \<br>    --resource-group myResourceGroup \<br>    --cluster-name myAKSCluster \<br>    --name mynodepool \<br>    --node-image-only</pre><p>Similar to the cluster-wide upgrade, check the status of the node images with the kubectl get nodes command.</p><pre>kubectl get nodes -o jsonpath=&#39;{range .items[*]}{.metadata.name}{&quot;\t&quot;}{.metadata.labels.kubernetes\.azure\.com\/node-image-version}{&quot;\n&quot;}{end}&#39;</pre><p>Use the az aks nodepool show command to get the details of the updated node pool.</p><pre>az aks nodepool show \<br>    --resource-group myResourceGroup \<br>    --cluster-name myAKSCluster \<br>    --name mynodepool</pre><h3>Use Node Surge to Speed Up Upgrades</h3><p><strong>CLI Command</strong>: az aks nodepool update --max-surge<br><strong>Scope</strong>: This command also targets a specific node pool but includes the -max-surge parameter to control the number of extra nodes that can be created to expedite the upgrade.<br><strong>Use Case</strong>: Use this when you want to perform a faster upgrade of a node pool by temporarily increasing the number of nodes during the upgrade process, thereby reducing downtime or upgrade duration.</p><p>To speed up the node image upgrade process, you can use the az aks node pool update command with the -max-surge flag, which specifies the number of extra nodes used during the upgrade process. This allows more nodes to be upgraded simultaneously.</p><pre>az aks nodepool update \<br>    --resource-group myResourceGroup \<br>    --cluster-name myAKSCluster \<br>    --name mynodepool \<br>    --max-surge 33% \<br>    --no-wait</pre><p>Check the node image status as previously described.</p><pre>kubectl get nodes -o jsonpath=&#39;{range .items[*]}{.metadata.name}{&quot;\t&quot;}{.metadata.labels.kubernetes\.azure\.com\/node-image-version}{&quot;\n&quot;}{end}&#39;</pre><p>Retrieve the updated node pool details using the az aks node pool show command.</p><pre>az aks nodepool show \<br>    --resource-group myResourceGroup \<br>    --cluster-name myAKSCluster \<br>    --name mynodepool</pre><p>The choice between the three will depend on what your strategy will be and what you want to focus on:</p><ul><li>If you have a new security patch or critical update and want every node in your cluster to be updated as quickly as possible without specifying individual node pools, upgrade the entire cluster.</li><li>If you are running different workloads on separate node pools and want to update the node image for only one specific pool to test compatibility or performance just target upgrade.</li><li>If you need a faster upgrade for a specific node pool and can afford to temporarily add more nodes to handle the upgrade process, use node surge.</li></ul><p><em>I hope this article will give you an idea of this particular security vulnerability and how you can mitigate it and how you can approach security patches in the future in the context of AKS VMSS. Thank you for reading!</em></p><p><em>Originally published at </em><a href="https://coffeewithana.cloud/posts/cve-2024-6387-security-aks/"><em>https://coffeewithana.cloud</em></a><em> on July 17, 2024.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b4cb0f4a779" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Book Review: The Unicorn Project]]></title>
            <link>https://medium.com/@ana.cozma/book-review-the-unicorn-project-e7a132790b4d?source=rss-c58698151430------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7a132790b4d</guid>
            <category><![CDATA[book-review]]></category>
            <category><![CDATA[book-recommendations]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Ana Cozma]]></dc:creator>
            <pubDate>Mon, 01 Jul 2024 20:18:12 GMT</pubDate>
            <atom:updated>2024-07-19T08:31:32.998Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/660/0*bf_A8qP8J9DAxzjf.png" /></figure><p>Since Gene Kim just came out with a new book (topic for another coffee read) I realized I never summarized his last one. So for this coffee read I chose to focus on <em>The Unicorn Project</em>.</p><p>The book came out in 2019 and it is a fictionalized story about a DevOps transformation taking place at the same time as <em>The Phoenix Project</em> with the following premise:</p><p><em>In The Unicorn Project, we follow Maxine, a senior lead developer and architect, as she is exiled to the Phoenix Project, to the horror of her friends and colleagues, as punishment for contributing to a payroll outage. She tries to survive in what feels like a heartless and uncaring bureaucracy and to work within a system where no one can get anything done without endless committees, paperwork, and approvals. One day, she is approached by a ragtag bunch of misfits who say they want to overthrow the existing order, to liberate developers, to bring joy back to technology work, and to enable the business to win in a time of digital disruption. To her surprise, she finds herself drawn ever further into this movement, eventually becoming one of the leaders of the Rebellion, which puts her in the crosshairs of some familiar and very dangerous enemies. — Gene Kim</em></p><p>I have to start by saying I loved <em>The Phoenix Project</em>. So an updated version matching the new reality in the industry was something I was really excited about to read. With that book I related a lot, nodding and laughing along the way, recognizing the similarities between the fictitious company with its struggles and my own working environment.</p><p>What resonated with me greatly from <em>The Unicorn Project</em> book were the five ideals:</p><ul><li>Locality and Simplicity</li><li>Focus, Flow and Joy</li><li>Improvement of Daily Work</li><li>Psychological Safety</li><li>Customer Focus</li></ul><p>I found that they complemented really well the three ways from <em>The Phoenix Project</em> which focused on flow, feedback, and continuous learning. This connection created a cohesive and comprehensive approach to improving work processes and achieving organizational goals.</p><p>The five ideals where expressed quite well by Maxine, the protagonist, when faced with various challenges:</p><blockquote>Punishing failure and “shooting the messenger” only cause people to hide their mistakes, and eventually, all desire to innovate is completely extinguished.</blockquote><p>with a touch of humor:</p><blockquote>You know you’re in real trouble when even the intern feels sorry for you, Maxine thinks. She leaves the building, carrying it requires an understanding of the business, incredible problem-solving skills, patience, and the political sophistication to work with sometimes Byzantine and occasionally incomprehensible processes that every large organization seems to have.</blockquote><blockquote>Technical debt is what you feel the next time you want to make a change.</blockquote><p>And I was excited to find a book that highlighted the importance of having a good CI/CD process in the company and an underlying well maintained infrastructure. This definitely, for me, mattered to be spelled out after having to fight with the mentality that infrastructure and CI/CD is less important than building new and cool features for the product in my role.</p><blockquote><em>Without constant feedback from a centralized build, integration, and test system, they really have no idea what will happen when all their work is merged with everyone else’s.</em></blockquote><blockquote><em>Everyone around here thinks features are important, because they can see them in their app, on the web page, or in the API. But no one seems to realize how important the build process is. Developers cannot be productive without a great build, integration, and test process.</em></blockquote><blockquote><em>Without continuous builds, we are like a car manufacturer without an assembly line, where anyone can do whatever they want, independent of the plant goals(&amp;mldr;).</em></blockquote><p>And <em>The Unicorn Project</em> even went a step further in asking the questions that I feel are sometimes overlooked or simply dismissed during planning or design sessions, but are nonetheless critical to building reliable software.</p><blockquote><em>How many transactions per second are we expecting for product displays and orders? And how many transactions per second are the current builds capable of handling right now? That will tell us how many servers we need for the horizontally scalable portions, as well as how far we’re off for the vertically scaled components, like the database.</em></blockquote><p>So Maxine ( <em>Gene Kim</em>), thank you from the bottom of my DevOps heart!</p><p>Maxine, and the book, did not shy away from highlighting not only the technical challenges of a disfunctional process, but also the cultural ones as well. This was something that sometimes I feel is not talked about enough in the industry.</p><blockquote><em>Although long hours are sometimes glorified in popular culture, Maxine views them as a symptom of something going very wrong.</em></blockquote><p>Seriously, yes.</p><blockquote><em>Is being assigned to the Phoenix Project making her a bad person?</em></blockquote><p>I mean we all know that <em>one</em> project.</p><blockquote><em>In his inexperience, he had merely closed her ticket by following the rules set for him. He was only trying to do his job the best he’d been shown how.</em></blockquote><blockquote><em>The leader must constantly model and coach and positively reinforce these desired behaviors every day. Psychological safety slips away so easily, like when the leader micromanages, can’t say ‘I don’t know,’ or acts like a know-it-all, pompous jackass. And it’s not just leaders, it’s also how one’s peers behave.</em></blockquote><p>Yes, yes and yes.</p><p>Another great point of the book was the importance of doing employee training close to the customers. By training employees in environments where they directly interact with customers, they gain a deeper understanding of customer needs and challenges. This proximity allows them to tailor their responses more effectively, leading to better customer service, increased satisfaction, and more relevant and impactful solutions driving the business forward. But whether you are working in a plant or on software, this mentality is definitely helpful since the last thing you want is to work on software that no one will use or that is hard to use.</p><p>The overall message of <em>The Unicorn Project</em> book is inspiring, particularly its emphasis on trusting developers and treating them as equals. This approach fosters a collaborative and respectful work environment where developers feel valued and empowered. In such a setup, their potential for creativity and innovation is unlocked, driving advancements for the business. The book highlights the importance of trust, respect, and empowerment in maximizing the contributions of every team member.</p><h3>Areas for improvements</h3><p>All of this said, I did find Maxine to be perfect. And not in a good way. While in the <em>Phoenix Project</em> we had multiple protagonists that ended up in situations that challenged their skills whether technical or not, in <em>The Unicorn Project</em> we have mainly Maxine that knows how to do everything — every — single — thing — while having a family at home. She’s already a very good developer and the book shows us this by her re-writing code in several instances reducing it by hundreds of lines with other developers watching in amazement. And if she’s not doing that, she’s ready with quoting principles and books to show her extensive knowledge. She also works long hours, meeting her team at the bar as well, but it seems there are no consequences for her family life, which realistically, will not be the case.</p><p>And then there is her assistant Kurt who already had a vision for Maxine and where they should be heading, putting his job on the line without any reservations. The external coach Eric does not guide the reader to a conclusion of the five ideals, but rather he just tells them while popping in and out of his bar. I think the book should’ve let the reader or the protagonist reach his own conclusions, rather then telling him what it is.</p><p>So from this point of view the characters didn’t grow in my view as they didn’t have any real challenges. I think to be a great professional or person, really, you don’t need to be perfect. You should just be open to failure and willingness to learn, openness to the new and to change. Adapt. Failure, in my opinion, is a greater teacher than instant success. It makes you motivated, resilient and ever evolving. So no, Maxine did not need to be perfect to show how good she is.</p><p>Lastly, then there were some aspects of it that were glossed over. For example, creating autonomous teams is no easy feat, but somehow the characters just managed to ‘do it’. There were no challenges there, everything just fit. And in my own experience this is not the case. Breaking down teams and making them efficient, while maintaining alignment with the business goals and a steady flow of seamless releases is always filled with hurdles and challenges, especially at the scale that Parts Unlimited, the fictious company, operates.</p><p>Definitely if you read the book, that came out in 2019, now, in 2024, it will feel a bit outdated already and perhaps even in 2019 it was already a bit. Overall <em>The Unicorn Project</em>, in my opinion, did not match its predecessor, even though it had a lot of potential from the premise and the new realities in the industry. That said, the five principles are definitely still relevant and the book is very good at showcasing why these are needed so this still makes for a good read.</p><p>I have a lot of respect for the author, Gene Kim, and look forward to reading his next book!</p><p><em>Hope you enjoyed this review and if you read the book let me know what your thoughts on it are!</em></p><p>Enjoy your coffee! ☕️</p><p><em>Originally published at </em><a href="https://coffeewithana.cloud/reads/book-review-the-unicorn-project/"><em>https://coffeewithana.cloud</em></a><em> on July 1, 2024.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7a132790b4d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Book Review: Software Architecture Patterns (Report)]]></title>
            <link>https://medium.com/@ana.cozma/book-review-software-architecture-patterns-report-ada91e0e128b?source=rss-c58698151430------2</link>
            <guid isPermaLink="false">https://medium.com/p/ada91e0e128b</guid>
            <dc:creator><![CDATA[Ana Cozma]]></dc:creator>
            <pubDate>Wed, 04 Oct 2023 12:20:38 GMT</pubDate>
            <atom:updated>2023-10-05T07:27:50.447Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/251/0*xnduxwaaR9beQzbw.png" /></figure><p>For this <em>coffee read</em>, I will be reviewing the book <a href="https://www.oreilly.com/library/view/software-architecture-patterns/9781491971437/">Software Architecture Patterns (Report) by Mark Richards</a>.</p><p>I want to start with a disclaimer on this one. I have not worked as a software architect. So this book review will be from the perspective of someone that has worked as a DevOps engineer (more of a Cloud Engineer if we have to label it), and that has been involved in the design of systems and the architecture of systems. My personal belief is you need to have a good high-level view of the system you are working on, regardless of the project or your skillset (or job title), in order to be able to design or test solutions that make it scalable, reliable, and maintainable.</p><p>My hopes, from reading this book, were to get a better understanding of the different architecture patterns that are out there, how they can be used to design systems, what are some things to look out for when choosing one or the other or a combination of them and what would be some good questions to ask yourself when opting between them.</p><h3>Software Architecture Patterns (Report)</h3><p>The book, in its own description, emphasizes the importance of having a clear and well-defined architecture in software development. Without it, developers tend to default to traditional layered patterns, which can result in disorganized code known as the “big ball of mud” anti-pattern. Applications lacking a formal architecture are typically tightly coupled, difficult to change, and lack clarity in terms of their characteristics.</p><p>Having a defined architecture pattern helps establish the fundamental characteristics and behavior of an application. Different architecture patterns are suitable for different needs, such as scalability or agility. Understanding the strengths and weaknesses of each pattern is essential to choosing the one that aligns with specific business requirements.</p><p>The goal of the book, as mentioned by the author, is to provide architects with the information needed to make and justify these decisions effectively (hence my disclaimer).</p><h3>Thoughts on the book</h3><p>The book is broken down into the following chapters:</p><ul><li><em>Layered Architecture</em></li><li><em>Event-Driven Architecture</em></li><li><em>Microkernel Architecture</em></li><li><em>Microservices Architecture</em></li><li><em>Space-Based Architecture</em></li></ul><p>Each type is nicely broken down into sections that explain the pattern description, key concepts, pattern examples, consideration, and pattern analysis.</p><p>The book also provides a summary of the different patterns in terms of their characteristics, strengths, weaknesses, and when to use them in real-life scenarios.</p><p>Each chapter starts with a summary of what the architectural pattern is and what are the key concepts behind it. It then goes into detail about the pattern (including design samples) and how it can be used by providing examples of real-life scenarios. For example, for the Event-Driven Architecture pattern, the author explains the mediator and broker topologies and how they can be used to implement the pattern before delving into the details of the pattern itself.</p><p>Next, it highlights the considerations that need to be taken into account when choosing that particular architecture. For example, in the Event-Driven Architecture pattern, the author explains that one of the challenges of this architecture pattern is the lack of atomic transactions for a single business process. And this is the reason why when using this pattern you need to continuously think about which events can and cannot run independently and plan the granularity of your event processors accordingly.</p><p>Finally, it provides an analysis of the pattern in terms of <strong>Overall agility</strong>, <strong>Ease of deployment</strong>, <strong>Testability</strong>, <strong>Performance</strong>, <strong>Scalability</strong>, and <strong>Ease of development</strong>. The author gives a rating from Low to High on each of these attributes when considering the architecture pattern and an analysis as to why it scored that way. This really made me understand why one pattern would be better than another in a specific scenario. Or at least what issues you can run into when choosing it. For example, Microservices pattern is rated as <strong>High</strong> in terms of <strong>Overall agility</strong> and <strong>Ease of deployment</strong> but <strong>Low</strong> in terms of <strong>Performance</strong>. This is because of the distributed nature of the pattern, even though you can most definitely create applications that are performant using this pattern.</p><p>It was easy to understand the concepts and follow the examples, and the analysis of the patterns was very useful in understanding the strengths and weaknesses of each pattern.</p><p>This analysis also guided me in understanding the trade-offs associated with choosing one pattern over another. It provided valuable insights into the kinds of questions that should be considered when making such a decision, whether individually or within a team context. Moreover, it encouraged a shift in my perspective from seeking the ‘perfect’ pattern to identifying the pattern that aligns best with the specific requirements of the system.</p><p>As a result, this change in mindset aided me in asking pertinent questions when designing a system, with a strong focus on the system’s characteristics and the demands of the business, ultimately contributing to more informed and effective decision-making.</p><h3>Summary</h3><p>This book was a very good read as it achieved what it set out to do.</p><p>I would recommend it as a very good starting point for anyone interested in learning more about different software architecture patterns. And you have the option of diving deeper into the patterns that are of interest to them in other books from this authos or others.</p><p>If you’ve read the book, let me know what you thought about it in the comments below. If you have any recommendations for other books on the topic of software architecture, I would love to hear them.</p><p><strong>Enjoy your coffee!</strong> ☕️</p><p><em>Originally published at </em><a href="https://ana-cozma.github.io/blog/coffee/book-review-sw-architecture-patterns-report/"><em>https://ana-cozma.github.io</em></a><em> on October 4, 2023.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ada91e0e128b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ensuring Seamless Operations: Troubleshooting and Resolving Dapr Certificate Expiry]]></title>
            <link>https://medium.com/@ana.cozma/ensuring-seamless-operations-troubleshooting-and-resolving-dapr-certificate-expiry-b460b2ac685f?source=rss-c58698151430------2</link>
            <guid isPermaLink="false">https://medium.com/p/b460b2ac685f</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[azure-devops]]></category>
            <category><![CDATA[dapr]]></category>
            <dc:creator><![CDATA[Ana Cozma]]></dc:creator>
            <pubDate>Tue, 18 Jul 2023 15:28:20 GMT</pubDate>
            <atom:updated>2023-07-18T15:33:34.245Z</atom:updated>
            <content:encoded><![CDATA[<p>A CNCF project, the <a href="https://dapr.io/">Distributed Application Runtime (Dapr)</a> provides APIs that simplify microservice connectivity. Whether your communication pattern is service to service invocation or pub/sub messaging, Dapr helps you write resilient and secured microservices. Essentially, it provides a new way to build microservices by using the reusable blocks implemented as sidecars.</p><p>While Dapr is great as it is language agnostic and it solves some challenges that come with microservices and distributed systems, such as message broker integration, encryption etc, troubleshooting Dapr issues can be quite challenging. Dapr logs, especially the error messages, can be quite generic and sometimes do not provide enough information for you to understand what is going on.</p><p>In this blog post, I want to detail a problem I had with Dapr certificate expiration, how I troubleshoot the root cause, the symptoms the application was manifesting and how I managed to solve it.</p><p>I want also to highlight how important it is to have proper monitoring in place so I will be touching upon that as well by showing you some lessons learned and what I ended setting up to save me from repeating the same mistakes in the future.</p><h3>Symptoms</h3><p>Application deployment was failing because it could not inject the dapr sidecar. It kept restarting until reaching the 5min defaut timeout and rolledback. Checking the events on the pod I noticed the GET /healthz endpoints for liveness and readiness probes were throwing connect: connection refused.</p><p>There were no errors in app logs or in the Dapr sidecar logs. The only thing I noticed was that the dapr sidecar was in CrashLoopBackOff state.</p><h3>Troubleshooting</h3><h3>Step 1: Dapr Operator logs</h3><p>Since no longs were available on pod or Dapr sidecar, I started by checking the logs of the next best thing which was the <strong>Dapr Operator</strong> and I noticed the following error:</p><pre>{&quot;instance&quot;:&quot;dapr-operator-0000000000-abcd&quot;,&quot;level&quot;:&quot;info&quot;,&quot;msg&quot;:&quot;starting webhooks&quot;,&quot;scope&quot;:&quot;dapr.operator&quot;,&quot;time&quot;:&quot;2023-05-25T12:51:13.267369255Z&quot;,&quot;type&quot;:&quot;log&quot;,&quot;ver&quot;:&quot;1.10.4&quot;}<br>I0525 12:51:13.269285       1 leaderelection.go:248] attempting to acquire leader lease dapr-system/webhooks.dapr.io...<br>{&quot;instance&quot;:&quot;dapr-operator-0000000000-abcd&quot;,&quot;level&quot;:&quot;info&quot;,&quot;msg&quot;:&quot;Conversion webhook for \&quot;subscriptions.dapr.io\&quot; is up to date&quot;,&quot;scope&quot;:&quot;dapr.operator&quot;,&quot;time&quot;:&quot;2023-05-25T12:51:13.277615379Z&quot;,&quot;type&quot;:&quot;log&quot;,&quot;ver&quot;:&quot;1.10.4&quot;}<br>W0601 02:52:46.530879       1 reflector.go:347] pkg/mod/k8s.io/client-go@v0.26.1/tools/cache/reflector.go:169: watch of *v1.Secret ended with: an error on the server (&quot;unable to decode an event from the watch stream: http2: client connection lost&quot;) has prevented the request from succeeding<br>W0601 02:52:46.531001       1 reflector.go:347] pkg/mod/k8s.io/client-go@v0.26.1/tools/cache/reflector.go:169: watch of *v1alpha1.Configuration ended with: an error on the server (&quot;unable to decode an event from the watch stream: http2: client connection lost&quot;) has prevented the request from succeeding<br>W0601 02:52:46.531061       1 reflector.go:347] pkg/mod/k8s.io/client-go@v0.26.1/tools/cache/reflector.go:169: watch of *v1.Service ended with: an error on the server (&quot;unable to decode an event from the watch stream: http2: client connection lost&quot;) has prevented the request from succeeding<br>E0601 02:52:46.531050       1 leaderelection.go:330] error retrieving resource lock dapr-system/operator.dapr.io: Get &quot;https://X.X.X.X:443/apis/coordination.k8s.io/v1/namespaces/dapr-system/leases/operator.dapr.io&quot;: http2: client connection lost<br>W0601 02:52:46.531095       1 reflector.go:347] pkg/mod/k8s.io/client-go@v0.26.1/tools/cache/reflector.go:169: watch of *v1alpha1.Resiliency ended with: an error on the server (&quot;unable to decode an event from the watch stream: http2: client connection lost&quot;) has prevented the request from succeeding<br>W0601 02:52:46.530891       1 reflector.go:347] pkg/mod/k8s.io/client-go@v0.26.1/tools/cache/reflector.go:169: watch of *v1alpha1.Component ended with: an error on the server (&quot;unable to decode an event from the watch stream: http2: client connection lost&quot;) has prevented the request from succeeding<br>E0601 02:52:46.531191       1 leaderelection.go:330] error retrieving resource lock dapr-system/webhooks.dapr.io: Get &quot;https://X.X.X.X:443/apis/coordination.k8s.io/v1/namespaces/dapr-system/leases/webhooks.dapr.io&quot;: http2: client connection lostThe Dapr operator works by establishing an admission webhook, which enables Kubernetes (K8s) to interact with it when it intends to deploy a new pod. After a successful response, the daprd container is added to the pod. For more in detail information on how the operator works, check the Dapr Operator control plane service overview documentation.</pre><h3>Step 2: Investigate the http2: client connection lost error</h3><p>The http2: client connection lost error indicated to me that K8s could not successfully invoke the admission webhook, so I started to check one by one:</p><p><strong>Network connectivity</strong>: The error message mentioned a potential issue with the client connection being lost. So I verified that the machine running the Dapr process could establish a stable connection to the Kubernetes API server. Checked for any network connectivity issues or firewalls that might be interfering with the communication. Everything was fine.</p><p><strong>API server issues</strong>: I also checked for any issues with the Kubernetes API server itself, such as high load, resource constraints, or misconfiguration. No issues found.</p><p><strong>Namespace or resource deletion</strong>: I checked that no resources had been deleted in the the dapr-system namespace or the webhooks.dapr.io resource. Everything was still there.</p><p>So as next step, I started looking into the <strong>AKS cluster logs</strong> and noticed that all the services that were also using Dapr had the following error authentication handshake failed. The full log is below:</p><pre>{&quot;app_id&quot;:&quot;app1&quot;,&quot;instance&quot;:&quot;app1-123456-abc7&quot;,&quot;level&quot;:&quot;info&quot;,&quot;msg&quot;:&quot;sending workload csr request to sentry&quot;,&quot;scope&quot;:&quot;dapr.runtime.grpc.internal&quot;,&quot;time&quot;:&quot;2023-06-19T13:19:53.535345802Z&quot;,&quot;type&quot;:&quot;log&quot;,&quot;ver&quot;:&quot;1.10.4&quot;}<br>2023-06-19 15:19:53.535 <br>{&quot;app_id&quot;:&quot;app1&quot;,&quot;instance&quot;:&quot;app1-123456-abc7&quot;,&quot;level&quot;:&quot;info&quot;,&quot;msg&quot;:&quot;renewing certificate: requesting new cert and restarting gRPC server&quot;,&quot;scope&quot;:&quot;dapr.runtime.grpc.internal&quot;,&quot;time&quot;:&quot;2023-06-19T13:19:53.535329702Z&quot;,&quot;type&quot;:&quot;log&quot;,&quot;ver&quot;:&quot;1.10.4&quot;}<br>2023-06-19 15:19:53.535 <br>{&quot;app_id&quot;:&quot;app1&quot;,&quot;instance&quot;:&quot;app1-123456-abc7&quot;,&quot;level&quot;:&quot;error&quot;,&quot;msg&quot;:&quot;error starting server: error from authenticator CreateSignedWorkloadCert: error from sentry SignCertificate: rpc error: code = Unavailable desc = connection error: desc = \&quot;transport: authentication handshake failed: tls: failed to verify certificate: x509: certificate has expired or is not yet valid: current time 2023-06-19T13:19:51Z is after 2023-06-16T12:31:17Z\&quot;&quot;,&quot;scope&quot;:&quot;dapr.runtime.grpc.internal&quot;,&quot;time&quot;:&quot;2023-06-19T13:19:53.535259601Z&quot;,&quot;type&quot;:&quot;log&quot;,&quot;ver&quot;:&quot;1.10.4&quot;}</pre><p>The errors above were a confirmation that it could not establish a connection because it could not authenticate due to an handshake failure.</p><p>To dig deeper, I researched how Dapr handles mTLS which pointed me to the Dapr Sentry service.</p><blockquote><em>The Dapr Sentry service manages mTLS between services and acts as a certificate authority. It generates mTLS certificates and distributes them to any running sidecars. This allows sidecars to communicate with encrypted, mTLS traffic.</em></blockquote><p>So I went to check the <em>Dapr Sentry</em> logs and I finally found the issue: <strong>Dapr root certificate expired</strong>.</p><pre>2023-06-19 14:49:06.566 { &quot;instance&quot;:&quot;dapr-sentry-123456-abc7&quot;,&quot;level&quot;:&quot;warning&quot;,&quot;msg&quot;:&quot;Dapr root certificate expiration warning: certificate has expired.&quot;,&quot;scope&quot;:&quot;dapr.sentry&quot;,&quot;time&quot;:&quot;2023-06-19T12:49:06.566339341Z&quot;,&quot;type&quot;:&quot;log&quot;,&quot;ver&quot;:&quot;1.10.4&quot; }</pre><p>In order to view the logs of the Dapr Sentry service you can run the following command:</p><pre>kubectl logs --selector=app=dapr-sentry --namespace &lt;NAMESPACE&gt;</pre><h3>Generating a new root certificate</h3><p>By default, the certificate expires after 365 days. You can change the expiration time by setting the --cert-chain-expiration flag when you start the Dapr Sentry service. The value is in days.</p><p>With Dapr, you can encrypt communication between applications using self-signed one valid for 1 year so it was time to renew the certificate.</p><p>To renew the certificate, I followed the recommended steps to root and issuer certificate upgrade using CLI. You can find the steps <a href="https://docs.dapr.io/operations/security/mtls/#root-and-issuer-certificate-upgrade-using-cli-recommended">here</a>.</p><pre>dapr mtls renew-certificate -k --valid-until &lt;days&gt; --restart</pre><pre>⌛  Starting certificate rotation<br>ℹ️  generating fresh certificates<br>ℹ️  Updating certifcates in your Kubernetes cluster<br>ℹ️  Dapr control plane version 1.10.4 detected in namespace dapr-system<br>✅  Certificate rotation is successful! Your new certicate is valid through Wed, 18 Jun 2025 13:37:30 UTC<br>ℹ️  Restarting deploy/dapr-sentry..<br>ℹ️  Restarting deploy/dapr-operator..<br>ℹ️  Restarting statefulsets/dapr-placement-server..<br>✅  All control plane services have restarted successfully!</pre><ol><li>Restarted one of the applications in kubernetes to see if the changes worked successfully. And it did!</li><li>Redeployed all applications that were using Dapr via our normal Github Actions pipelines.</li></ol><p>There was no downtime and the process was quite smooth. Dapr does not renew certificates automatically so depending on your setup you will need to renew them manually or create an intermediary service that does it for you.</p><h3>Next steps</h3><h3>Lesson learned no 1: Have an overview of your Dapr services</h3><p>I had no overview of the Dapr system which caused me a lot of time in trying to get to the root cause. So first thing I did was to create a <strong>nice dashboard</strong> where we can have an overview of our Dapr services and their certificates. I started from the official one from <a href="https://github.com/dapr/dapr/tree/master/grafana">Grafana</a> for this. But the dashboard is a bit outdated so I had some issues with the queries, so I did some changes and you can find the JSON of the dashboard below if it helps anyone.</p><p>For the <a href="https://ana-cozma.github.io/blog/posts/dapr-certificate-renewal/">full Grafana Dashboard JSON</a>. Go to Next steps &gt; Lesson learned no 1: Have an overview of your Dapr services and click on Expand report.</p><p>I added some variables for the Prometheus datasource name and the cluster name. You can change the refresh rate of the dashboard and the time range.</p><p>And the output creates a dashboard that something like below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*qopqWd79nLqmMKGw" /></figure><p>Each section of the dashboard has a very nice info box that will tell you what the section shows and how to interpret the data.</p><p>Ideally I think a good practice is not to overload yourself by creating tons of dashboards that you will not look at, maintain or forget about.</p><p>In this case, it’s quite useful to have one because in the event of an incident or a problem, this will save you hours of troubleshooting and will give you a good overview of the system and what is failing. If you look at the outputs of the board itself you’ll see that it logs: CSR Failures, Server TLS certificate issuance failures, etc.</p><h3>Lesson Learned no 2: Make sure you are aware before expiration</h3><p>Beginning <strong>30 days</strong> prior to mTLS root certificate expiration the Dapr sentry service will emit hourly warning level logs indicating that the root certificate is about to expire. You can use these logs to set up alerts to notify you when the certificate is about to expire.</p><pre>&quot;Dapr root certificate expiration warning: certificate expires in 2 days and 15 hours</pre><p>First thing is <strong>configure a Loki data source</strong>.</p><p>I already had this done and setting it up might be the subject of another blog post. But in a nutshell, Loki is a log aggregation system that integrates with Grafana which allows you to ingest and query log data. So I just made sure I had a Loki data source configured correctly.</p><p>Next, I created a <strong>create a log query</strong>.</p><p>In the Explore view of Grafana, selecting the Loki data source, I wrote a log query that retrieves the logs I want to use for the alert. The query you build might differ but it should match the logs produced by the kubectl logs command for dapr-sentry.</p><p>For example:</p><pre>{cluster=&quot;$cluster&quot;, namespace=&quot;dapr-system&quot;} |= `Dapr root certificate expiration warning: certificate expires in`</pre><p>Adjust the query based on the specific log lines or patterns you want to target. I wanted to get all the logs that had the warning message about the certificate expiration starting from the 30days mark. But you can just edit the query to log you x days before the expiration.</p><p>A good rule of thumb is to <strong>test the log query</strong>.</p><p>After executing the query, you should see the warnings in the log entries.</p><p><strong>Tip:</strong></p><blockquote><em>If no logs are returned, check that the query is correct, that the data source is set up correctly, and that the logs are being ingested by Loki.</em></blockquote><p>Since all was good in my case, I proceeded to <strong>add this query from the Explore page to my previously created dashboard</strong> so I can see the logs in the dashboard itself as well. So I created a new panel with the logs and a nice description of what the logs mean for anyone reading it.</p><figure><img alt="Cert Warnings" src="https://cdn-images-1.medium.com/max/800/0*XsDsl2zWHm6mRsnO" /></figure><p>And lastly, I <strong>create an alert rule</strong>.</p><p>In the Alerting section in Grafana I went to “Create Rule” to define an alert rule. I configured the alert based on the previous query and I defined the conditions that trigger the alert based on the log query results. For example, you can set a condition like “Count() is above 0” to trigger the alert when there is at least one log entry matching the query. Or you can customize it based on your needs.</p><p>Here the implementation of the alert might differ based on what tooling you use, which channel you want to be alerted on (slack, email etc).</p><p>Hope this gave an insight into how you can troubleshoot and monitor Dapr in your environments.</p><p><em>Thank you for reading! And let me know if you have any questions or feedback.</em></p><p><em>Originally published at </em><a href="https://community.ops.io/the_cozma/ensuring-seamless-operations-troubleshooting-and-resolving-dapr-certificate-expiry-3mni"><em>https://community.ops.io</em></a><em> on July 18, 2023.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b460b2ac685f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Troubleshooting and Resolving a Pod Stuck in ‘CreateContainerConfigError’ in Kubernetes]]></title>
            <link>https://medium.com/@ana.cozma/troubleshooting-and-resolving-a-pod-stuck-in-createcontainerconfigerror-in-kubernetes-95e195430e20?source=rss-c58698151430------2</link>
            <guid isPermaLink="false">https://medium.com/p/95e195430e20</guid>
            <category><![CDATA[troubleshooting]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[azure-kubernetes-service]]></category>
            <dc:creator><![CDATA[Ana Cozma]]></dc:creator>
            <pubDate>Mon, 30 Jan 2023 21:38:27 GMT</pubDate>
            <atom:updated>2023-02-08T19:02:23.038Z</atom:updated>
            <content:encoded><![CDATA[<p>The other day I was making changes to my helm charts and, after deploying my application, I noticed that one of my pods was stuck in a CreateContainerConfigError state. This is a pretty tricky error because it doesn&#39;t give you any details on what the underlying issue could be.</p><h3>What is the CreateContainerConfigError?</h3><p>To understand this, let’s look at what happens at deployment time to give you an idea of the flow and what could go wrong at each step.</p><p>When you deploy a pod, the first step is to pull the image from the registry and then create the container. If the <strong>image is not found</strong>, then Kubernetes will return an <strong>ErrImagePull</strong> error. If the image is found, then it will proceed to create the container.</p><p>If the <strong>container creation fails</strong>, then it will return a <strong>CreateContainerError</strong> error. If the container creation succeeds, then Kubernetes will then start the container.</p><p>If the <strong>container start fails</strong>, then it will return a <strong>CreateContainerConfigError</strong> error.</p><p>In other words, the error happens when the container is transitioning from a Pending state to a Running state. It is at this point that the deployment configuration will be validated to make sure that the container can be started. If the configuration is invalid, then it will return a <strong>CreateContainerConfigError</strong> error.</p><h3>How to Troubleshoot the CreateContainerConfigError</h3><blockquote>Disclaimer: There can be many reasons why the container configuration is invalid and it will depende on your specific configuration. I will only be covering the one that I have encountered. If you have encountered a different cause, please leave a comment below.</blockquote><p>Because the error happens during the validation of the configuration, a good starting point is to double-check the following:</p><ul><li>is the ConfigMap missing? Is it properly configured?</li><li>is a Secret missing? Is it properly configured?</li><li>is the PersistentVolume missing? Is it properly configured?</li><li>is the Pod being created correctly? Are there any empty or invalid fields?</li></ul><p>Now that we understand what the error is, and what we should be looking at, let’s look at how to troubleshoot it and narrow down the problem.</p><h3>Check the Pod Status</h3><p>The first thing I did was get the pod that I had the error and that I wanted to drill into.</p><p>You can do this by running kubectl get pods -n &lt;namespace&gt;.</p><pre>~ kubectl get pods -n my-service NAME READY STATUS RESTARTS AGE my-service-00000000078c9fff-dssbk 0/2 CreateContainerConfigError 1 (10s ago) 28s my-service-00000000bcddf7d-xfsmk 2/2 Running 25 (42h ago) 16d</pre><h3>Check the Events</h3><p>Next, we are interested to see all the events on the pod.</p><p>You can do this by running kubectl describe pod &lt;pod-name&gt; -n &lt;namespace&gt; and look at the bottom at the <strong>Events</strong>. This will give you a lot of information about the pod, including the events that have happened to it similar to the following, which has been redacted to remove sensitive information.</p><p>The Events section shows a list of all the events that have occurred in the process of creating the pod.</p><p>And here we find the issue. The pod is actually missing a secret, the ClientId in my case, that it needs to start. And that is why the pod is in:</p><p>If you want to double-check that the secret is missing, you can run kubectl get secrets -n &lt;namespace&gt; and check if the secret is not there.</p><p>Or you can output it in a JSON format and check that the key is missing by running the following command:</p><pre>kubectl get secret my-service -n my-service -o json | jq &#39;.data | map_values(@base64d)&#39;</pre><h3>How to Resolve the CreateContainerConfigError</h3><p>In my case, because I store my infrastructure and configuration (including the kubernetes secrets) in Terraform, I just needed to add the secret to the Terraform configuration, apply it and because the deployment had already timed out, re-run the deployment. But it would’ve picked it up automatically if I had applied it a bit sooner.</p><p>Now that the pod has its necessary configuration and is valid if we run kubectl get pods -n &lt;namespace&gt; again, we can see that the pod is now in a Running state.</p><pre>kubectl get pods -n my-service NAME READY STATUS RESTARTS AGE my-service-00000000078c9fff-dssbk 2/2 Running 1 (10s ago) 28s my-service-00000000bcddf7d-xfsmk 2/2 Terminating 25 (42h ago) 16d</pre><p>And there you have it. You have successfully resolved the CreateContainerConfigError.</p><p>This was an easy one, let me know what you encountered in the comments below and how you fixed it.</p><p><em>Happy Coding and I hope this helps someone!</em></p><p><em>Originally published at </em><a href="https://ana-cozma.github.io/blog/posts/k8s-pod-createcontainerconfigerror/"><em>https://ana-cozma.github.io</em></a><em> on January 30, 2023.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=95e195430e20" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kube-bench and Popeye: A Power Duo for AKS Security Compliance]]></title>
            <link>https://medium.com/@ana.cozma/kube-bench-and-popeye-a-power-duo-for-aks-security-compliance-562f4ba88b66?source=rss-c58698151430------2</link>
            <guid isPermaLink="false">https://medium.com/p/562f4ba88b66</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[azure-kubernetes-service]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[opsec]]></category>
            <dc:creator><![CDATA[Ana Cozma]]></dc:creator>
            <pubDate>Mon, 23 Jan 2023 18:11:02 GMT</pubDate>
            <atom:updated>2023-02-02T07:53:10.638Z</atom:updated>
            <content:encoded><![CDATA[<p>In today’s world, security is a top priority for any organization or at least it should be. With the rise of cloud computing, the number of security threats has increased exponentially.</p><p>So how do we keep up? Where do we start?</p><p>Microsoft has created a set of security benchmarks to give users a starting point for setting up their security configurations. The Microsoft cloud security benchmark (MCSB) is the successor of Azure Security Benchmark (ASB), which was rebranded in October 2022 (Currently in public preview).</p><p>In this post, I would like to go over the Azure security baseline for Azure Kubernetes Service and give a shoutout to two tools that can aid you in the process of establishing your compliance with the baseline.</p><h3>Azure Security Baseline for AKS</h3><p>The Azure Security Baseline for <a href="https://learn.microsoft.com/en-us/security/benchmark/azure/baselines/aks-security-baseline">Azure Kubernetes Service</a> (AKS) is a set of recommendations for securing your AKS cluster.</p><p>It is an exhaustive list of various aspects of AKS security and it also provides the corresponding actions to be taken in each case. From the documentation’s overview:</p><blockquote>You can monitor this security baseline and its recommendations using Microsoft Defender for Cloud. Azure Policy definitions will be listed in the Regulatory Compliance section of the Microsoft Defender for Cloud dashboard.</blockquote><blockquote>When a section has relevant Azure Policy Definitions, they are listed in this baseline to help you measure compliance to the Azure Security Benchmark controls and recommendations. Some recommendations may require a paid Microsoft Defender plan to enable certain security scenarios.</blockquote><p>It is based on the CIS Kubernetes Benchmark and the Azure Security Benchmark v1.0.</p><blockquote>CIS Benchmarks are best practices for the secure configuration of a target system. Available for more than 100 CIS Benchmarks across 25+ vendor product families, CIS Benchmarks are developed through a unique consensus-based process comprised of cybersecurity professionals and subject matter experts around the world. CIS Benchmarks are the only consensus-based, best-practice security configuration guides both developed and accepted by government, business, industry, and academia.</blockquote><p>For more information on <strong>CIS Benchmark</strong> please check <a href="https://www.cisecurity.org/cis-benchmarks/cis-benchmarks-faq">CIS Benchmark FAQ</a>.</p><p>For more information on the <strong>CIS Benchmark for Kubernetes</strong> please check the K<a href="https://www.cisecurity.org/benchmark/kubernetes">ubernetes benchmark</a>.</p><p>In the CIS Benchmark for Kubernetes document, there are instructions for both Master nodes and Worker nodes. But when using AKS we don’t have access to the master nodes. In this case, we can make use of the <a href="https://www.cisecurity.org/insights/blog/new-release-cis-azure-kubernetes-service-aks-benchmark">CIS Benchmark document for AKS</a>.</p><p><strong>What could we use to help us check our AKS setup against this benchmark?</strong></p><p>We can start by looking at the Azure Portal and <strong>Microsoft Defender for Cloud</strong>, checking out CIS compliance with <strong>Kube-bench</strong> and any configuration mismatches with <strong>Popeye</strong>. I will go into more detail on the last two tools. But first, let’s see what Microsoft Defender for Cloud looks like and what can you get from it.</p><h3>Microsoft Defender for Cloud</h3><p>As suggested by Microsoft, we can start with Microsoft Defender for Cloud. If you go to Azure Portal and search for Microsoft Defender for Cloud, then filter by “Assessed Resources”, and select your cluster you will see a list of all the cluster details and <em>Recommendations</em> and the <em>Alerts</em> tab as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Qh6DuOaMJJszxitF.png" /></figure><p>Let’s take the first recommendation as an example: <em>Azure Kubernetes Service clusters should have Defender profile enabled</em></p><p>If you click on it and expand it will give you the following information:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oVrENIskciYdGpbt.png" /></figure><p>You can choose to Exempt it, meaning you have either fixed this issue or you don’t want to fix it or Enforce it, meaning you want to enforce this setting by adding it to an Azure Policy definition.</p><p>There is also a nice description of the issue and suggested remediation steps to take.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/0*W7tkLKqXekFg1dJB.png" /></figure><h3>Kube-bench</h3><p>The official repository can be found <a href="https://github.com/aquasecurity/kube-bench">here</a> with detailed installation instructions.</p><blockquote>kube-bench is a tool that checks whether Kubernetes is deployed securely by running the checks documented in the CIS Kubernetes Benchmark.</blockquote><p>There are multiple ways of running this tool that you can check <a href="https://github.com/aquasecurity/kube-bench/blob/main/docs/running.md">here</a>.</p><h3>Setting it up</h3><p>To test out this tool, I decided to just apply it to my local cluster so the first thing I did was start my <a href="https://minikube.sigs.k8s.io/docs/start/">minikube</a> instance and then I ran the following command:</p><pre>&gt; minikube start 😄 minikube v1.22.0 on Darwin 12.6.2 ✨ Using the hyperkit driver based on existing profile 👍 Starting control plane node minikube in cluster minikube 🏃 Updating the running hyperkit &quot;minikube&quot; VM ... 🎉 minikube 1.28.0 is available! Download it: https://github.com/kubernetes/minikube/releases/tag/v1.28.0 💡 To disable this notice, run: &#39;minikube config set WantUpdateNotification false&#39; 🐳 Preparing Kubernetes v1.21.2 on Docker 20.10.6 ... 🔎 Verifying Kubernetes components... ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5 🌟 Enabled addons: storage-provisioner, default-storageclass ❗ /usr/local/bin/kubectl is version 1.25.2, which may have incompatibilites with Kubernetes 1.21.2. ▪ Want kubectl v1.21.2? Try &#39;minikube kubectl -- get pods -A&#39; 🏄 Done! kubectl is now configured to use &quot;minikube&quot; cluster and &quot;default&quot; namespace by default # Download the job.yaml file &gt; curl https://raw.githubusercontent.com/aquasecurity/kube-bench/main/job.yaml &gt; job.yaml &gt; kubectl apply -f job.yaml job.batch/kube-bench created &gt; kubectl get pods -A  ✔  at minikube ⎈ NAMESPACE NAME READY STATUS RESTARTS AGE default kube-bench-t2fgh 0/1 ContainerCreating 0 5s &gt; kubectl get pods -A  ✔  at minikube ⎈ NAMESPACE NAME READY STATUS RESTARTS AGE default kube-bench-t2fgh 0/1 Completed 0 32s</pre><p>You can run Kube-bench inside a pod, but it will need access to the host’s PID namespace to check the running processes, as well as access to some directories on the host where config files and other files are stored.</p><p>The supplied job.yaml file can be applied to run the tests as a job. This was enough for me to run locally to get a feel of what the tool does and how it generates the report.</p><p>Next, after having run the tests, I wanted to get the report. The results of the tests can be found in the logs of the pod which you can get by running:</p><p>Kube-bench generates a report that looks like the following snippet.</p><p><em>For a full report head over to my blog where I posted it in full.</em></p><pre>[INFO] 1 Master Node Security Configuration <br>[INFO] 1.1 Master Node Configuration Files <br>[PASS] 1.1.1 Ensure that the API server pod specification file permissions are set to 644 or more restrictive (Automated) [PASS] 1.1.2 Ensure that the API server pod specification file ownership is set to root:root (Automated) <br>[PASS] 1.1.3 Ensure that the controller manager pod specification file permissions are set to 644 or more restrictive (Automated) [PASS] 1.1.4 Ensure that the controller manager pod specification file ownership is set to root:root (Automated) <br>[PASS] 1.1.5 Ensure that the scheduler pod specification file permissions are set to 644 or more restrictive (Automated) [PASS] 1.1.6 Ensure that the scheduler pod specification file ownership is set to root:root (Automated) </pre><p>This can also be run inside the AKS cluster by following the instructions <a href="https://github.com/aquasecurity/kube-bench/blob/main/docs/running.md#running-in-an-aks-cluster">here</a>. As a reminder: Kube-bench cannot be run on AKS master nodes. It can only be run on worker nodes, this is not a limitation of Kube-bench but of AKS as mentioned before.</p><h3>The report breakdown</h3><p>From the report above you can see that Kube-bench benchmarks 5 sections of your configurations which are the following:</p><ul><li>Control Plane Components</li><li>Etcd</li><li>Control Plane Configurations</li><li>Worker Nodes</li><li>Policies</li></ul><p>Each section starts by describing which section it targets, the lines having the INFO tag. For example:</p><pre>[INFO] 5 Kubernetes Policies [INFO] 5.1 RBAC and Service Accounts</pre><p>Then it lists the checks that are performed for that section. Each check gets a PASS, FAIL or WARN status. For example:</p><pre>[WARN] 5.1.1 Ensure that the cluster-admin role is only used where required (Manual)</pre><p>And after the tests run, it also suggests remediations for the check that got a WARN/FAIL status. For example:</p><pre>== Remediations policies == 5.1.1 Identify all clusterrolebindings to the cluster-admin role. Check if they are used and if they need this role or if they could use a role with fewer privileges. Where possible, first bind users to a lower privileged role and then remove the clusterrolebinding to the cluster-admin role : kubectl delete clusterrolebinding [name]</pre><p>And at the end you can find a summary of the section:</p><pre>== Summary policies == 0 checks PASS 0 checks FAIL 26 checks WARN 0 checks INFO</pre><h3>Potential use cases</h3><p>By running it as a CronJon in your cluster, Kube-bench can help you identify potential security issues in your cluster. It is a great tool to have in your toolbox and it is very easy to use. You can configure it to run on a schedule like every week or month and get a report on the security of your cluster, while also taking into account the specific CIS benchmark for your cloud provider. For example, you can set up and run the <a href="https://github.com/aquasecurity/kube-bench/blob/main/job-aks.yaml">job-aks.yaml</a> file to run the tests on an AKS cluster.</p><h3>Popeye — A Kubernetes Cluster Sanitizer</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/425/0*bWfX3Je6kvx8l6O8.png" /></figure><p>The repository for the tool can be found <a href="https://github.com/derailed/popeye">here</a>.</p><p>This is a read-only utility that scans live Kubernetes clusters and reports potential issues with deployed resources and configurations. What I liked about this tool is that it is very easy to install and use and it achieves what it promises: it reduces the cognitive overload one faces when operating a Kubernetes cluster in the wild.</p><h3>Setting it up</h3><p>Popeye can be used standalone using the command line, using a <a href="https://github.com/derailed/popeye/blob/master/spinach/spinach_aks.yml">spinach.yml</a> file or running directly in the cluster as a CronJob.</p><p>In this post, I will be using the command line option on a mac. So to install it I just ran:</p><pre># Install popeye <br>&gt; brew install derailed/popeye/popeye <br># Check popeye version <br>&gt; popeye version ___ ___ _____ _____ K .-&#39;-. | _ \___| _ \ __\ \ / / __| 8 __| `\ | _/ _ \ _/ _| \ V /| _| s `-,-`--._ `\ |_| \___/_| |___| |_| |___| [] .-&gt;&#39; a `|-&#39; Biffs`em and Buffs`em! `=/ (__/_ / \_, ` _) `----; | <br>Version: 0.10.1 <br>Commit: ae19897a4b5d3738a3e98179207759e45a53a64c <br>Date: 2022-06-28T14:46:13Z <br>Logs: /var/folders/vp/l8dlq0gn3x71f3vk82shmzlm0000gn/T/popeye.log <br># Connected to my AKS cluster <br># Check the context I am using <br>&gt; kubectl config current-context <br># Run popeye <br>&gt; popeye</pre><h3>The report breakdown</h3><p>The report will be printed to the console and it will look something like the following snippet below. I have removed some of the output for brevity and to give you an idea of the output format and the types of checks that are performed and the results.</p><p>The report is nicely split into sections and each section has a summary of the checks performed and the results. It ends with giving a grade to the cluster.</p><p>The color coding is also very helpful to quickly identify the issues.</p><p><em>For a full report head over to my blog where I posted it in full.</em></p><pre>CLUSTER (1 SCANNED) 💥 0 😱 0 🔊 0 ✅ 1 100٪ ┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅ CLUSTERROLES (13 SCANNED) 💥 0 😱 0 🔊 0 ✅ 13 100٪ ┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅ · azure-policy-webhook-cluster-role..............................................................✅ · gatekeeper-manager-role........................................................................✅ · <br>keda-operator-external-metrics-reader..........................................................✅ <br>system:coredns-autoscaler......................................................................✅ · system:metrics-server..........................................................................✅ <br>CLUSTERROLEBINDINGS (19 SCANNED) 💥 0 😱 6 🔊 0 ✅ 13 68٪ ┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅ · <br>azure-policy-webhook-cluster-rolebinding.......................................................✅ · <br>dapr-role-tokenreview-binding..................................................................😱 😱 </pre><p>Popeye has a bit of a different scope than Kube-bench in the sense that it scans your cluster for best practices and potential issues. It is not a security scanner like Kube-bench, but it can be used to find potential security issues and for your cluster management.</p><p>It targets the following:</p><p>Its main scope is to find misconfigurations like port mismatches, dead or unused resources etc. You can find the full list of available sanitizers <a href="https://github.com/derailed/popeye#sanitizers">here</a>.</p><h3>Potential use cases</h3><p>Should you choose it to run in a pipeline or as a job you can build on it and make action items to fix based on the errors reported in the report.</p><p>Or this could just be a little helpful tool to run on your cluster to get a quick overview of the state of your cluster. And you can extract any action items for yourself. In this case, you can save the report using the --save flag and attach it to your JIRA Ticket or PR.</p><p>This will save the report in your current working directory.</p><pre>&gt; popeye --save /var/folders/vp/l8dlq0gn3x71f3vk82shmzlm0000gn/T/popeye/sanitizer_aks-staging_1673563387070145000.txt</pre><h3>Summary</h3><p>I quite enjoyed using both Popeye and Kube-bench. They are both very useful in different ways. Popeye is more of a cluster management tool, while Kube-bench is more of a security scanner. But they can both be used to improve the security of your cluster.</p><p>In the next posts from this series, we will take a deeper look at the reports in more detail, focusing on the errors and seeing what we can do to improve our cluster score.</p><p><em>Until then, thank you for reading and I hope you found this useful. Let me know what other tools you use</em></p><p><em>Originally published at </em><a href="https://ana-cozma.github.io/blog/posts/k8s-aks-security-helpers/"><em>https://ana-cozma.github.io</em></a><em> on January 23, 2023.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=562f4ba88b66" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Terraform vs. Helm for managing K8s objects]]></title>
            <link>https://medium.com/@ana.cozma/terraform-vs-helm-for-managing-k8s-objects-69c2f7cda22b?source=rss-c58698151430------2</link>
            <guid isPermaLink="false">https://medium.com/p/69c2f7cda22b</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[helm]]></category>
            <dc:creator><![CDATA[Ana Cozma]]></dc:creator>
            <pubDate>Wed, 10 Aug 2022 09:02:46 GMT</pubDate>
            <atom:updated>2022-08-12T08:50:10.552Z</atom:updated>
            <content:encoded><![CDATA[<p>When I started migrating to Kubernetes (K8s) I discovered that I can use Terraform for managing not only the infrastructure, but also I could define the K8s objects in it, but I also could use Helm to handle that. But what would be a good way to handle this?</p><p>In this post we will cover Terraform and Helm for managing Kubernetes clusters with some code snippets and an idea on how you can use them together to get you started.</p><h3>Structure of the post:</h3><ol><li><a href="https://community.ops.io/the_cozma/terraform-vs-helm-for-managing-k8s-objects-1p1h#What%20is%20Terraform?">What is Terraform?</a></li><li><a href="https://community.ops.io/the_cozma/terraform-vs-helm-for-managing-k8s-objects-1p1h#Manage%20Kubernetes%20Resources%20via%20Terraform">Manage Kubernetes Resources via Terraform</a></li><li><a href="https://community.ops.io/the_cozma/terraform-vs-helm-for-managing-k8s-objects-1p1h#What%20is%20Helm?">What is Helm?</a></li><li><a href="https://community.ops.io/the_cozma/terraform-vs-helm-for-managing-k8s-objects-1p1h#Manage%20Kubernetes%20Resources%20via%20Helm">Manage Kubernetes Resources via Helm</a></li><li><a href="https://community.ops.io/the_cozma/terraform-vs-helm-for-managing-k8s-objects-1p1h#Using%20Helm%20and%20Terraform%20Together">Using Helm and Terraform Together</a></li></ol><h3>What is Terraform?</h3><p><a href="https://www.terraform.io/">HashiCorp Terraform</a> is an infrastructure as code tool that lets you define both cloud and on-prem resources in human-readable configuration files that you can version, reuse, and share.</p><p>It can manage low-level components like compute, storage, and networking resources, as well as high-level components like DNS entries and SaaS features.</p><p>Terraform treats Infrastructure as Code (IaC) meaning teams manage infrastructure setup with configuration files instead of using graphical user interface (think of Azure Portal and the like).</p><p><em>So why would you use Terraform?</em></p><p>Some of the <em>benefits</em> include:</p><ul><li>It allows teams to build, change, and manage the infrastructure in a <strong>safe, consistent, and repeatable way</strong> by defining resource configurations that can be versioned, reused, and shared.</li><li>It supports all major cloud <strong>providers</strong>: Azure, AWS, GCP and many other which you can find <a href="https://registry.terraform.io/browse/providers">by browsing their registry</a>.</li></ul><blockquote>Providers define individual units of infrastructure, for example compute instances or private networks, as resources. You can compose resources from different providers into reusable Terraform configurations called modules, and manage them with a consistent language and workflow.</blockquote><p>You define your providers in the terraform code as follows:</p><blockquote>Meaning that it describes the desired <strong>end-state for your infrastructure</strong>, in contrast to procedural programming languages that require step-by-step instructions to perform tasks. Terraform providers automatically calculate dependencies between resources to create or destroy them in the correct order.</blockquote><p>This means that any new team member joining will be able to understand the infrastructure setup you have just by going through the configuration files.</p><p>You can read more on the advantages it brings by looking over the <a href="https://www.terraform.io/use-cases/infrastructure-as-code">official use cases</a> from the Terraform documentation.</p><p><em>Terraform — How does it work?</em></p><p>Terraform follows a simple <em>workflow</em> for managing your infrastructure. So once a new resource or changes to resources are desired, the team will:</p><p><strong>Initialize</strong> the backend by running the terraform init command, which will install the plugins Terraform needs to manage the infrastructure.</p><p>Output will look something like:</p><p>In the example above we initialize the backend, in our case we store the state file in a container in azure, the providers (azurerm, azuread, helm, kubernetes) and we get a successful message of completion.</p><p><strong>Plan</strong> the changes to be made by running the terraform plan command, which will give a review of the &#39;planned&#39; changes Terraform will make to match your configuration.</p><p>During the plan, Terraform will mark which resources will be:</p><ul><li>added with a ‘+’ sign,</li><li>updated with a ‘~’ sign or</li><li>deleted with a ‘-’ sign.</li></ul><p>In this example Terraform is creating a brand new resource as you can see all attributes are marked with the + sign:</p><p>But in this one, the resource was already previously created, and Terraform is just updating something to it which is marked with the ~ sign:</p><p>Terraform keeps track of your real infrastructure in a <em>state</em> file, which acts as a source of truth for your environment. Meaning it uses this file to determine the changes to make to your infrastructure so that it will match your configuration.</p><p>This is also helpful to detect infrastructure drifts between the desired state and the current one.</p><p><strong>Apply</strong> the desired changes by running the terraform apply command.</p><p>A view from the Terraform official documentation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*RlKtyNkr8fQagFa_" /></figure><p>So this is Terraform in a nutshell.</p><h3>Manage Kubernetes Resources via Terraform</h3><p>Terraform’s Kubernetes (K8S) provider is used to interact with the resources supported by Kubernetes and offers many benefits, but it’s important to note that the capability is still new. This means you might not have all of the resources available in the provider or there might be some open bugs.</p><p>That said, how would this look?<br> Let’s look at an example for an AKS cluster in Terraform:</p><p>So you create the resources, run terraform apply and it will provision your infrastructure.</p><p>For the <strong><em>deployment</em></strong> we create a separate Terraform file using the kubernetes deployment resource:</p><p>And in order to create this you again run terraform apply and confirm the changes.</p><p>Same approach will apply to creating a :</p><p>And if you want to scale this setup then the approach is:</p><p>Aside from this we can store the kubernetes_namespace resource:</p><p>And any secrets you might need:</p><p>Using this approach means you can take <em>advantage</em> of the benefits of Terraform including:</p><ul><li>can use one tool for managing your infrastructure resources and also for your cluster management</li><li>you use one language for all your infrastructure resources and also the k8s objects</li><li>you can nicely see the plan of your changes before provisioning resources</li></ul><p>The <em>disadvantages</em> are of course you need to be familiar with hcl language and if the team is new adopting it would take a bit of time.</p><p>The K8s Terraform provider might not fully support all the beta objects so you might need to wait.</p><p>If you are interested in provisioning a cluster and all the K8s objects via Terraform please check the <a href="https://learn.hashicorp.com/tutorials/terraform/kubernetes-provider">official documentation</a> for step by step settings.</p><h3>What is Helm?</h3><p><a href="https://helm.sh/">Helm</a> is a package manager tool that helps you manage Kubernetes applications. Helm makes use of <strong>Helm Charts</strong> to define, install, and upgrade Kubernetes application.</p><p>Let’s look over some terminology when working with Helm:</p><p><em>Helm:</em> is the command-line interface that helps you define, install, and upgrade your Kubernetes application using charts.</p><p><em>Charts:</em> are the format for Helm’s application package. The <strong>chart</strong> is a bundle of information necessary to create an instance of a Kubernetes application. Basically a package of files and templates that gets converted into Kubernetes objects at deployment time.</p><p><em>Chart repository:</em> is the location where you can store and share packaged charts.</p><p><em>The config:</em> contains configuration information that can be merged into a packaged chart to create a releasable object.</p><p><em>The Release:</em> is a running instance of a chart, combined with a specific config. It is created by Helm to track the installation of the charts you created/defined.</p><p>For more details on <a href="https://helm.sh/docs/topics/architecture/">Helm architecture</a>.</p><p>Some of the <em>benefits</em> Helm brings:</p><ul><li>Charts are in YAML format and are <strong>reusable</strong> because they provide repeatable application installation. Because of this you can use them in multiple environments (think dev, staging and prod following the same one).</li><li>Because charts build a repeatable process this makes deployments easier.</li><li>A lot of charts are <strong>already </strong><a href="https://artifacthub.io/"><strong>available</strong></a>, but you can create your own as well — <strong>custom</strong> charts.</li><li>You can create <strong>dependencies</strong> between the charts and can also use <a href="https://helm.sh/docs/chart_template_guide/subcharts_and_globals/"><strong>sub-charts</strong></a> to add more flexibility to your setup.</li><li>Charts serve as a single point of authority.</li><li>Releases are tracked.</li><li>You can upgrade or rollback multiple K8s objects together.</li><li>Charts can be easily installed/ uninstalled.</li></ul><h3>Manage Kubernetes Resources via Helm</h3><p>We looked over the main terminology when using Helm, but let’s see how it would look like.</p><p>First thing we need to do is in the repository where we have our code we run the helm create &lt;app_name&gt; command. This command creates a chart directory along with the common files and directories used in a chart. <a href="https://helm.sh/docs/helm/helm_create/">More information on the command</a>.</p><p>And this will create a structure as follows:</p><pre>. └── example ├── Chart.yaml ├── charts ├── templates │ ├── NOTES.txt │ ├── _helpers.tpl │ ├── deployment.yaml │ ├── hpa.yaml │ ├── ingress.yaml │ ├── service.yaml │ ├── serviceaccount.yaml │ └── tests │ └── test-connection.yaml └── values.yaml</pre><p>We notice it created:<br> A <em>Chart.yaml</em> file which just contains the information about the chart.</p><p>The <em>charts</em> directory where you can add any charts that your chart depends on.</p><p>The <em>templates</em> directory:<br> A directory to store partials and helpers. The file called<strong>_helpers.tpl</strong> is the default location for template partials that the rest of the yaml files rely on as we will see.</p><p>How does this work?</p><p>Let’s take a small example, in that file we define the fullname:</p><p>And in our service.yaml file we can include the defined fullname like:</p><p>And in the values.yaml file we can also override it:</p><p>In the example above the fullname will be the Chart name since we didn’t pass any value in the values.yaml file for the override based on the definition of the parameter in the _helpers.tpl file.</p><p>The <em>values.yaml</em> file which contains the default values for your templates. You can at this point split the values file per each environment: one for staging, one for production etc.</p><p>From here onwards you can start configuring based on what you need. If you check the yaml files you will notice the structure is very similar to what we defined in the K8s objects terraform code.</p><p>For the installation of the charts you can either go one by one and make use of the helm install/upgrade commands OR you can add this in your CI/CD pipelines.</p><p>Going by the command line could look something like:<br>helm upgrade example infra/charts/example --install --wait --atomic --namespace=example --set=app.name=example --values=infra/charts/example/values.yaml<br> where:</p><ul><li>infra/charts/example — is the location of your Chart.yaml file</li><li>values=infra/charts/example/values.yaml — is the location of the values file</li><li>--wait - will wait until either the release is successful or the default timeout is reached (5m) if no timeout is specified</li><li>--atomic- if set, upgrade process rolls back changes made in case of failed upgrade</li></ul><p>Check the full synopsis of the command <a href="https://helm.sh/docs/helm/helm_upgrade/">here</a>.</p><p><em>helm install or helm upgrade — install?</em></p><p>The <em>install</em> sub-command always installs a brand new chart, while the <em>upgrade</em> sub-command can upgrade an existing chart and install a new one, if the chart hasn’t been installed before.</p><blockquote><em>For simplicity you can always you the upgrade sub-command.</em></blockquote><h3>Using Helm and Terraform Together</h3><p>Helm and Terraform are not mutually exclusive and can be used together in the same K8s setup even if the actual setup really depends on your project complexity, which benefits you want to make use of and which drawbacks you can live with.</p><p>In a potential setup where you would use both you could structure it something like:</p><ul><li>use Terraform to <em>create and manage resources</em>: the K8s Cluster, the K8s namespace, and the K8s secrets( if any )</li><li>use Helm charts to <em>deploy</em> your applications</li></ul><p>This is the setup we currently use and it has served us well so far.</p><p>It is worth mentioning that you can also use Terraform to handle your Helm deploys using the helm_release <a href="https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release">resource</a>.</p><p>In this approach you would have both infrastructure and provisioning in one place — in Terraform. I will not go in this post in the differences between them, but I will mention going with this approach should depend on how <em>frequent</em> you need to apply changes to your infrastructure because the way this works is during terraform apply operation the helm release will take place.</p><p>There is no one-size-fits-all approach, but you should tailor tooling and the strategy to your needs.</p><p><em>Hope you find this helpful. Thank you for reading and feel free to comment on your experience and what you prefer to use and why.</em></p><p><em>Originally published at </em><a href="https://community.ops.io/the_cozma/terraform-vs-helm-for-managing-k8s-objects-1p1h"><em>https://community.ops.io</em></a><em> on August 10, 2022.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69c2f7cda22b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Terraform: Alternative to the Template provider on Apple M1 MBP]]></title>
            <link>https://medium.com/@ana.cozma/terraform-alternative-to-the-template-provider-on-apple-m1-mbp-4be4004b8f7b?source=rss-c58698151430------2</link>
            <guid isPermaLink="false">https://medium.com/p/4be4004b8f7b</guid>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[m1-mac]]></category>
            <category><![CDATA[infrastructure-as-code]]></category>
            <dc:creator><![CDATA[Ana Cozma]]></dc:creator>
            <pubDate>Fri, 05 Aug 2022 08:24:28 GMT</pubDate>
            <atom:updated>2022-08-15T06:03:00.815Z</atom:updated>
            <content:encoded><![CDATA[<p>We ran into an issue while applying our Terraform infrastructure on a M1 Mac where we were making use of the <a href="https://github.com/hashicorp/terraform-provider-template">Terraform Provider Template</a>.</p><p>When applying it, we were getting the following error:</p><pre>template v2.2.0 does not have a package available for your current platform, darwin_arm64</pre><p>Since the provider is archived, we need to find an alternative.</p><p><em>What does archiving mean?</em><br> Per Terraform <a href="https://www.terraform.io/internals/archiving">Archiving Providers</a> documentation.</p><ul><li>The code repository and all commit, issue, and PR history will still be available.</li><li>Existing released binaries will remain available on the releases site.</li><li>Documentation for the provider will remain on the Terraform website.</li><li>Issues and pull requests are not being monitored, merged, or added.</li><li>No new releases will be published.</li><li>Nightly acceptance tests may not be run.</li></ul><p><em>So what alternatives do we have instead of the deprecated provider?</em></p><p>Let’s look at an example.</p><h3>Resource using the deprecated Template provider</h3><p>Let’s say we have the following resource — a grafana dashboard json that we store in our Terraform code.</p><p>And the grafana dashboard Terraform resource:</p><p>When you try to apply this piece of code it will throw the aforementioned error.</p><h3>Updating to the built-in templatefile Terraform function</h3><p>We can make use of the built-in templatefile <a href="https://www.terraform.io/language/functions/templatefile">Terraform function</a> that:</p><blockquote>templatefile reads the file at the given path and renders its content as a template using a supplied set of template variables.</blockquote><p>The function uses the format:<br>templatefile(path, vars)</p><p>In our case the path is the path to the grafana json file.</p><p>And vars contains all the variables that we need to use for the grafana dashboard json file.</p><blockquote>The “vars” argument must be a map. Within the template file, each of the keys in the map is available as a variable for interpolation. The template may also use any other function available in the Terraform language, except that recursive calls to templatefile are not permitted. Variable names must each start with a letter, followed by zero or more letters, digits, or underscores.</blockquote><p>And our new code looks like this:</p><p>Thanks to the new templatefile function, we can get rid of the template_file data source.</p><p>This means at this point we no longer rely on the hashicorp/template provider and we can apply our infrastructure changes.</p><p>At this point you can apply the infrastructural changes, but it still might not work and throw the error and this is because if the infrastructure has already been initialized and applied previously we have a record of the deprecated provider stored in the lock file.</p><h3>The template provider is still in the .terraform.lock.hcl file</h3><p>If you run terraform init and still see that the template provider is being installed:</p><p>Then check the Dependency Lock File, terraform.hcl.lock file. If you still see it there:</p><p>Check who is requiring the provider (maybe it’s still being used in the code elsewhere). This can be done by running the terraform providers command, which:</p><blockquote><em>The terraform providers command shows information about the provider requirements of the configuration in the current working directory, as an aid to understanding where each requirement was detected from.</em></blockquote><p>In this case we can see that the template provider is required by the state.</p><p>In order to get rid of this dependency, make sure you update Terraform to any versions greater than <strong>v.1.1.3.</strong> and this is because they fixed the following issue: <a href="https://github.com/hashicorp/terraform/pull/30192">https://github.com/hashicorp/terraform/pull/30192</a> in version 1.1.3.</p><p>In order to update the lock file and remove the entry for the deprecated template provider, we run terraform init.</p><p>This is because Terraform relies on two sources for determining the truth: the <em>configuration</em> itself and the <em>state</em>. If you remove the dependency on a particular provider from <em>both</em> your configuration and the state then running terraform init will remove any existing lock file entry for that provider.</p><p>And let’s look at the output:</p><p>And we see the template provider is no longer there.</p><p>Now you can safely commit the freshly updated <a href="https://www.terraform.io/language/files/dependency-lock">Dependency Lock File</a>.</p><p><em>Originally published at </em><a href="https://community.ops.io/the_cozma/terraform-alternative-to-the-template-provider-on-apple-m1-mbp-31c8"><em>https://community.ops.io</em></a><em> on August 5, 2022.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4be4004b8f7b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[K8s] Fix Helm release failing with an upgrade still in progress]]></title>
            <link>https://medium.com/@ana.cozma/k8s-fix-helm-release-failing-with-an-upgrade-still-in-progress-3841152976da?source=rss-c58698151430------2</link>
            <guid isPermaLink="false">https://medium.com/p/3841152976da</guid>
            <category><![CDATA[helm]]></category>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Ana Cozma]]></dc:creator>
            <pubDate>Mon, 30 May 2022 19:47:20 GMT</pubDate>
            <atom:updated>2022-05-31T08:02:11.379Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*ht66oks082-668KO" /></figure><p>This article applies to: <strong>Helm v3.8.0</strong></p><blockquote>Helm helps you manage Kubernetes applications — Helm Charts help you define, install, and upgrade even the most complex Kubernetes application. More details on Helm and the commands can be found in the <a href="https://helm.sh/">official documentation</a>.</blockquote><p>Assuming you use Helm to handle your releases, you might end up in a case where the release will be stuck in a pending state and all subsequent releases will keep failing.</p><p>This could happen if:</p><ul><li>you run the upgrade command from the cli and accidentally (or not) interrupt it or</li><li>you have two deploys running at the same time (maybe in Github Actions, for example)</li></ul><p>Basically any interruption that occurred during your install/upgrade process <strong>could</strong> lead you to a state where you cannot install another release anymore.</p><p>In the release logs the failing upgrade will show an error similar to the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Hn1m3-of1o7kjQq9EYh6A.png" /></figure><p>And the status will be stuck in: PENDING_INSTALL or PENDING_UPGRADE depending on the command you were running.</p><p>Because of this pending state when you run the command to list all release it will return empty:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vec5FOCj5LJKXKIjIfin7A.png" /></figure><p>So what can we do now? In this article we will look over the two options described below. Keep in mind that based on your setup it could be another issue, but I’m hoping that these two pointers will give you a place to start.</p><ol><li>Roll back to the previous working version using the helm rollback command.</li><li>Delete the helm secret associated with the release and re-run the upgrade command.</li></ol><p>So let’s look at each option in detail.</p><h3>First option: Roll back to the previous working version using the helm rollback command</h3><p>From the official documentation:</p><blockquote>This command rolls back a release to a previous revision.<br> The first argument of the rollback command is the name of a release, and the second is a revision (version) number. If this argument is omitted, it will roll back to the previous release.</blockquote><p>So, in this case, let’s get the history of the releases:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*b9fwnMox-k2ELBis7Q0Eig.png" /></figure><p>In the output you will notice the STATUS of your release with: pending-upgrade:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PKHM_W8bqLETtSIQ1cPKlQ.png" /></figure><p>Now let’s perform the rollback by running the following command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HN3n4IVmyEr3yLbFtWWUPQ.png" /></figure><p>So in our case we run:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WuUzmA4ZU0RLiJUm5498bw.png" /></figure><p>After we get confirmation that the rollback was successful, we run the command to get the history again.</p><p>We now see we have two releases and that our rollback was successful having the STATUS is: deployed</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9CY7JeMbeLMpXD8TEWS3pA.png" /></figure><p>So what if the solution above didn’t work?</p><h3>Second option: Delete the helm secret associated with the release and re-run the upgrade command</h3><p>First we get all the secrets for the namespace by running:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Osvhqrw9uSdFVyMUroZ_Sg.png" /></figure><p>In the output you will notice a list of secrets in the following format:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VivEe0erQZuW1U5h6cgjdQ.png" /></figure><p><strong>So what’s in a secret?</strong></p><p>Helm3 makes use of the Kubernetes <a href="https://kubernetes.io/docs/concepts/configuration/secret/">Secrets</a> object to store any information regarding a release. These secrets are basically used by Helm to store and read it’s state every time we run: helm list, helm history or helm upgrade in our case.</p><p>The naming of the secrets is <strong>unique per namespace</strong>. <br> The format follows the following convention:<br>sh.helm.release.v1.&lt;release_name&gt;.&lt;release_version&gt;.</p><p>There is a max of 10 secrets that are stored by default, but you can modify this by setting the --history-max flag in your <a href="https://helm.sh/docs/helm/helm_upgrade/">helm upgrade</a> command.</p><blockquote>— history-max int limit the maximum number of revisions saved per release. Use 0 for no limit (default 10)</blockquote><p>Now that we know what these secrets are used for, let’s delete the helm secret associated with the pending release by running the following command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5VApyCYJnkS479KKLNSrHA.png" /></figure><p>Finally, we re-run the helm upgrade command (either from command line or from your deployment workflow), which, if all was good so far, should succeed.</p><p>There is an open issue with <a href="https://github.com/helm/helm/issues/4558">Helm</a> so hopefully these workaround won’t be needed anymore. But it’s open since 2018.</p><p><em>Of course there could be other cases or issues, but I hope this is a nice place to start. If you ran into something similar I would love to read your input in what the issue was and how you solved it especially since I didn’t find the error message to be intuitive.</em> <em>Thank you for reading!</em></p><p><em>Originally published at </em><a href="https://community.ops.io/the_cozma/k8s-fix-helm-release-failing-with-an-upgrade-still-in-progress-4660"><em>https://community.ops.io</em></a><em> on May 30, 2022.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3841152976da" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>