<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Edu Mínguez</title>
    <description>The latest articles on DEV Community by Edu Mínguez (@minwi).</description>
    <link>https://dev.to/minwi</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%2F898450%2F15144944-52bb-4622-a4ff-89cea26488e4.jpg</url>
      <title>DEV Community: Edu Mínguez</title>
      <link>https://dev.to/minwi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/minwi"/>
    <language>en</language>
    <item>
      <title>Fixing potential security issues in your Infrastructure as Code at the source with Sysdig</title>
      <dc:creator>Edu Mínguez</dc:creator>
      <pubDate>Wed, 14 Sep 2022 14:29:24 +0000</pubDate>
      <link>https://dev.to/minwi/fixing-potential-security-issues-in-your-infrastructure-as-code-at-the-source-with-sysdig-2bdm</link>
      <guid>https://dev.to/minwi/fixing-potential-security-issues-in-your-infrastructure-as-code-at-the-source-with-sysdig-2bdm</guid>
      <description>&lt;p&gt;Infrastructure as Code (IaC) is a powerful mechanism to manage your infrastructure, but with great power comes great responsibility. If your IaC files have security problems (for example, a misconfigured permission because of a typo), this will be propagated along your CI/CD pipeline until it is hopefully discovered at runtime, where most of the security issues are scanned or found. &lt;em&gt;What if you can fix potential security issues in your infrastructure at the source?&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Infrastructure as Code?
&lt;/h2&gt;

&lt;p&gt;IaC is a methodology of treating the building blocks of your infrastructure (virtual machines, networking, containers, etc.) as code using different techniques and tools. This means instead of manually creating your infrastructure, such as VMs, containers, networks, or storage, via your favorite infrastructure provider web interface, you define them as code and then those are created/updated/managed by the tools you choose (terraform, crossplane, pulumi, etc.).&lt;/p&gt;

&lt;p&gt;The benefits are huge. You can manage your infrastructure as if it was code (it &lt;em&gt;is&lt;/em&gt; code now) and leverage your development best practices (automation, testing, traceability, versioning control, etc.) to your infrastructure assets. There is tons of information out there around this topic, but the &lt;a href="https://sysdig.com/learn-cloud-native/cloud-security/what-is-infrastructure-as-code-iac-security/"&gt;following resource&lt;/a&gt; is a good starting point. &lt;/p&gt;

&lt;h2&gt;
  
  
  Why is securing your Infrastructure as Code assets important as an additional security layer?
&lt;/h2&gt;

&lt;p&gt;Most security tools detect potential vulnerabilities and issues at runtime, which is too late. In order to fix them, either a reactive manual process needs to be performed (for example, directly modifying a parameter in your k8s object with&lt;code&gt;kubectl edit&lt;/code&gt;) or ideally, the fix will happen at source and then it will be propagated all along your supply chain. This is what is called “Shift Security Left.” Move from fixing the problem when it is too late to fixing it before it happens.&lt;/p&gt;

&lt;p&gt;According to Red Hat's "&lt;a href="https://www.redhat.com/en/resources/state-kubernetes-security-report"&gt;2022 state of Kubernetes security report&lt;/a&gt;,” _57% of respondents worry the most about the runtime phase of the container life cycle. _But wouldn't it be better if those potential issues can be discovered directly into the code definition instead?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YzUcBBVR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xhmjghak69clcd1o369h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YzUcBBVR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xhmjghak69clcd1o369h.png" alt="" width="880" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introducing Sysdig Git Infrastructure as Code Scanning
&lt;/h2&gt;

&lt;p&gt;Based on the current&lt;a href="https://docs.sysdig.com/en/docs/sysdig-secure/iac-security/iac-policy-controls/"&gt; “CIS Kubernetes” and “Sysdig K8s Best Practices” benchmarks&lt;/a&gt;, Sysdig Secure scans you Infrastructure as Code manifests at the source. Currently, it supports scanning YAML, Kustomize, Helm. or Terraform files representing &lt;a href="https://kubernetes.io/docs/concepts/workloads/"&gt;Kubernetes workloads&lt;/a&gt; (stay tuned for future releases), and it integrates seamlessly with your development workflow by showing potential issues directly in the pull requests on the repositories hosted in GitHub, GitLab, Bitbucket, or Azure DevOps. See more information in the &lt;a href="https://docs.sysdig.com/en/docs/sysdig-secure/iac-security/git-iac-scanning/"&gt;official documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;As a proof of concept, let's see it in action in a small EKS cluster using the example guestbook application as our “Infrastructure as Code,” where we will also apply GitOps practices to manage our application lifecycle with ArgoCD.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This is a proof of concept of a GitOps integration with Sysdig IaC scanning. The versions used on this PoC are ArgoCD 2.4.0, Sysdig Agent 12.8.0, and Sydig Charts v1.0.3.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; Want to know more about GitOps? See &lt;a href="https://sysdig.com/blog/gitops-iac-security-source/"&gt;How to apply security at the source using GitOps&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Preparations
&lt;/h2&gt;

