<?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: Amit Chaturvedi</title>
    <description>The latest articles on DEV Community by Amit Chaturvedi (@amit_chaturvedi_f4ca8f532).</description>
    <link>https://dev.to/amit_chaturvedi_f4ca8f532</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%2F2354524%2F828f473f-4095-4673-a52a-ead559f8b644.png</url>
      <title>DEV Community: Amit Chaturvedi</title>
      <link>https://dev.to/amit_chaturvedi_f4ca8f532</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/amit_chaturvedi_f4ca8f532"/>
    <language>en</language>
    <item>
      <title>Terraform Atlantis: GitOps-Driven Infrastructure Management</title>
      <dc:creator>Amit Chaturvedi</dc:creator>
      <pubDate>Mon, 28 Jul 2025 12:54:30 +0000</pubDate>
      <link>https://dev.to/amit_chaturvedi_f4ca8f532/terraform-atlantis-gitops-driven-infrastructure-management-e5j</link>
      <guid>https://dev.to/amit_chaturvedi_f4ca8f532/terraform-atlantis-gitops-driven-infrastructure-management-e5j</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy66bbujwlgu83dsj6dgv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy66bbujwlgu83dsj6dgv.png" alt=" " width="800" height="355"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Infrastructure as Code (IaC) has revolutionized how we manage cloud infrastructure. Terraform, being one of the most popular IaC tools, allows declarative, repeatable, and version-controlled infrastructure provisioning. However, as teams grow, managing Terraform execution securely and collaboratively becomes challenging.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Atlantis solves this by bringing Terraform into your GitOps workflow. In this post, we’ll explore what Atlantis is, how it works, why it’s useful, and how to set it up.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Atlantis?&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Atlantis is an open-source tool that automates Terraform workflows via pull requests. It listens to Git events (PRs, pushes, etc.) and triggers Terraform commands such as plan and apply automatically in response to PR comments.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Core Features:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Git-based Terraform automation&lt;/li&gt;
&lt;li&gt;PR-based infrastructure change visibility&lt;/li&gt;
&lt;li&gt;Secure plan and apply in CI/CD pipelines&lt;/li&gt;
&lt;li&gt;Team collaboration with role-based approvals_&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How Atlantis Works&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PR Creation:&lt;/strong&gt; &lt;em&gt;A developer creates a &lt;strong&gt;pull request&lt;/strong&gt; with Terraform changes.&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Atlantis Webhook Triggered:&lt;/strong&gt; &lt;em&gt;Atlantis detects the &lt;strong&gt;PR&lt;/strong&gt; via a Git webhook.&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Terraform Plan:&lt;/strong&gt; &lt;em&gt;Atlantis runs terraform plan and comments the output on the PR.&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Approval:&lt;/strong&gt; &lt;em&gt;A reviewer comments &lt;strong&gt;atlantis apply&lt;/strong&gt; once satisfied with the plan.&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Terraform Apply:&lt;/strong&gt; &lt;em&gt;Atlantis applies the changes using terraform &lt;strong&gt;apply&lt;/strong&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisite&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Storage (I am Using Longhorn)&lt;/li&gt;
&lt;li&gt; MINIO (Object Storage) &lt;/li&gt;
&lt;li&gt; Kubernetes&lt;/li&gt;
&lt;li&gt; Atlantis (Open-source tool used to automate Terraform workflows)&lt;/li&gt;
&lt;li&gt; Istio/Ingress (For Exposing Atlantis)&lt;/li&gt;
&lt;li&gt; Gitlab&lt;/li&gt;
&lt;li&gt; AWS Free Tier&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;** Generate Random Token**&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;head -c 32 /dev/urandom | base64
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Create Secret for Minio&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: v1
kind: Secret
metadata:
  name: minio-credentials
type: Opaque
stringData:
  access_key: &amp;lt;access_key&amp;gt;
  secret_key: &amp;lt;access_secret&amp;gt;

# kubectl apply -f minio.yml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Create values.yml&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;environmentSecrets:
  # MinIO Credentials for remote backend
  - name: MINIO_ACCESS_KEY_ID
    secretKeyRef:
        name: minio-credentials
        key: access_key
  - name: MINIO_SECRET_ACCESS_KEY
    secretKeyRef:
        name: minio-credentials
        key: secret_key

