GithubHelp home page GithubHelp logo

smana / demo-tofu-controller Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 261 KB

Demo of the Opentofu controller

Home Page: https://flux-iac.github.io/tofu-controller/

HCL 92.54% Shell 7.46%
gitops infrastructure-as-code kubernetes

demo-tofu-controller's Introduction

Demo Opentofu Controller

โ„น๏ธ Blog post written in 2022

๐Ÿšง The second part is being written and will be soon available ....

This repository is dedicated to showcasing the Flux Opentofu Controller, a tool designed to bridge the gap between Kubernetes and cloud resource management. By leveraging the power and the flexibility of Opentofu modules, the Flux Controller enables seamless management of cloud infrastructure directly from within a Kubernetes cluster. Set within an Amazon EKS cluster, this demonstration provides a hands-on example of deploying the tofu-controller and configuring it to manage resources effectively. The core configurations and examples reside in infrastructure/controlplane-0/tofu-controller.

๐Ÿ”„ Flux Dependencies matter

graph TD;
    Namespaces-->CRDs;
    CRDs-->Observability;
    CRDs-->CloudResources;
    CloudResources-->Security;
    Security-->Applications;
Loading

This diagram can be hard to understand so these are the key information:

  • Namespaces are the first resources to be created, all other resources may be namespace scoped
  • CRDs that allow to extend Kubernetes capabilities must be present in order to use them in all other applications when needed (Including Tofu controller CRDs)
  • Cloud resources may be required by applications. For instance the EPI give permissions to AWS services.
  • Security defines external-secrets that are needed by some applications in order to start.

๐Ÿš€ Deploy the ControlPlane

Tailscale Terraform Issue Workaround

Due to a known issue with Tailscale and Terraform integration as outlined in Tailscale issue #182, the Access Control Lists (ACLs) must be imported manually before proceeding with the Terraform apply. This step ensures that the ACLs are properly recognized by Terraform's state management, avoiding conflicts or errors during the infrastructure deployment process.

Importing ACLs

First, navigate to the terragrunt/network directory where the Terraform network configuration is located. Use the following command to import the existing Tailscale ACLs into your Terraform state.

cd terragrunt/network
terragrunt import --var-file variables.tfvars tailscale_acl.this acl

Deploying Infrastructure with Terragrunt

Once the ACLs are imported, you can proceed with deploying your infrastructure. The deployment includes three main modules as visualized below:

graph LR;
    Network-->EKS;
    EKS-->TofuAWS["Tofu controller AWS requirements"];
Loading
  • Network: This module sets up the Virtual Private Cloud (VPC), subnets, and the Tailscale subnet router necessary for private connections within the infrastructure. For more information on configuring Tailscale in a VPC environment, refer to my previous blog post on Tailscale.

  • EKS: This module deploys an Elastic Kubernetes Service (EKS) cluster, configures Karpenter for efficient node provisioning, and bootstraps Flux for GitOps-based cluster management.

  • Tofu Controller AWS Requirements: Sets up the required IAM permissions for the Tofu controller to manage AWS Cloud resources. It also involves the creation of a secret used by the "Branch Planner".

To deploy all modules and apply the configuration changes, use the following Terragrunt command:

cd terragrunt/tofu-controller
terragrunt run-all apply

โš ๏ธ Gateway API is used here, exposing services publicly for the demo. For production use cases, these platform tools should be accessed through a secure wire.

๐Ÿงช CI

2 things are checked

  • The Opentofu code quality, conformance and security using pre-commit-terraform.
  • The kustomize and Kubernetes conformance using kubeconform and building the kustomize configuration.

In order to run the CI checks locally just run the following command

โ„น๏ธ It requires task to be installed

 task check

The same tasks are run in Github Actions.

demo-tofu-controller's People

Contributors

smana avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

demo-tofu-controller's Issues

Renovate Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Pending Approval