&lt;p&gt;This is how our EKS cluster (created as "&lt;code&gt;eksctl create cluster -n edu --region eu-central-1 --node-type m4.xlarge --nodes 2&lt;/code&gt;")&lt;/p&gt;

&lt;p&gt;looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;❯ kubectl get nodes
NAME                                          STATUS   ROLES    AGE    VERSION
ip-10-0-2-210.eu-central-1.compute.internal   Ready    &amp;lt;none&amp;gt;   108s   v1.20.15-eks-99076b2
ip-10-0-3-124.eu-central-1.compute.internal   Ready    &amp;lt;none&amp;gt;   2m4s   v1.20.15-eks-99076b2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Installing Argo CD is as easy as following the instructions in the &lt;a href="https://argo-cd.readthedocs.io/en/stable/getting_started/"&gt;official documentation&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;❯ kubectl create namespace argocd
❯ kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/v2.4.0/manifests/install.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With Argo in place, let's create our example application. We will leverage the example guestbook Argo CD application already available at &lt;a href="https://github.com/argoproj/argocd-example-apps.git"&gt;https://github.com/argoproj/argocd-example-apps.git&lt;/a&gt; by creating our own fork directly at GitHub:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://app.storylane.io/demo/do0o8plgnf7o"&gt;See it here interactively&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Or, using the GitHub cli tool:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;❯ cd ~/git
❯ gh repo fork https://github.com/argoproj/argocd-example-apps.git --clone
✓ Created fork e-minguez/argocd-example-apps
Cloning into 'argocd-example-apps'...
...
From github.com:argoproj/argocd-example-apps
 * [new branch]      master     -&amp;gt; upstream/master
✓ Cloned fork
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, configure Argo CD to deploy our application in our k8s cluster via the web interface. To access the Argo CD web interface, we are required to get the password (it is randomized at installation time) as well as make it externally available. In this example a port-forward is used:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;❯ kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo
s8ZzBlGRSnPbzmtr
❯ kubectl port-forward svc/argocd-server -n argocd 8080:443 &amp;amp;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, we can access the Argo CD UI using a web browser pointing to &lt;a href="http://localhost:8080"&gt;http://localhost:8080&lt;/a&gt; :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://app.storylane.io/demo/ziml7xbgicku"&gt;See it here interactively&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Or, using Kubernetes objects directly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;❯ cat &amp;lt;&amp;lt; EOF | kubectl apply -f -
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: my-example-app
  namespace: argocd
spec:
  destination:
    namespace: my-example-app
    server: https://kubernetes.default.svc
  project: default
  source:
    path: guestbook/
    repoURL: https://github.com/e-minguez/argocd-example-apps.git
    targetRevision: HEAD
  syncPolicy:
    automated: {}
    syncOptions:
    - CreateNamespace=true
EOF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After a few moments, Argo will deploy your application from your git repository, including all the objects:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0HLvjHnd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/InfraAsCodeSecurity-02.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0HLvjHnd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/InfraAsCodeSecurity-02.png" alt="" width="880" height="463"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;❯ kubectl get all -n my-example-app
NAME                                READY   STATUS    RESTARTS   AGE
pod/guestbook-ui-85985d774c-n7dzw   1/1     Running   0          14m

NAME                   TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE
service/guestbook-ui   ClusterIP   172.20.217.82   &amp;lt;none&amp;gt;        80/TCP    14m

NAME                           READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/guestbook-ui   1/1     1            1           14m

NAME                                      DESIRED   CURRENT   READY   AGE
replicaset.apps/guestbook-ui-85985d774c   1         1         1       14m
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Success!&lt;/p&gt;

&lt;p&gt;The application defined as code is already running in the Kubernetes cluster and the deployment has been automated using the GitOps practices. However, we didn't take into consideration any security aspect of it. Is the definition of my application secure enough? Did we miss anything? Let's see what we can find out.&lt;/p&gt;

&lt;p&gt;Configuring Sysdig Secure to scan our new shiny repository is as easy as adding a new git repository integration:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://app.storylane.io/demo/ysepdzaddvcb"&gt;See it here interactively&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Pull request policy evaluation
&lt;/h2&gt;

