<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: varshith</title>
    <description>The latest articles on Forem by varshith (@darthvader2).</description>
    <link>https://forem.com/darthvader2</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F248932%2Fa2e87272-6167-44a4-a789-bd5553eb50e8.jpeg</url>
      <title>Forem: varshith</title>
      <link>https://forem.com/darthvader2</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/darthvader2"/>
    <language>en</language>
    <item>
      <title>Integrate kube-score into github actions for Helm charts</title>
      <dc:creator>varshith</dc:creator>
      <pubDate>Thu, 22 Jun 2023 09:28:54 +0000</pubDate>
      <link>https://forem.com/darthvader2/integrate-kube-score-into-github-actions-for-helm-charts-210f</link>
      <guid>https://forem.com/darthvader2/integrate-kube-score-into-github-actions-for-helm-charts-210f</guid>
      <description>&lt;p&gt;Kube Score is a powerful open-source tool designed to evaluate the security posture of Helm charts. By integrating kube-score into GitHub Actions, you can easily check the security context of your Helm charts as part of your CI/CD pipeline. In this blog post, we will guide you through the process of setting up kube-score within GitHub Actions to ensure the security of your deployments.&lt;/p&gt;

&lt;p&gt;Step 1: Creating the GitHub Actions Workflow&lt;/p&gt;

&lt;p&gt;To begin, navigate to your GitHub project's root directory and create a new file named &lt;code&gt;.github/workflows/kube-score-check.yaml&lt;/code&gt;. This file will contain the configuration for our kube-score check.&lt;/p&gt;

&lt;p&gt;Step 2: Editing the kube-score-check.yaml file&lt;/p&gt;

&lt;p&gt;Open the newly created &lt;code&gt;kube-score-check.yaml&lt;/code&gt; file and let's start editing it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Kube-score-check&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first line sets the name of our GitHub Actions workflow as "Kube-score-check".&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;push&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;pull_request&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;branches&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;main&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above code specifies the trigger for our workflow. It will be triggered on both push and pull request events in the main branch. Adjust the branch name as per your project's configuration.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;kube-score&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-22.04&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Checkout&lt;/span&gt;
          &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/checkout@v3&lt;/span&gt;
          &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="na"&gt;fetch-depth&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this section, we define the jConclusion:ob for our workflow. It will run on an Ubuntu 22.04 environment. The first step is to checkout the repository's code using the &lt;code&gt;actions/checkout&lt;/code&gt; action. We set &lt;code&gt;fetch-depth&lt;/code&gt; to 0 to ensure the full history of the repository is fetched.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt; &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Install kube-score&lt;/span&gt;
          &lt;span class="s"&gt;run&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
              &lt;span class="s"&gt;wget https://github.com/zegl/kube-score/releases/download/v1.16.1/kube-score_1.16.1_linux_amd64.tar.gz&lt;/span&gt;
              &lt;span class="s"&gt;tar xvf ./kube-score_1.16.1_linux_amd64.tar.gz &amp;amp;&amp;amp; mv kube-score /usr/local/bin&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, we fetch and install the kube-score package within the GitHub Actions runtime environment. This step downloads the necessary kube-score binary and adds it to the &lt;code&gt;/usr/local/bin&lt;/code&gt; directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Run kube-score&lt;/span&gt;
          &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;helm template "YOUR DEPLOYMENT NAME" . | kube-score score -&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After installing kube-score, we can now run the actual evaluation. Replace "YOUR DEPLOYMENT NAME" with the name of your Helm deployment (without quotes). This command uses &lt;code&gt;helm template&lt;/code&gt; to render the Helm chart and then pipes it to &lt;code&gt;kube-score score -&lt;/code&gt; for evaluation.&lt;/p&gt;

&lt;p&gt;Step 3: Pushing the Workflow to GitHub&lt;/p&gt;

&lt;p&gt;Finally, push the &lt;code&gt;kube-score-check.yaml&lt;/code&gt; file to your GitHub repository. This will trigger the workflow whenever there is a pull request or push event on the specified branch.&lt;/p&gt;

&lt;p&gt;Integrating kube-score into GitHub Actions provides a seamless way to evaluate the security posture of your Helm charts as part of your CI/CD pipeline. By following the steps outlined in this blog post, you can easily set up kube-score and ensure the security of your deployments.&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>githubactions</category>
      <category>cicd</category>
    </item>
  </channel>
</rss>