gitlab:
  user: "champ25"
  token: "&amp;lt;gitlab-token&amp;gt;"
  secret: "&amp;lt;random-secret&amp;gt;"
  hostname: "gitlab.com"
aws:
   credentials: |
     [default]
     aws_access_key_id=&amp;lt;AWS ACCESS KEY&amp;gt;
     aws_secret_access_key=&amp;lt;AWS SECRET KEY&amp;gt;
   directory: "/home/atlantis/.aws"
repoConfig: |-                                     
    - id: gitlab.com/infrastructure149/*
      apply_requirements: [approved, mergeable]
      import_requirements: [approved, mergeable]
      workflow: default
      allowed_overrides: [workflow, apply_requirements]
      allow_custom_workflows: true
      workflows:
         default:
            plan:
             steps:
              - run: |
                  terraform init -reconfigure\
                    -input=false \
                    -backend-config="bucket=terraform-statefile" \
                    -backend-config="key=envs/dev/terraform.tfstate" \
                    -backend-config="region=us-east-1" \
                    -backend-config="access_key=${MINIO_ACCESS_KEY_ID}" \
                    -backend-config="secret_key=${MINIO_SECRET_ACCESS_KEY}" \
                    -backend-config="skip_credentials_validation=true" \
                    -backend-config="skip_metadata_api_check=true" \
                    -backend-config="force_path_style=true" \
                    -backend-config="skip_requesting_account_id=true" \
                    -backend-config="force_path_style=true" \
                    -backend-config="endpoint=https://minioapi.kubeopscloud.uk"
                  terraform plan -input=false

            apply:
             steps:
               - run: |
                   terraform apply -input=false --auto-approve
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Install Atlantis&lt;/strong&gt;&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 runatlantis https://runatlantis.github.io/helm-charts
helm install atlantis runatlantis/atlantis \
  --namespace atlantis -f values.yaml \
  --create-namespace
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;&lt;strong&gt;Expose via Istio to access from Gitlab&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd5lsupb46ufumu5dh6tf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd5lsupb46ufumu5dh6tf.png" alt=" " width="800" height="57"&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;root@master:~# kubectl exec -ti atlantis-0 -n atlantis -- printenv | grep -i webhook
ATLANTIS_GITLAB_WEBHOOK_SECRET=0adfa526cfdgdgsgsdhsdgtewsgsfgsdhshgsgsd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Copy the Webhook Secret to Use in Gitlab&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Login To Gitlab&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Create A Project :&lt;/strong&gt; &lt;em&gt;VPC Creation&lt;/em&gt;&lt;br&gt;
&lt;em&gt;Copy The Terraform Code to VPC Creation Project&lt;/em&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;em&gt;Click On Setting&lt;/em&gt; --&amp;gt; &lt;em&gt;Click Webhook&lt;/em&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;em&gt;Note :&lt;/em&gt; Copy the Webhook Token&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Create A Branch and Create MR&lt;/strong&gt;&lt;br&gt;
_As soon as we create ME, Atlatis Webhook will get triggered&lt;br&gt;
_&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0viykdkvf2ufl5mmlgqd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0viykdkvf2ufl5mmlgqd.png" alt=" " width="800" height="442"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Click On Show Output and we will see the plan&lt;/em&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;em&gt;If Plan Looks Good, type atlantis apply -d . in commit message&lt;/em&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;em&gt;Wait For Some Time and you Will See Output&lt;/em&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;em&gt;Click On Show Output&lt;/em&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;We have Sucessfully Integrated Atlantis to create workflow with Terraform using Gitlab&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Verify state file in Minio&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fajagxqnxidagzvzn5l23.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fajagxqnxidagzvzn5l23.png" alt=" " width="800" height="184"&gt;&lt;/a&gt; &lt;br&gt;
&lt;em&gt;Successfully state file updated in Minio Storage&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Atlantis brings safety, visibility, and collaboration to Terraform workflows by integrating with Git. With pull request automation, it enables true GitOps-style infrastructure management — ensuring all changes are reviewed, tracked, and auditable.&lt;/em&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Automate your Infrastructure on AWS using Terraform Controller and FluxCD</title>
      <dc:creator>Amit Chaturvedi</dc:creator>
      <pubDate>Sun, 11 May 2025 11:07:32 +0000</pubDate>
      <link>https://dev.to/amit_chaturvedi_f4ca8f532/automate-your-infrastructure-on-aws-using-terraform-controller-and-fluxcd-47e0</link>
      <guid>https://dev.to/amit_chaturvedi_f4ca8f532/automate-your-infrastructure-on-aws-using-terraform-controller-and-fluxcd-47e0</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;In the age of cloud-native operations, infrastructure automation is no longer optional—it's essential. While tools like Terraform have long been the standard for Infrastructure as Code (IaC), integrating them into a GitOps workflow brings unprecedented control, traceability, and scalability. In this blog, we'll explore how to automate your AWS infrastructure using Terraform Controller (from the Crossplane ecosystem) and FluxCD, leveraging Git as the single source of truth.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Terraform Controller + FluxCD?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Terraform Controller:&lt;/strong&gt; &lt;em&gt;A Kubernetes controller that allows you to manage Terraform executions through Custom Resource Definitions (CRDs).&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;FluxCD:&lt;/strong&gt; &lt;em&gt;A GitOps toolkit that automates Kubernetes deployments by syncing Git repositories with clusters.&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitOps Benefits:&lt;/strong&gt; &lt;em&gt;Version control, audit trails, CI/CD integration, and reduced configuration drift.&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Before you begin, ensure you have the following:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;A Kubernetes cluster (EKS,AKS,GKS,On-Prem or local like KinD)&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;AWS credentials with necessary IAM permissions&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;kubectl, flux, and terraform controller installed&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;A Git repository for storing Terraform manifests&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step-by-Step Guide&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Install Kind Cluster&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#cat config.yaml 
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#kind create cluster --config=config.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;&lt;strong&gt;Install flux cli&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#brew install fluxcd/tap/flux
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://fluxcd.io/flux/installation/" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;BootStrap fluxcd to install flux-system with gitrepo infra-demo&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F11hd0buj0v6hm4chiior.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F11hd0buj0v6hm4chiior.png" alt="Image description" width="800" height="270"&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;#flux bootstrap gitlab   --token-auth   --owner=infra-demo2   --repository=flux-system   --branch=main   --path=clusters/dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;&lt;strong&gt;A namespace name flux-system will be created with required components&lt;/strong&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 ns
#kubectl get all -n flux-system
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;&lt;strong&gt;Lets Install Terraform Controller&lt;/strong&gt;&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 tofu-controller https://flux-iac.github.io/tofu-controller

#helm upgrade -i tofu-controller tofu-controller/tf-controller \
    --namespace flux-system
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;&lt;strong&gt;Lets Verify Controller in flux-system&lt;/strong&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 pods -n flux-system | grep tf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;&lt;strong&gt;Create infrastructure project inside infra-demo repo and map Source list and Kustamization to infra-demo repository to managed by Flux-cd&lt;/strong&gt;  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F03uohxzzy5duehvzx9fd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F03uohxzzy5duehvzx9fd.png" alt="Image description" width="800" height="328"&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;#cat infra-demo.yaml
apiVersion: source.toolkit.fluxcd.io/v1beta1
kind: GitRepository
metadata:
  name: vpc-creation
  namespace: flux-system
spec:
  interval: 30s
  url: https://gitlab.com/infra-demo2/infrastructure.git
  ref:
    branch: main
  secretRef:
    name: flux-system
---
apiVersion: kustomize.toolkit.fluxcd.io/v1beta2
kind: Kustomization
metadata:
  name: vpc-creation
  namespace: flux-system
spec:
  prune: true
  interval: 2m
  path: ./      
  sourceRef:
    kind: GitRepository
    name: vpc-creation
  timeout: 3m
  healthChecks:
    - apiVersion: infra.contrib.fluxcd.io/v1alpha1
      kind: Terraform
      name: vpc-creation
      namespace: flux-system
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Lets Create terraform Code in Infrastructure Project to deploy VPC in AWS Account&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#cat main.tf
resource "aws_vpc" "main" {
  cidr_block           = var.vpc_cidr
  enable_dns_support   = true
  enable_dns_hostnames = true
  tags = {
    Name = "${var.project}-vpc"
  }
}

resource "aws_subnet" "public" {
  count             = length(var.public_subnets)
  vpc_id            = aws_vpc.main.id
  cidr_block        = var.public_subnets[count.index]
  availability_zone = element(var.availability_zones, count.index)
  map_public_ip_on_launch = true
  tags = {
    Name = "${var.project}-public-subnet-${count.index + 1}"
  }
}

resource "aws_internet_gateway" "igw" {
  vpc_id = aws_vpc.main.id
  tags = {
    Name = "${var.project}-igw"
  }
}

resource "aws_route_table" "public" {
  vpc_id = aws_vpc.main.id
  tags = {
    Name = "${var.project}-public-rt"
  }
}

resource "aws_route" "internet_access" {
  route_table_id         = aws_route_table.public.id
  destination_cidr_block = "0.0.0.0/0"
  gateway_id             = aws_internet_gateway.igw.id
}

resource "aws_route_table_association" "public_assoc" {
  count          = length(var.public_subnets)
  subnet_id      = aws_subnet.public[count.index].id
  route_table_id = aws_route_table.public.id
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#cat outputs.tf
output "vpc_id" {
  value = aws_vpc.main.id
}

output "public_subnet_ids" {
  value = aws_subnet.public[*].id
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#cat variables.tf
variable "aws_region" {
  default = "us-east-1"
}

variable "project" {
  default = "demo"
}

variable "vpc_cidr" {
  default = "10.0.0.0/16"
}

variable "public_subnets" {
  default = ["10.0.1.0/24", "10.0.2.0/24"]
}

variable "availability_zones" {
  default = ["us-east-1a", "us-east-1b"]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; &lt;em&gt;Not Recommended&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#cat provider.tf
provider "aws" {
  region     = var.aws_region
  access_key = "XXXXXXXXXX"
  secret_key = "YYYYYYYYYYYYYY"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now Create Terraform Controller to Deploy Terraform Code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#cat terraform.yaml
apiVersion: infra.contrib.fluxcd.io/v1alpha1
kind: Terraform
metadata:
  name: vpc-creation
  namespace: flux-system
spec:
  interval: 1m
  approvePlan: auto
  path: ./                     
  sourceRef:
    kind: GitRepository
    name: vpc-creation
    namespace: flux-system  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Now the Repo will look Like&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2mphdbbvjvr3de474vgf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2mphdbbvjvr3de474vgf.png" alt="Image description" width="800" height="443"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Now Lets Deploy infrademo.yaml to Map Repo to get managed by flux-system&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#flux get sources all | grep vpc-creation

#flux get kustomization | grep vpc-creation

# kubectl apply -f infrademo.yaml

#flux get sources all | grep vpc-creation

#flux get sources all | grep vpc-creation
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;&lt;strong&gt;Once we Deploy it Terraform Controller is going to Create a runner with name of vpc-creation-tf-runner which is going to deploy the resources in AWS&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Lets verify the log of the runner&lt;/strong&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 logs vpc-creation-tf-runner -n flus-system -f
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;&lt;strong&gt;Congratulations:&lt;/strong&gt; &lt;em&gt;We have deployed our resource successfully&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lets Verify from the AWS Portal&lt;/strong&gt;&lt;/p&gt;

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

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

</description>
      <category>terraform</category>
      <category>fluxcd</category>
      <category>gitop</category>
      <category>gitlab</category>
    </item>
    <item>
      <title>Automate your Deployments on Kubernetes using FluxCD</title>
      <dc:creator>Amit Chaturvedi</dc:creator>
      <pubDate>Thu, 08 May 2025 19:10:31 +0000</pubDate>
      <link>https://dev.to/amit_chaturvedi_f4ca8f532/gitops-with-fluxcd-and-kubernetes-controllers-1k9f</link>
      <guid>https://dev.to/amit_chaturvedi_f4ca8f532/gitops-with-fluxcd-and-kubernetes-controllers-1k9f</guid>
      <description>&lt;p&gt;&lt;em&gt;In the ever-evolving world of Kubernetes, automation and consistency are key. Enter FluxCD, a powerful GitOps tool designed to simplify and supercharge your deployment pipelines. When paired with custom Kubernetes controllers, Flux can orchestrate even the most complex deployment flows. Let’s dive into how you can use FluxCD alongside Kubernetes controllers to build a robust, automated, and Git-driven infrastructure&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What Is FluxCD?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;FluxCD is a CNCF-graduated open-source GitOps tool that automatically synchronizes the desired state of your Kubernetes cluster with configuration stored in Git repositories. It continuously monitors the Git repo and reconciles the live state of Kubernetes resources with what’s defined in Git.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Combine FluxCD with Kubernetes Controllers?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Kubernetes controllers are control loops that watch the state of your cluster and attempt to move the current state toward the desired state.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Components of FluxCD&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Source Controller:&lt;/strong&gt; Monitors Git repositories or Helm repositories.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Kustomize Controller:&lt;/strong&gt; Applies manifests using Kustomize.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Helm Controller:&lt;/strong&gt; Handles Helm releases.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Image Automation Controller:&lt;/strong&gt; Watches image registries and updates manifests.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Notification Controller:&lt;/strong&gt; Sends alerts or takes action based on events.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Prerequisite&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Kubernetes Cluster Up and Running&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Gitlab Repository&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;PAT Token&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Deploy Token&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Install the Flux CLI&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -s https://fluxcd.io/install.sh | sudo bash
. &amp;lt;(flux completion bash)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;&lt;strong&gt;Flux bootstrap for GitLab&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The flux bootstrap gitlab command deploys the Flux controllers on a Kubernetes cluster and configures the controllers to sync the cluster state from a Gitlab repository. Besides installing the controllers, the bootstrap command pushes the Flux manifests to the Gitlab repository and configures Flux to update itself from Git.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;After running the bootstrap command, any operation on the cluster (including Flux upgrades) can be done via Git push, without the need to connect to the Kubernetes cluster.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://fluxcd.io/flux/installation/bootstrap/gitlab/" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Create Deploy Token&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Group Name -&amp;gt; Setting -&amp;gt; Repository -&amp;gt; Default Token -&amp;gt; Add Token&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Create flux-system namespace&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Bootstrap Command to Create flux-cd controller&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;flux bootstrap gitlab --token-auth --owner=&amp;lt;group-name&amp;gt; --repository=flux-systemtest --branch=main --path=clusters/dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;&lt;strong&gt;Verify the component in flux-system namespace&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fshcuom4ws4nsksye3y1g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fshcuom4ws4nsksye3y1g.png" alt="Image description" width="800" height="268"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Verify the repository flux-systemtest must be created&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;gotk-components.yaml&lt;/strong&gt; file is a pre-generated manifest used by FluxCD to install its core components into your Kubernetes cluster.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;gotk-sync.yaml&lt;/strong&gt; is another key Flux file — it's the manifest that tells Flux where and how to sync your cluster state from Git.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;kustomization.yaml&lt;/strong&gt; is used to declare how to apply a specific folder of Kubernetes manifests from your Git repository.
 This file is read by the Flux kustomize-controller, and it tells Flux:

&lt;ul&gt;
&lt;li&gt;Which directory in your repo to apply&lt;/li&gt;
&lt;li&gt;How often to check for changes&lt;/li&gt;
&lt;li&gt;Whether to prune deleted resources&lt;/li&gt;
&lt;li&gt;Whether to validate the manifests&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Lets Deploy Application in Kubernetes using Flux-cd&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Create a folder under flux-systemtest/clusters/dev/demo-1&lt;/em&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Create Kubernetes related file under demo-1 dir and commit the code&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;deployment.yaml&lt;/li&gt;
&lt;li&gt;service.yaml&lt;/li&gt;
&lt;li&gt;namespace.yaml&lt;/li&gt;
&lt;li&gt;dockerced.yaml&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;&lt;strong&gt;Note :&lt;/strong&gt; &lt;em&gt;As soon we commit the code it should create the resources&lt;/em&gt;&lt;/p&gt;

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

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

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

&lt;p&gt;&lt;em&gt;Lets update the image version 2 in deployment file and see the new deployment and access from the browser&lt;/em&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;em&gt;New Code Deployed once commit the code&lt;/em&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Congratulations:&lt;/strong&gt; &lt;em&gt;Using FluxCD we have successfully automated the Kubernetes deployments.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; &lt;em&gt;Next we will see how to automate infrastructure deployment using terraform and flux cd&lt;/em&gt; &lt;/p&gt;

</description>
      <category>gitop</category>
      <category>fluxcd</category>
      <category>kubernetes</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