&lt;p&gt;Now, let's see it in action. Create a pull request with some code changes, for example to increase the number of replicas from 1 to 2:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://app.storylane.io/demo/50zbsmimy6oa"&gt;See it here interactively&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Or, by using the cli:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;❯ git switch -c my-first-pr
Switched to a new branch 'my-first-pr'
❯ sed -i -e 's/  replicas: 1/  replicas: 2/g' guestbook/guestbook-ui-deployment.yaml
❯ git add guestbook/guestbook-ui-deployment.yaml
❯ git commit -m 'Added more replicas'
[my-first-pr c67695e] Added more replicas
 1 file changed, 1 insertion(+), 1 deletion(-)
❯ git push
Enumerating objects: 7, done.
…
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Almost immediately, Sysdig Secure will perform a scan of the repository folder and will notify potential issues:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HqYcbCId--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/InfraAsCodeSecurity-03.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HqYcbCId--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/InfraAsCodeSecurity-03.png" alt="" width="880" height="824"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, you can see some potential issues based on the CIS Kubernetes V1.6 benchmark as well as the Sysdig Kubernetes best practices ordered by severity. An example is the “Container with writable root file system” one located in the deployment file of our example application.&lt;/p&gt;

&lt;p&gt;You can apply those recommendations by modifying your source code, but why don't we make Sysdig Secure do it for you?&lt;/p&gt;

&lt;h2&gt;
  
  
  Remediating the issues at source automagically
&lt;/h2&gt;

&lt;p&gt;Let's deploy the Sysdig Secure agent via helm in our cluster so it can inspect our objects running, including a couple of new flags to enable the KSPM features.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;❯ helm repo add sysdig https://charts.sysdig.com
❯ helm repo update
❯ export SYSDIG_ACCESS_KEY="XXX"
❯ export SAAS_REGION="eu1"
❯ export CLUSTER_NAME="mycluster"
❯ export COLLECTOR_ENDPOINT="ingest-eu1.app.sysdig.com"
❯ export API_ENDPOINT="eu1.app.sysdig.com"

❯ helm install sysdig sysdig/sysdig-deploy \
    --namespace sysdig-agent \
    --create-namespace \
    --set global.sysdig.accessKey=${SYSDIG_ACCESS_KEY} \
    --set global.sysdig.region=${SAAS_REGION} \
    --set global.clusterConfig.name=${CLUSTER_NAME} \
    --set agent.sysdig.settings.collector=${COLLECTOR_ENDPOINT} \
    --set nodeAnalyzer.nodeAnalyzer.apiEndpoint=${API_ENDPOINT} \
    --set global.kspm.deploy=true
# after a few moments
❯ kubectl get po -n sysdig-agent
NAME                                    READY   STATUS    RESTARTS   AGE
nodeanalyzer-node-analyzer-bw5t5        4/4     Running   0          9m14s
nodeanalyzer-node-analyzer-ccs8d        4/4     Running   0          9m5s
sysdig-agent-8sshw                      1/1     Running   0          5m4s
sysdig-agent-smm4c                      1/1     Running   0          9m16s
sysdig-kspmcollector-5f65cb87bb-fs78l   1/1     Running   0          9m22s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;_NOTE: As an exercise for the reader, this step can be achieved the GitOps way using Argo CD with the helm chart &lt;a href="https://argo-cd.readthedocs.io/en/stable/user-guide/helm/"&gt;https://argo-cd.readthedocs.io/en/stable/user-guide/helm/&lt;/a&gt; &lt;a href="https://github.com/argoproj/argocd-example-apps/tree/master/helm-dependency"&gt;https://github.com/argoproj/argocd-example-apps/tree/master/helm-dependency&lt;/a&gt; _&lt;/p&gt;

&lt;p&gt;After a few minutes, the agent is deployed and has reported back the Kubernetes status in the new Posture -&amp;gt; &lt;a href="https://docs.sysdig.com/en/docs/sysdig-secure/iac-security/iac-policy-controls/"&gt;“&lt;/a&gt;Actionable Compliance” section where the security requirements can be observed:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BTeU682_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/InfraAsCodeSecurity-04.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BTeU682_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/InfraAsCodeSecurity-04.png" alt="" width="880" height="458"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's fix the “Container Image Pull” policy control (see &lt;a href="https://docs.sysdig.com/en/docs/sysdig-secure/iac-security/iac-policy-controls/"&gt;the official documentation&lt;/a&gt; for the detailed list of policy controls available).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://app.storylane.io/demo/tzwdyavbyice"&gt;See it here interactively&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There, you can see the remediation proposal, a Kubernetes patch, and a “Setup Pull Request” section. But will it?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://app.storylane.io/demo/c8fhqiiju69l"&gt;See it here interactively&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Indeed! Sysdig Secure is now also able to compare the source and the runtime status of your Kubernetes objects and can even fix it for you, &lt;strong&gt;&lt;em&gt;from source to run.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;There’s no need for complex operations or manual fixes that create snowflakes. Instead, fix it at the source.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Final thoughts
&lt;/h2&gt;

