<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Golohanikita on Medium]]></title>
        <description><![CDATA[Stories by Golohanikita on Medium]]></description>
        <link>https://medium.com/@golohanikita892?source=rss-9bd32a7b39dd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*EU09T1WSeDJekH6j</url>
            <title>Stories by Golohanikita on Medium</title>
            <link>https://medium.com/@golohanikita892?source=rss-9bd32a7b39dd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 00:02:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@golohanikita892/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Flux terraform provider]]></title>
            <link>https://medium.com/dataops-tech/flux-terraform-provider-edb68f0012c9?source=rss-9bd32a7b39dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/edb68f0012c9</guid>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[gitops]]></category>
            <category><![CDATA[flux]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Golohanikita]]></dc:creator>
            <pubDate>Mon, 05 May 2025 14:59:13 GMT</pubDate>
            <atom:updated>2025-05-05T14:59:13.719Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HsM8-KLBln0UhTaQELhCsg.png" /><figcaption>FluxCD, HashiCorp Terraform</figcaption></figure><p>In today’s cloud-native landscape, Terraform has become the standard for managing infrastructure across major cloud providers. From provisioning compute resources to configuring storage and networking, Terraform enables teams to define their entire infrastructure as code in a consistent, repeatable way.</p><p>This approach naturally extends to Kubernetes clusters, which are often provisioned and configured using Terraform modules. But what about the tools <em>inside</em> your clusters, especially GitOps controllers like <a href="https://fluxcd.io/">Flux</a>?</p><p>Flux is widely adopted as a GitOps solution for Kubernetes, enabling automated and declarative delivery of application workloads and cluster configurations. And while Flux itself promotes the idea of managing resources via Git, it might surprise some that Flux can also be managed <em>as code</em> using the Terraform Flux provider. This opens the door to managing your entire infrastructure stack from cloud resources to Kubernetes clusters to GitOps controllers, within a single Terraform workflow.</p><p>In this article, we’ll explore how the Flux Terraform provider works, and how you can use it to bring your GitOps setup under the same declarative control as the rest of your infrastructure.</p><h3>Setup EKS cluster</h3><p>To demonstrate how to manage Flux with Terraform, we’ll use a common scenario: a Kubernetes cluster running on <strong>Amazon Elastic Kubernetes Service (EKS)</strong>. EKS is a popular choice for teams using AWS, and it integrates well with Terraform through the official AWS provider and community-maintained EKS modules.</p><p>In this example, we’ll assume that you already have an EKS cluster provisioned via Terraform. If not, we’ll briefly outline the necessary steps to create one, before moving on to installing and configuring Flux using the Flux Terraform provider.</p><pre>module &quot;eks&quot; {<br>  source  = &quot;terraform-aws-modules/eks/aws&quot;<br>  version = &quot;~&gt; 20.0&quot;<br><br>  cluster_name    = &quot;example&quot;<br>  cluster_version = &quot;1.31&quot;<br><br>  bootstrap_self_managed_addons = false<br>  cluster_addons = {<br>    coredns = {<br>      most_recent = true<br>    }<br>    kube-proxy = {<br>      most_recent = true<br>    }<br>    vpc-cni = {<br>      most_recent = true<br>    }<br>    aws-ebs-csi-driver = {<br>      most_recent = true<br>    }<br>  }<br><br>  # Optional<br>  cluster_endpoint_public_access = true<br><br>  # Optional: Adds the current caller identity as an administrator via cluster access entry<br>  enable_cluster_creator_admin_permissions = true<br><br>  vpc_id                   = &quot;vpc-1234556abcdef&quot;<br>  subnet_ids               = [&quot;subnet-abcde012&quot;, &quot;subnet-bcde012a&quot;, &quot;subnet-fghi345a&quot;]<br>  control_plane_subnet_ids = [&quot;subnet-xyzde987&quot;, &quot;subnet-slkjf456&quot;, &quot;subnet-qeiru789&quot;]<br><br>  # EKS Managed Node Group(s)<br>  eks_managed_node_group_defaults = {<br>    instance_types = [&quot;m6i.large&quot;, &quot;m5.large&quot;, &quot;m5n.large&quot;, &quot;m5zn.large&quot;]<br>  }<br><br>  eks_managed_node_groups = {<br>    example = {<br>      # Starting on 1.30, AL2023 is the default AMI type for EKS managed node groups<br>      ami_type       = &quot;AL2023_x86_64_STANDARD&quot;<br>      instance_types = [&quot;m5.xlarge&quot;]<br><br>      min_size     = 2<br>      max_size     = 10<br>      desired_size = 2<br>    }<br>  }<br><br>  tags = {<br>    Environment = &quot;dev&quot;<br>    Terraform   = &quot;true&quot;<br>  }<br>}</pre><h3>Setup Github ssh</h3><p>Flux connects to your Git repository to pull manifests and synchronize your cluster state. While it supports multiple authentication methods, <strong>SSH is the most common and secure choice</strong> for private repositories.</p><p>To enable this, Flux requires an SSH deploy key to authenticate with GitHub. In a typical setup, you would generate a key pair manually and configure it both in Flux and on GitHub. But with the <strong>Flux Terraform provider</strong>, we can automate this process entirely, generating the key, provisioning it into Flux, and registering the public key in your GitHub repo using the <strong>Terraform GitHub provider</strong>.</p><p>This ensures a fully automated and reproducible GitOps setup with no manual key handling.</p><pre>provider &quot;github&quot; {<br>  owner = &quot;your-github-owner&quot;<br>  token = &quot;your-github-token&quot;<br>}<br><br>resource &quot;tls_private_key&quot; &quot;flux&quot; {<br>  algorithm   = &quot;ECDSA&quot;<br>  ecdsa_curve = &quot;P256&quot;<br>}<br><br>resource &quot;github_repository_deploy_key&quot; &quot;this&quot; {<br>  title      = &quot;Flux&quot;<br>  repository = var.github_repository<br>  key        = tls_private_key.flux.public_key_openssh<br>  read_only  = &quot;false&quot;<br>}</pre><h3>Setup flux terraform provider</h3><p>At this stage, we’re ready to configure the <strong>Flux Terraform provider</strong>. This is where we connect to both our <strong>Kubernetes cluster</strong> and the <strong>Git repository</strong>, and define how Flux should operate.</p><p>Using the provider, we specify:</p><ul><li>the Kubernetes cluster context (via kubernetes provider or kubeconfig),</li><li>the Git repository to sync from (typically over SSH),</li><li>the <strong>directory path</strong> within the repository that contains the Kubernetes manifests.</li></ul><p>This allows you to declaratively manage Flux resources such as GitRepository, Kustomization, and others from Terraform. With this setup, any changes to the repository or sync settings can be tracked and applied through Terraform, giving you full control over your GitOps pipeline.</p><pre>data &quot;aws_eks_cluster&quot; &quot;cluster&quot; {<br>  name = module.eks.cluster_name<br>}<br><br>data &quot;aws_eks_cluster_auth&quot; &quot;cluster&quot; {<br>  name = module.eks.cluster_name<br>}<br>provider &quot;flux&quot; {<br>  kubernetes = {<br>    host                   = module.eks.cluster_endpoint<br>    cluster_ca_certificate = base64decode(module.eks.cluster_certificate_authority_data)<br>    exec = {<br>      api_version = &quot;client.authentication.k8s.io/v1beta1&quot;<br>      args        = [&quot;eks&quot;, &quot;get-token&quot;, &quot;--cluster-name&quot;, module.eks.cluster_name]<br>      command     = &quot;aws&quot;<br>    }<br>  }<br>  git = {<br>    url = &quot;your-ssh-github-url&quot;<br>    ssh = {<br>      username    = &quot;git&quot;<br>      private_key = tls_private_key.flux.private_key_pem<br>    }<br>  } <br>}<br><br>resource &quot;flux_bootstrap_git&quot; &quot;flux&quot; {<br>  embedded_manifests = true<br>  path               = &quot;flux&quot;<br>}</pre><h3>Deploy manifest to cluster</h3><p>After deploying the initial manifests to the Kubernetes cluster, we enable a GitOps workflow. Any changes to the manifests can simply be pushed to the Git repository, and they will be <strong>automatically applied</strong> to the cluster.</p><p>As a result we have:</p><ul><li>the Git repository becomes the <strong>single source of truth</strong> for cluster state;</li><li>every commit represents a <strong>declarative change</strong> to the infrastructure;</li><li>this ensures <strong>transparency</strong>, <strong>version control</strong>, and <strong>easy recovery</strong>.</li></ul><pre>apiVersion: v1<br>kind: Namespace<br>metadata:<br>  name: test<br>---<br>apiVersion: v1<br>kind: ConfigMap<br>metadata:<br>  creationTimestamp: null<br>  name: test<br>  namespace: test<br>data:<br>  test.json: |<br>    {<br>      &quot;test&quot; : test<br>    }</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8WFk_HtjHJpdfictLbRT2A.png" /></figure><h3><strong>Conclusion</strong></h3><p>Managing Flux with Terraform is a great way to bring your entire GitOps setup under the same declarative control as the rest of your infrastructure. Instead of juggling separate tools and manual steps, you get a streamlined, reproducible workflow from spinning up an EKS cluster to syncing your manifests from GitHub.</p><p>This approach not only simplifies operations, but also gives your team a single source of truth for everything that runs in your cloud and Kubernetes environments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=edb68f0012c9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dataops-tech/flux-terraform-provider-edb68f0012c9">Flux terraform provider</a> was originally published in <a href="https://medium.com/dataops-tech">DataOps.tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>