These branches will be created by Renovate only once you click their checkbox below.

  • chore(deps): update dependency helmrelease to helm.toolkit.fluxcd.io/v2
  • chore(deps): update dependency helmrepository to source.toolkit.fluxcd.io/v1
  • chore(deps): update helm release kube-prometheus-stack to v57.2.1
  • chore(deps): update terraform tls to v4.0.6
  • chore(deps): update bitnami/kubectl docker tag to v1.31.1
  • chore(deps): update dependency flux2 to v2.3.0
  • chore(deps): update dependency gateway-api to v1.1.0
  • chore(deps): update dependency terraform-aws-acm to v5.1.0
  • chore(deps): update dependency terraform-aws-eks-pod-identity to v1.4.1
  • chore(deps): update dependency terraform-aws-iam to v5.44.0
  • chore(deps): update dependency terraform-aws-vpc to v5.13.0
  • chore(deps): update dependency terragrunt to v0.67.9
  • chore(deps): update dependency tflint to v0.53.0
  • chore(deps): update helm release cert-manager to v1.15.3
  • chore(deps): update helm release external-secrets to v0.10.3
  • chore(deps): update terraform flux to v1.3.0
  • chore(deps): update terraform smana/tailscale-subnet-router/aws to v1.1.0
  • chore(deps): update terraform tailscale to ~> 0.17
  • chore(deps): update terraform terraform-aws-modules/iam/aws to v5.44.0
  • chore(deps): update terragrunt dependency terraform-aws-modules/eks-pod-identity/aws to v1.4.1
  • chore(deps): update tflint plugin terraform-linters/tflint-ruleset-aws to v0.33.0
  • chore(deps): update dependency terraform-aws-route53 to v4
  • chore(deps): update helm release kube-prometheus-stack to v62
  • chore(deps): update helm release prometheus-operator-crds to v14
  • chore(deps): update terraform aws to v5
  • chore(deps): update terraform terraform-aws-modules/route53/aws to v4
  • ๐Ÿ” Create all pending approval PRs at once ๐Ÿ”

Detected dependencies

asdf
.tool-versions
  • tflint 0.50.3
  • terragrunt 0.55.20
  • flux2 2.2.3
flux
crds/base/external-secrets/source.yaml
  • external-secrets v0.9.13
crds/base/gateway-api/source.yaml
  • gateway-api v1.0.0
crds/base/prometheus-operator/helmrelease.yaml
  • prometheus-operator-crds 10.0.0
crds/base/tofu-controller/source.yaml
  • tofu-controller v0.16.0-rc.4
flux-config/base/capacitor/source.yaml
infrastructure/base/aws-load-balancer-controller/helmrelease.yaml
infrastructure/base/external-dns/helmrelease.yaml
infrastructure/controlplane-0/tofu-controller/controller/release.yaml
infrastructure/controlplane-0/tofu-controller/controller/source.yaml
infrastructure/controlplane-0/tofu-controller/sources/demo-tofu-controller.yaml
infrastructure/controlplane-0/tofu-controller/sources/terraform-aws-acm.yaml
  • terraform-aws-acm v5.0.1
infrastructure/controlplane-0/tofu-controller/sources/terraform-aws-epi.yaml
  • terraform-aws-eks-pod-identity v1.1.0
infrastructure/controlplane-0/tofu-controller/sources/terraform-aws-iam.yaml
  • terraform-aws-iam v5.37.2
infrastructure/controlplane-0/tofu-controller/sources/terraform-aws-route53.yaml
  • terraform-aws-route53 v2.11.1
infrastructure/controlplane-0/tofu-controller/sources/terraform-aws-vpc.yaml
  • terraform-aws-vpc v5.7.0
observability/base/kube-prometheus-stack/helmrelease.yaml
  • kube-prometheus-stack 57.2.0
security/base/cert-manager/helmrelease.yaml
  • cert-manager v1.14.4
security/base/external-secrets/helmrelease.yaml
  • external-secrets 0.9.13
github-actions
.github/workflows/ci.yaml
  • actions/checkout v4
  • arduino/setup-task v1
.github/workflows/manifests.yaml
  • actions/checkout v4
.github/workflows/pr-agent.yaml
kubernetes
crds/base/cert-manager/crds.yaml
  • CustomResourceDefinition apiextensions.k8s.io/v1
  • CustomResourceDefinition apiextensions.k8s.io/v1
  • CustomResourceDefinition apiextensions.k8s.io/v1
  • CustomResourceDefinition apiextensions.k8s.io/v1
  • CustomResourceDefinition apiextensions.k8s.io/v1
  • CustomResourceDefinition apiextensions.k8s.io/v1
crds/base/cert-manager/kustomization.yaml
  • Kustomization kustomize.config.k8s.io/v1beta1
crds/base/external-secrets/crds.yaml
  • Kustomization kustomize.toolkit.fluxcd.io/v1
crds/base/external-secrets/kustomization.yaml
  • Kustomization kustomize.config.k8s.io/v1beta1
crds/base/external-secrets/source.yaml
  • GitRepository source.toolkit.fluxcd.io/v1
crds/base/gateway-api/crds.yaml
  • Kustomization kustomize.toolkit.fluxcd.io/v1