&lt;p&gt;Adding IaC scanning, security, and compliance mechanisms to your toolbox will help your organization find and fix potential security issues directly at the source (&lt;em&gt;shifting security left&lt;/em&gt;) of your supply chain. Sysdig Secure can even create the remediation directly for you!&lt;/p&gt;

&lt;p&gt;Get started now with a&lt;a href="https://sysdig.com/company/start-free/"&gt; free trial &lt;/a&gt;and see for yourself.&lt;/p&gt;

</description>
      <category>infrastructureascode</category>
      <category>security</category>
    </item>
    <item>
      <title>How to apply security at the source using GitOps</title>
      <dc:creator>Edu Mínguez</dc:creator>
      <pubDate>Wed, 27 Jul 2022 09:53:19 +0000</pubDate>
      <link>https://dev.to/minwi/how-to-apply-security-at-the-source-using-gitops-21bk</link>
      <guid>https://dev.to/minwi/how-to-apply-security-at-the-source-using-gitops-21bk</guid>
      <description>&lt;p&gt;
If your &lt;strong&gt;GitOps deployment model has security issues&lt;/strong&gt; (for example, a misconfigured permission because of a typo), &lt;strong&gt;this will be propagated until it is hopefully discovered at runtime&lt;/strong&gt;, where most of the security events are scanned or found.
&lt;/p&gt;

&lt;p&gt;
&lt;a href="https://sysdig.com/wp-content/uploads/Security-source-GitOps-00.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--e3IUH5uq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Security-source-GitOps-00.png" alt="" width="880" height="485"&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;em&gt;What if you can fix potential security issues in your infrastructure at the source?&lt;/em&gt;
&lt;/p&gt;

&lt;p&gt;
Let's start with the basics.
&lt;/p&gt;

&lt;h2 id="git"&gt;What is Git?&lt;/h2&gt;

&lt;p&gt;
&lt;strong&gt;&lt;a rel="noopener nofollow noreferrer" href="https://git-scm.com/"&gt;Git&lt;/a&gt; is an open source distributed version control system&lt;/strong&gt;. It tracks changes made in files (usually text files such as source code) &lt;strong&gt;allowing and fostering a collaborative work model&lt;/strong&gt;. It is the&lt;em&gt; de facto &lt;/em&gt;standard in version control systems nowadays.
&lt;/p&gt;

&lt;p&gt;
You can have your own git repo locally on your laptop, host it on your own server, or use some provider such as GitLab or GitHub.
&lt;/p&gt;

&lt;p&gt;
There are different “flows” on how to manage a repository (git-flow, github-flow, etc.), but a basic example on how git is used is something like this: Changes in the files are “committed” by users by “forking” the repository and doing the proper changes in a “branch”.
&lt;/p&gt;

&lt;p&gt;
Then, the user creates a request (either "pull request", "merge request", or just "send a patch") to include those changes in the repository.
&lt;/p&gt;

&lt;p&gt;
After that, usually a discussion happens between the “owner” and the user creating the request, and if everything goes fine the change is accepted and added to the repository.
&lt;/p&gt;

&lt;p&gt;
NOTE: If you want to know more, &lt;a rel="noopener nofollow noreferrer" href="https://martinfowler.com/bliki/PullRequest.html"&gt;here&lt;/a&gt; is much more detailed information about the git pull request mechanism.
&lt;/p&gt;

&lt;p&gt;
To see a real world example, just browse your favorite open source GitLab or GitHub repository and browse the Pull Request (or Merge Request) tab (or see &lt;a rel="noopener nofollow noreferrer" href="https://github.com/danielmiessler/SecLists/pull/155"&gt;this&lt;/a&gt; for a fun one). You can see the proposed changes, comments, labels, who proposed the changes, tools running validations against the proposed changes, notifications sent to people watching the repository, etc.
&lt;/p&gt;

&lt;h2 id="gitops"&gt;What is GitOps?&lt;/h2&gt;

&lt;p&gt;
To put it simply, &lt;strong&gt;GitOps is just a methodology that uses a git repository as the single source of truth for your software assets&lt;/strong&gt; so you can leverage the git deployment model (pull requests, rollbacks, approvals, etc.) to your software.
&lt;/p&gt;

&lt;p&gt;
There are books (&lt;a rel="noopener nofollow noreferrer" href="https://developers.redhat.com/e-books/path-gitops"&gt;The Path to GitOps&lt;/a&gt;, &lt;a rel="noopener nofollow noreferrer" href="https://www.manning.com/books/gitops-and-kubernetes"&gt;GitOps and Kubernetes&lt;/a&gt; or &lt;a rel="noopener nofollow noreferrer" href="https://www.gitops.tech/"&gt;GitOps Cloud-native Continuous Deployment&lt;/a&gt;), &lt;a rel="noopener nofollow noreferrer" href="https://go.weave.works/automating-kubernetes-with-gitops-wp.html"&gt;whitepapers&lt;/a&gt;, and &lt;a rel="noopener nofollow noreferrer" href="https://github.com/weaveworks/awesome-gitops"&gt;more&lt;/a&gt; &lt;a rel="noopener nofollow noreferrer" href="https://www.weave.works/technologies/gitops/"&gt;blog posts&lt;/a&gt; &lt;a rel="noopener nofollow noreferrer" href="https://www.weave.works/blog/gitops-operations-by-pull-request"&gt;than&lt;/a&gt; we &lt;a rel="noopener nofollow noreferrer" href="https://www.redhat.com/en/topics/devops/what-is-gitops"&gt;can&lt;/a&gt; &lt;a href="https://sysdig.com/blog/gitops-k8s-security-configwatch/" rel="noopener"&gt;manage&lt;/a&gt; &lt;a rel="noopener nofollow noreferrer" href="https://about.gitlab.com/blog/2022/04/07/the-ultimate-guide-to-gitops-with-gitlab/"&gt;to&lt;/a&gt; &lt;a rel="noopener nofollow noreferrer" href="https://cloud.google.com/kubernetes-engine/docs/tutorials/gitops-cloud-build"&gt;count&lt;/a&gt; but let us elaborate on the GitOps purpose by taking a quick look on how things evolved in the last few years.
&lt;/p&gt;

&lt;p&gt;
Before the cloud, adding a new server to host your application took weeks. You had to ask for permissions, purchase it, and perform a lot of manual tasks. Then, virtualization made things much easier. You request a virtual machine with some specs and after a few minutes, you have access to it.
&lt;/p&gt;

&lt;p&gt;
Then, the cloud. Requesting servers, network, storage, and even databases, messaging queues, containers, machine learning stuff, serverless… is just an API call away! You request it and a few seconds later, you get it, just like that. You just need to pay for what you use. This also means the infrastructure can be managed as code performing API calls… and where do you store your code? In a git repository (or any other content version system).
&lt;/p&gt;

&lt;p&gt;
The GitOps term was coined back in &lt;a rel="noopener nofollow noreferrer" href="https://www.weave.works/blog/the-history-of-gitops"&gt;2017 by Weaveworks&lt;/a&gt;, and paraphrasing &lt;a rel="noopener nofollow noreferrer" href="https://github.com/open-gitops/documents/blob/main/PRINCIPLES.md"&gt;OpenGitOps&lt;/a&gt;, a GitOps system is based on the following principles:
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Declarative&lt;/strong&gt;: it defines “what.”
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Versioned and immutable&lt;/strong&gt;: hence “git.”
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pulled automatically&lt;/strong&gt;: an agent observes the desired state and the changes happening in the code.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Continuously reconciled&lt;/strong&gt;: did someone mention Kubernetes?
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
The &lt;strong&gt;essence of the GitOps methodology is basically a Kubernetes controller or controllers&lt;/strong&gt; (or agents) running on your cluster that observes the Kubernetes objects running on top of it (defined by a &lt;a rel="noopener nofollow noreferrer" href="https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/"&gt;CustomResource&lt;/a&gt;) &lt;strong&gt;comparing the current state against the state specified in the Git repo&lt;/strong&gt;. If it doesn't match, it &lt;em&gt;remediates&lt;/em&gt; the application by applying the manifests found in the repository.
&lt;/p&gt;

&lt;p&gt;
NOTE: There are slightly different approaches to GitOps, for example, push vs. pull, how to handle the configuration management, etc. Those are advanced topics, but for now, let's stick to the basics.
&lt;/p&gt;

&lt;p&gt;
The following diagram shows a simplified GitOps system:
&lt;/p&gt;

&lt;p&gt;
&lt;a href="https://sysdig.com/wp-content/uploads/Security-source-GitOps-01.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NcQCXoXf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Security-source-GitOps-01.png" alt="GitOps diagram showing a developer sending changes, the GitOps process and the agent deployed on Kubernetes observing the changes" width="880" height="498"&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A code change is submitted to the Git repository by the user.
&lt;/li&gt;
&lt;li&gt;Then, a process is triggered on the repository to incorporate those changes into the application itself, including running automation tools against that new code to validate it.
&lt;/li&gt;
&lt;li&gt;Once everything is in place, the GitOps agent running in the Kubernetes cluster, which is observing the repository, performs the reconciliation between the desired state (the code in the repository) and the current state (the objects running on the Kubernetes cluster itself).
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Being based on Git means frictionless for developers. They don't need to worry about a new tool to interact with, but rather apply the same practices used to manage the code in the Git repository.
&lt;/p&gt;