crds/base/gateway-api/kustomization.yaml
  • Kustomization kustomize.config.k8s.io/v1beta1
crds/base/gateway-api/source.yaml
  • GitRepository source.toolkit.fluxcd.io/v1
crds/base/kustomization.yaml
  • Kustomization kustomize.config.k8s.io/v1beta1
crds/base/prometheus-operator/helmrelease.yaml
  • HelmRelease helm.toolkit.fluxcd.io/v2beta2
crds/base/prometheus-operator/kustomization.yaml
  • Kustomization kustomize.config.k8s.io/v1beta1
crds/base/prometheus-operator/source.yaml
  • HelmRepository source.toolkit.fluxcd.io/v1beta2
crds/base/tofu-controller/crds.yaml
  • Kustomization kustomize.toolkit.fluxcd.io/v1
crds/base/tofu-controller/kustomization.yaml
  • Kustomization kustomize.config.k8s.io/v1beta1
crds/base/tofu-controller/source.yaml
  • GitRepository source.toolkit.fluxcd.io/v1
flux-config/base/capacitor/capacitor.yaml
  • Kustomization kustomize.toolkit.fluxcd.io/v1
flux-config/base/capacitor/kustomization.yaml
  • Kustomization kustomize.config.k8s.io/v1beta1
flux-config/base/capacitor/source.yaml
  • OCIRepository source.toolkit.fluxcd.io/v1beta2
flux-config/base/prometheus/kustomization.yaml
  • Kustomization kustomize.config.k8s.io/v1beta1
flux-config/controlplane-0/kustomization.yaml
  • Kustomization kustomize.config.k8s.io/v1beta1
flux-config/dev-0/kustomization.yaml
  • Kustomization kustomize.config.k8s.io/v1beta1
infrastructure/base/aws-load-balancer-controller/helmrelease.yaml
  • HelmRelease helm.toolkit.fluxcd.io/v2beta2
infrastructure/base/aws-load-balancer-controller/kustomization.yaml
  • Kustomization kustomize.config.k8s.io/v1beta1
infrastructure/base/aws-load-balancer-controller/source.yaml
  • HelmRepository source.toolkit.fluxcd.io/v1beta2
infrastructure/base/external-dns/helmrelease.yaml
  • HelmRelease helm.toolkit.fluxcd.io/v2beta2
infrastructure/base/external-dns/kustomization.yaml
  • Kustomization kustomize.config.k8s.io/v1beta1
infrastructure/base/external-dns/source.yaml
  • HelmRepository source.toolkit.fluxcd.io/v1beta2
infrastructure/base/gapi/kustomization.yaml
  • Kustomization kustomize.config.k8s.io/v1beta1
infrastructure/controlplane-0/kustomization.yaml
  • Kustomization kustomize.config.k8s.io/v1beta1
infrastructure/controlplane-0/tofu-controller/aws-resources/acm/kustomization.yaml
  • Kustomization kustomize.config.k8s.io/v1beta1
infrastructure/controlplane-0/tofu-controller/aws-resources/eks-pod-identity/kustomization.yaml
  • Kustomization kustomize.config.k8s.io/v1beta1
infrastructure/controlplane-0/tofu-controller/aws-resources/eks/kustomization.yaml
  • Kustomization kustomize.config.k8s.io/v1beta1
infrastructure/controlplane-0/tofu-controller/aws-resources/irsa/kustomization.yaml
  • Kustomization kustomize.config.k8s.io/v1beta1
infrastructure/controlplane-0/tofu-controller/aws-resources/kustomization.yaml
  • Kustomization kustomize.config.k8s.io/v1beta1
infrastructure/controlplane-0/tofu-controller/aws-resources/route53-zone/kustomization.yaml
  • Kustomization kustomize.config.k8s.io/v1beta1
infrastructure/controlplane-0/tofu-controller/aws-resources/vpc/kustomization.yaml
  • Kustomization kustomize.config.k8s.io/v1beta1
infrastructure/controlplane-0/tofu-controller/controller/kustomization.yaml
  • Kustomization kustomize.config.k8s.io/v1beta1
infrastructure/controlplane-0/tofu-controller/controller/release.yaml
  • HelmRelease helm.toolkit.fluxcd.io/v2beta2
infrastructure/controlplane-0/tofu-controller/controller/source.yaml
  • GitRepository source.toolkit.fluxcd.io/v1
infrastructure/controlplane-0/tofu-controller/kustomization.yaml
  • Kustomization kustomize.config.k8s.io/v1beta1