&lt;p&gt;
Speaking about GitOps tools, there are a few already available, including open source tools such as &lt;a rel="noopener nofollow noreferrer" href="https://www.cncf.io/projects/flux/"&gt;Flux&lt;/a&gt; or &lt;a rel="noopener nofollow noreferrer" href="https://www.cncf.io/projects/argo/"&gt;ArgoCD&lt;/a&gt;, both &lt;a rel="noopener nofollow noreferrer" href="https://www.cncf.io/projects/"&gt;CNCF incubating projects&lt;/a&gt;.
&lt;/p&gt;

&lt;p&gt;
To get a feeling on what an application definition looks like via GitOps, this is an example of a simple application (stored in a GitHub repository) managed by Flux or ArgoCD.
&lt;/p&gt;

&lt;p&gt;
With Flux:
&lt;/p&gt;

&lt;pre&gt;---
apiVersion: source.toolkit.fluxcd.io/v1beta2
kind: GitRepository
metadata:
  name: my-example-app
  namespace: hello-world
spec:
  interval: 30s
  ref:
    branch: master
  url: https://github.com/xxx/my-example-apps.git
---
apiVersion: kustomize.toolkit.fluxcd.io/v1beta2
kind: Kustomization
metadata:
  name: my-example-app
  namespace: hello-world
spec:
  interval: 5m0s
  path: ./myapp
  prune: true
  sourceRef:
    kind: GitRepository
    name: my-example-app
  targetNamespace: hello-world
&lt;/pre&gt;

&lt;p&gt;
With ArgoCD:
&lt;/p&gt;

&lt;pre&gt;apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: my-example-app
  namespace: hello-world
spec:
  destination:
    namespace: my-example-app
    server: https://kubernetes.default.svc
  project: default
  source:
    path: myapp/
    repoURL: https://github.com/xxx/my-example-apps.git
    targetRevision: HEAD
  syncPolicy:
    automated: {}
    syncOptions:
    - CreateNamespace=true
&lt;/pre&gt;

&lt;p&gt;
Both reference the Git repository where the application manifests are stored (Deployments), the NameSpaces, and a few more details.
&lt;/p&gt;

&lt;h2 id="gitops-vs-iac"&gt;GitOps vs. IaC&lt;/h2&gt;

&lt;p&gt;
&lt;strong&gt;Infrastructure as Code&lt;/strong&gt; is a methodology of treating the building blocks of your infrastructure as code using different techniques and tools. This means that instead of manually creating your infrastructure such as VMs, containers, networks, or storage via your favorite infrastructure provider web interface manually, you define them as code, and then those are created/updated/managed by the tools you choose, such as &lt;a rel="noopener nofollow noreferrer" href="https://www.terraform.io/"&gt;terraform&lt;/a&gt;, &lt;a rel="noopener nofollow noreferrer" href="https://crossplane.io/"&gt;crossplane&lt;/a&gt;, or &lt;a rel="noopener nofollow noreferrer" href="https://www.pulumi.com/"&gt;pulumi&lt;/a&gt;, among others.
&lt;/p&gt;

&lt;p&gt;
The benefits are huge. You can manage your infrastructure as if it was code (it &lt;em&gt;is&lt;/em&gt; code now) and leverage your development best practices (automation, testing, traceability, versioning control, etc.) to your infrastructure assets. In fact, there is a trend of using "Infrastructure as Software" as a term instead because it is much more than just code.
&lt;/p&gt;

&lt;p&gt;
There is tons of information out there on this topic, but the &lt;a href="https://sysdig.com/learn-cloud-native/cloud-security/what-is-infrastructure-as-code-iac-security/" rel="noopener"&gt;following resource&lt;/a&gt; is a good starting point.
&lt;/p&gt;

&lt;p&gt;
As you have probably figured, GitOps leverages Infrastructure as Code as the declarative model to define the infrastructure. In fact, IaC is one of the GitOps cornerstones! But it is much more as IaC doesn't mandate the rest of the GitOps principles.
&lt;/p&gt;

&lt;h2 id="gitops-vs-devops"&gt;GitOps vs. DevOps&lt;/h2&gt;

&lt;p&gt;
There are lots of definitions of the "DevOps" term. It depends who you ask but to put it simply, "DevOps is the combination of practices and tools to build and deliver software reducing friction and to a high speed."
&lt;/p&gt;

&lt;p&gt;
DevOps methodologies can leverage GitOps as GitOps provides a framework that matches DevOps practices but it is not strictly necessary.
&lt;/p&gt;

&lt;h2 id="noops"&gt;What about NoOps?&lt;/h2&gt;

&lt;p&gt;
NoOps was coined by Forrester in &lt;a rel="noopener nofollow noreferrer" href="https://www.forrester.com/blogs/11-02-07-i_dont_want_devops_i_want_noops/"&gt;2011&lt;/a&gt; and it is a radical approach to handling operations where the IT environment is abstracted and automated to the point there is no need to manage it manually.
&lt;/p&gt;

&lt;p&gt;
GitOps helps to reduce the manual changes by remediating those with the desired state in the Git repository, but &lt;strong&gt;applying a real NoOps to the whole IT environment is an aspirational goal rather than a real goal as of today&lt;/strong&gt;.
&lt;/p&gt;

&lt;h2 id="kubernetes"&gt;Is GitOps just for Kubernetes?&lt;/h2&gt;

&lt;p&gt;
No. Kubernetes, the &lt;a rel="noopener nofollow noreferrer" href="https://kubernetes.io/docs/concepts/architecture/controller/#controller-pattern"&gt;controller pattern&lt;/a&gt;, and the &lt;a rel="noopener nofollow noreferrer" href="https://kubernetes.io/docs/tasks/manage-kubernetes-objects/declarative-config/"&gt;declarative model&lt;/a&gt; to define Kubernetes objects are a perfect match for a GitOps methodology, but it doesn't mean GitOps methodologies cannot be applied without Kubernetes. There are a few challenges if using GitOps outside of Kubernetes, such as handling the idempotency, the deletion/creation of the assets, secrets managements, etc. But &lt;strong&gt;the GitOps principles can be applied without Kubernetes&lt;/strong&gt; (and applying a little bit of creativity).
&lt;/p&gt;

&lt;h2 id="security"&gt;GitOps &amp;amp; Security&lt;/h2&gt;

&lt;p&gt;
Let's talk about the security aspects now. Most security tools detect potential vulnerabilities and issues at runtime (too late). In order to fix them, either a reactive manual process needs to be performed (e.g., modifying directly a parameter in your k8s object with kubectl edit) or ideally, the fix will happen at source and will be propagated all along your supply chain. This is what is called “&lt;a href="https://sysdig.com/blog/shift-left-secure-software-delivery/" rel="noopener"&gt;Shift Security Left&lt;/a&gt;”. From fixing the problem when it is too late to fixing it before it happens.
&lt;/p&gt;

&lt;p&gt;
This doesn't mean every security issue can be fixed at the source, but adding a security layer directly at the source can prevent some issues.
&lt;/p&gt;