infrastructure/controlplane-0/tofu-controller/sources/demo-tofu-controller.yaml
  • GitRepository source.toolkit.fluxcd.io/v1
infrastructure/controlplane-0/tofu-controller/sources/kustomization.yaml
  • Kustomization kustomize.config.k8s.io/v1beta1
infrastructure/controlplane-0/tofu-controller/sources/terraform-aws-acm.yaml
  • GitRepository source.toolkit.fluxcd.io/v1
infrastructure/controlplane-0/tofu-controller/sources/terraform-aws-epi.yaml
  • GitRepository source.toolkit.fluxcd.io/v1
infrastructure/controlplane-0/tofu-controller/sources/terraform-aws-iam.yaml
  • GitRepository source.toolkit.fluxcd.io/v1
infrastructure/controlplane-0/tofu-controller/sources/terraform-aws-route53.yaml
  • GitRepository source.toolkit.fluxcd.io/v1
infrastructure/controlplane-0/tofu-controller/sources/terraform-aws-vpc.yaml
  • GitRepository source.toolkit.fluxcd.io/v1
namespaces/base/kustomization.yaml
  • Kustomization kustomize.config.k8s.io/v1beta1
observability/base/kube-prometheus-stack/helmrelease.yaml
  • HelmRelease helm.toolkit.fluxcd.io/v2beta2
observability/base/kube-prometheus-stack/kustomization.yaml
  • Kustomization kustomize.config.k8s.io/v1beta1
observability/controlplane-0/kustomization.yaml
  • Kustomization kustomize.config.k8s.io/v1beta1
security/base/cert-manager/helmrelease.yaml
  • HelmRelease helm.toolkit.fluxcd.io/v2beta2
security/base/cert-manager/kustomization.yaml
  • Kustomization kustomize.config.k8s.io/v1beta1
security/base/cert-manager/source.yaml
  • HelmRepository source.toolkit.fluxcd.io/v1beta2
security/base/external-secrets/helmrelease.yaml
  • HelmRelease helm.toolkit.fluxcd.io/v2beta2
security/base/external-secrets/kustomization.yaml
  • Kustomization kustomize.config.k8s.io/v1beta1
security/base/external-secrets/source.yaml
  • HelmRepository source.toolkit.fluxcd.io/v1beta2
security/controlplane-0/external-secrets/kustomization.yaml
  • Kustomization kustomize.config.k8s.io/v1beta1
security/dev-0/external-secrets/kustomization.yaml
  • Kustomization kustomize.config.k8s.io/v1beta1
terraform
opentofu/global/iam.tf
  • terraform-aws-modules/iam/aws v5.9.2
opentofu/global/providers.tf
opentofu/global/versions.tf
  • aws ~> 4.0
  • hashicorp/terraform ~> 1.4
opentofu/modules/eks/helm.tf
opentofu/modules/eks/karpenter.tf
  • terraform-aws-modules/eks/aws ~> 20.0
opentofu/modules/eks/kubernetes.tf
  • bitnami/kubectl 1.29.3
opentofu/modules/eks/main.tf
  • terraform-aws-modules/eks/aws ~> 20
opentofu/modules/eks/providers.tf
opentofu/modules/eks/versions.tf
  • aws ~> 5.0
  • flux 1.2.3
  • github ~> 6.0
  • helm >= 2.7
  • http >= 3.4
  • kubectl >= 2.0.0
  • kubernetes >= 2.20
  • random ~> 3.5
  • tls 4.0.5
  • hashicorp/terraform ~> 1.4
opentofu/modules/network/network.tf
  • terraform-aws-modules/vpc/aws ~> 5.0
opentofu/modules/network/providers.tf
opentofu/modules/network/route53.tf
  • terraform-aws-modules/route53/aws ~> 2.0
opentofu/modules/network/tailscale.tf
  • Smana/tailscale-subnet-router/aws 1.0.4
opentofu/modules/network/versions.tf
  • aws ~> 5.0
  • random ~> 3.5
  • tailscale ~> 0.15
  • hashicorp/terraform ~> 1.4
terragrunt
terragrunt/eks/terragrunt.hcl
terragrunt/network/terragrunt.hcl
terragrunt/terragrunt.hcl
terragrunt/tofu-controller/terragrunt.hcl
  • terraform-aws-modules/eks-pod-identity/aws 1.1.0
tflint-plugin
.tflint.hcl
  • terraform-linters/tflint-ruleset-aws 0.30.0

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.