&lt;p&gt;
First of all, the general security recommendations apply.
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reduce the attack surface
&lt;/li&gt;
&lt;li&gt;Encrypt the secrets (using External Secrets or Sealed Secrets)
&lt;/li&gt;
&lt;li&gt;Network segmentation
&lt;/li&gt;
&lt;li&gt;RBAC
&lt;/li&gt;
&lt;li&gt;Keep software up to date
&lt;/li&gt;
&lt;li&gt;Enforce least privilege
&lt;/li&gt;
&lt;li&gt;Monitor &amp;amp; measure
&lt;/li&gt;
&lt;li&gt;…
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Let's see a few scenarios where the GitOps methodology can improve your security in general:
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Avoid/Refuse manual changes (avoiding Drift)&lt;/strong&gt;. The Git repository is the source of truth. If you try to modify the application definition, the GitOps tool will revert those changes by applying the version stored in the Git repository.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;a href="https://sysdig.com/wp-content/uploads/Security-source-GitOps-02.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--slrJ4I2v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Security-source-GitOps-02.png" alt="GitOps UI showing the differences between the object running on the cluster and the definition stored in the Git repository" width="880" height="458"&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;a href="https://sysdig.com/wp-content/uploads/Security-source-GitOps-03.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mXw2Oy85--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Security-source-GitOps-03.png" alt="GitOps UI showing the remediation performed because of the differences" width="880" height="151"&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Rollback changes&lt;/strong&gt;. Imagine you introduced a potential security issue in a specific commit by modifying some parameter in your application deployment. Leveraging the Git capabilities, you can rollback the change if needed directly at the source and the GitOps tool will redeploy your application without user interaction.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;a href="https://sysdig.com/wp-content/uploads/Security-source-GitOps-04.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KbWBlEV4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Security-source-GitOps-04.png" alt="GitOps UI showing the reverted changes" width="880" height="304"&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fast response.&lt;/strong&gt; If you find you are using a vulnerable container image in your application (e.g., MariaDB), you just need to create a PR to update the tag into the deployment file and the GitOps tool will use the new tag in a new deployment.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;a href="https://sysdig.com/wp-content/uploads/Security-source-GitOps-05.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5TTnJopJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Security-source-GitOps-05.png" alt="Detail of the deployment performed by the GitOps tool shown in the GitOps UI" width="880" height="304"&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Traceability.&lt;/strong&gt; Using Git capabilities, you can easily check when a file was changed, the changes themselves and the user that promoted the changes. You've got an audit log &lt;em&gt;for free&lt;/em&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;a href="https://sysdig.com/wp-content/uploads/Security-source-GitOps-06.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--S9Ow4ALf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Security-source-GitOps-06.png" alt="GitHub UI showing a log of the committed changes" width="880" height="258"&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Disaster recovery.&lt;/strong&gt; Again, the Git repository is the source of truth. If you need to redeploy your application because something happened, the definition is there (of course you need to have a disaster recovery plan for other stuff such as the data itself).
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Access Control.&lt;/strong&gt; You can apply different permissions to different users on your Git repositories and even policies such as “only merge a change after two positive reviews”.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Those benefits are good enough to justify using GitOps methodologies to improve your security posture and they came out of the box, but GitOps is a combination of a few more things. We can do much more. GitHub, GitLab, and other Git repositories providers allow you to run &lt;em&gt;actions&lt;/em&gt; or &lt;em&gt;pipelines&lt;/em&gt; based on the changes you perform in your Git repository, including by a pull request, so the possibilities are endless. A few examples:
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Linting.&lt;/strong&gt; The definition of the application &lt;em&gt;is code&lt;/em&gt;, what if the definition is checked for wrong syntax, missing parameters, and more? There are tools (such as the &lt;a rel="noopener nofollow noreferrer" href="https://github.com/oxsecurity/megalinter"&gt;megalinter&lt;/a&gt;) that can be executed against the changes you've performed so you avoid surprises later on.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;a href="https://sysdig.com/wp-content/uploads/Security-source-GitOps-07.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qLUx44mD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Security-source-GitOps-07.png" alt="Megalinter output showing the tests executed, alerts and details" width="880" height="681"&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Testing.&lt;/strong&gt; You can even automate the &lt;a rel="noopener nofollow noreferrer" href="https://github.com/marketplace/actions/kind-kubernetes-in-docker-action"&gt;creation of a temporary Kubernetes cluster&lt;/a&gt; to run your application with the changes and run some tests against it.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;a href="https://sysdig.com/wp-content/uploads/Security-source-GitOps-08.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KoOBGCJ8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Security-source-GitOps-08.png" alt="GitHub UI showing a GitHub action log deploying a Kind Kubernetes cluster" width="880" height="668"&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Vulnerability scanning&lt;/strong&gt;. By checking the &lt;a rel="noopener nofollow noreferrer" href="https://github.com/sysdiglabs/secure-inline-scan-examples/tree/main/github"&gt;container images&lt;/a&gt; you are using for vulnerabilities before they are deployed in your environment.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;a href="https://sysdig.com/wp-content/uploads/Security-source-GitOps-09.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SUUNLH04--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Security-source-GitOps-09.png" alt="GitHub UI showing a detailed view of policies checking the code directly in the pull-request" width="880" height="609"&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Policy-as-code.&lt;/strong&gt; Leveraging &lt;a rel="noopener nofollow noreferrer" href="https://github.com/open-policy-agent/setup-opa"&gt;OPA&lt;/a&gt;, you can even apply policies to your manifests to check for potential issues or custom policies
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;a href="https://sysdig.com/wp-content/uploads/Security-source-GitOps-10.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--84nGrDmZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Security-source-GitOps-10.png" alt="GitHub UI showing the output of a GitHub action running OPA policies against the change performed" width="880" height="668"&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;h2 id="conclusion"&gt;Final thoughts&lt;/h2&gt;

&lt;p&gt;
The &lt;strong&gt;GitOps methodology brings a few improvements to the deployment model&lt;/strong&gt; and &lt;strong&gt;security benefits to the table without having to add another tool&lt;/strong&gt;.
&lt;/p&gt;

&lt;p&gt;
&lt;strong&gt;It improves the security posture by adding a “shift left” layer directly to the source code&lt;/strong&gt; and thanks to the flexibility of the pull-request model, you can easily add extra security checks without affecting or modifying the runtime.
&lt;/p&gt;

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