{
  "schema_version": 1,
  "kind": "article",
  "title": "Managing Kubernetes platform components with Terragrunt",
  "description": "A walkthrough of Terragrunt configuration, module dependencies, and deployment steps for Kubernetes platform tools.",
  "url": "https://cloudon-one.com/blog/simplify-kubernetes-terragrunt",
  "markdown_url": "https://cloudon-one.com/blog/simplify-kubernetes-terragrunt.md",
  "json_url": "https://cloudon-one.com/blog/simplify-kubernetes-terragrunt.json",
  "language": "en",
  "author": {
    "type": "Organization",
    "name": "CloudOn",
    "url": "https://cloudon-one.com/"
  },
  "rights_url": "https://cloudon-one.com/terms",
  "indexable": true,
  "headings": [
    {
      "level": 2,
      "text": "Introduction",
      "id": "introduction",
      "url": "https://cloudon-one.com/blog/simplify-kubernetes-terragrunt#introduction"
    },
    {
      "level": 2,
      "text": "The Big Picture: Architecture",
      "id": "the-big-picture-architecture",
      "url": "https://cloudon-one.com/blog/simplify-kubernetes-terragrunt#the-big-picture-architecture"
    },
    {
      "level": 2,
      "text": "Why Terragrunt?",
      "id": "why-terragrunt",
      "url": "https://cloudon-one.com/blog/simplify-kubernetes-terragrunt#why-terragrunt"
    },
    {
      "level": 2,
      "text": "Repository Structure",
      "id": "repository-structure",
      "url": "https://cloudon-one.com/blog/simplify-kubernetes-terragrunt#repository-structure"
    },
    {
      "level": 2,
      "text": "Prerequisites",
      "id": "prerequisites",
      "url": "https://cloudon-one.com/blog/simplify-kubernetes-terragrunt#prerequisites"
    },
    {
      "level": 2,
      "text": "Getting Started",
      "id": "getting-started",
      "url": "https://cloudon-one.com/blog/simplify-kubernetes-terragrunt#getting-started"
    },
    {
      "level": 3,
      "text": "1. Configure Common Settings",
      "id": "1-configure-common-settings",
      "url": "https://cloudon-one.com/blog/simplify-kubernetes-terragrunt#1-configure-common-settings"
    },
    {
      "level": 3,
      "text": "2. Define Platform Variables",
      "id": "2-define-platform-variables",
      "url": "https://cloudon-one.com/blog/simplify-kubernetes-terragrunt#2-define-platform-variables"
    },
    {
      "level": 3,
      "text": "3. Deployment Order",
      "id": "3-deployment-order",
      "url": "https://cloudon-one.com/blog/simplify-kubernetes-terragrunt#3-deployment-order"
    },
    {
      "level": 4,
      "text": "1. Core Platform",
      "id": "1-core-platform",
      "url": "https://cloudon-one.com/blog/simplify-kubernetes-terragrunt#1-core-platform"
    },
    {
      "level": 4,
      "text": "2. Service Mesh & Networking",
      "id": "2-service-mesh--networking",
      "url": "https://cloudon-one.com/blog/simplify-kubernetes-terragrunt#2-service-mesh--networking"
    },
    {
      "level": 4,
      "text": "3. Observability",
      "id": "3-observability",
      "url": "https://cloudon-one.com/blog/simplify-kubernetes-terragrunt#3-observability"
    },
    {
      "level": 4,
      "text": "4. Platform Tools",
      "id": "4-platform-tools",
      "url": "https://cloudon-one.com/blog/simplify-kubernetes-terragrunt#4-platform-tools"
    },
    {
      "level": 2,
      "text": "Day 2 Operations",
      "id": "day-2-operations",
      "url": "https://cloudon-one.com/blog/simplify-kubernetes-terragrunt#day-2-operations"
    },
    {
      "level": 3,
      "text": "Updating a Component",
      "id": "updating-a-component",
      "url": "https://cloudon-one.com/blog/simplify-kubernetes-terragrunt#updating-a-component"
    },
    {
      "level": 3,
      "text": "Backing Up Terraform State",
      "id": "backing-up-terraform-state",
      "url": "https://cloudon-one.com/blog/simplify-kubernetes-terragrunt#backing-up-terraform-state"
    },
    {
      "level": 2,
      "text": "Security Considerations",
      "id": "security-considerations",
      "url": "https://cloudon-one.com/blog/simplify-kubernetes-terragrunt#security-considerations"
    },
    {
      "level": 2,
      "text": "Monitoring & Observability",
      "id": "monitoring--observability",
      "url": "https://cloudon-one.com/blog/simplify-kubernetes-terragrunt#monitoring--observability"
    },
    {
      "level": 2,
      "text": "CI/CD Integration",
      "id": "cicd-integration",
      "url": "https://cloudon-one.com/blog/simplify-kubernetes-terragrunt#cicd-integration"
    },
    {
      "level": 2,
      "text": "Ready to Dive In?",
      "id": "ready-to-dive-in",
      "url": "https://cloudon-one.com/blog/simplify-kubernetes-terragrunt#ready-to-dive-in"
    },
    {
      "level": 2,
      "text": "Contributing",
      "id": "contributing",
      "url": "https://cloudon-one.com/blog/simplify-kubernetes-terragrunt#contributing"
    },
    {
      "level": 2,
      "text": "License",
      "id": "license",
      "url": "https://cloudon-one.com/blog/simplify-kubernetes-terragrunt#license"
    },
    {
      "level": 2,
      "text": "Final Thoughts",
      "id": "final-thoughts",
      "url": "https://cloudon-one.com/blog/simplify-kubernetes-terragrunt#final-thoughts"
    }
  ],
  "date_published": "2025-01-08T00:00:00.000Z",
  "tags": [
    "Kubernetes",
    "Terragrunt",
    "IaC",
    "Platform Engineering",
    "GitOps"
  ],
  "content_markdown": "---\ntitle: Managing Kubernetes platform components with Terragrunt\ndescription: A walkthrough of Terragrunt configuration, module dependencies, and deployment steps for Kubernetes platform tools.\nurl: https://cloudon-one.com/blog/simplify-kubernetes-terragrunt\nauthor: CloudOn\nlanguage: en\ndate_published: '2025-01-08T00:00:00.000Z'\ntags:\n  - Kubernetes\n  - Terragrunt\n  - IaC\n  - Platform Engineering\n  - GitOps\nrights_url: https://cloudon-one.com/terms\n---\n\n# Managing Kubernetes platform components with Terragrunt\n\n## Introduction\n\nA Kubernetes platform brings together tools with shared configuration and deployment dependencies. Terragrunt can keep those settings in one place and make the order of operations explicit.\n\nThis walkthrough uses the [Kubernetes Platform Terragrunt Configuration](https://github.com/cloudon-one/k8s-platform-tools) repository to connect core platform tools, networking, and monitoring.\n\n## The Big Picture: Architecture\n\nBelow is a high-level architecture that illustrates the essential modules and their relationships.\n\n**Key Highlights:**\n\n- **Core Platform**: Manages vital capabilities like node provisioning (Karpenter), DNS integration (External DNS), certificate management (Cert Manager), and secret management (External Secrets).\n- **Networking & Service Mesh**: Tightly integrates Istio, Kong Gateway, and Jaeger for routing and distributed tracing.\n- **Observability**: Implements Loki for logs and Kubecost for cost insights.\n- **Platform Tools**: Offers GitOps (ArgoCD), Terraform collaboration (Atlantis), workflow management (Airflow), and advanced secret management (Vault).\n\n## Why Terragrunt?\n\n**Terragrunt** extends Terraform's functionality by introducing:\n\n1. **DRY (Don't Repeat Yourself)**: Centralize standard configurations (like common.hcl) and reduce duplication across multiple modules.\n2. **Automated Dependencies**: Terragrunt's dependency management ensures proper deployment order.\n3. **Consistent Environment Management**: Standardize your environment configurations (like platform_vars.yaml) for dev, stage, and production.\n\n## Repository Structure\n\n```\n.\n├── core-platform/          # Core platform components\n│   ├── cert-manager        # Certificate management\n│   ├── external-dns        # DNS automation\n│   ├── external-secrets    # Secrets management\n│   └── karpenter           # Kubernetes node provisioning\n├── service-mesh/           # Service mesh components\n│   ├── istio               # Service mesh control plane\n│   ├── jeager              # Distributed tracing\n│   └── kong-gw             # API gateway\n├── observability/          # Monitoring and observability\n│   ├── kubecost            # Cost monitoring\n│   └── loki-stack          # Log aggregation\n├── platform-tools/         # Platform utilities\n│   ├── airflow             # Workflow automation\n│   ├── argocd              # GitOps deployment\n│   ├── atlantis            # Terraform automation\n│   └── vault               # Secrets management\n└── ci-cd-templates/        # Reusable CI/CD workflows\n```\n\nThis modular layout allows teams to maintain, iterate, and scale independently on each platform component.\n\n## Prerequisites\n\nTo get started, ensure you have the following tools properly installed and configured:\n\n- Terragrunt >= v0.60.0\n- Terraform >= v1.5.0\n- AWS CLI configured\n- kubectl configured\n- Helm v3.x\n\n## Getting Started\n\n### 1. Configure Common Settings\n\nIn *common.hcl*, you'll find shared values, like the EKS cluster name and AWS region:\n\n```hcl\nlocals {\n  platform_vars    = yamldecode(file((\"platform_vars.yaml\")))\n  eks_cluster_name = local.platform_vars.common.eks_cluster_name\n  environment      = get_env(\"ENV\", \"dev\")\n  aws_region       = local.platform_vars.common.aws_region\n  tags             = local.platform_vars.common.common_tags\n}\n```\n\n### 2. Define Platform Variables\n\nInside *platform_vars.yaml*, you set environment-specific details like domain name, AWS region, and tagging:\n\n```yaml\naws_region:       \"us-east-2\"\neks_cluster_name: \"dev-eks-cluster\"\nenvironment:      \"dev\"\ndomain_name:      \"cloudon.work\"\ncommon_tags:\n    Environment:  \"dev\"\n    Owner:        \"cloudon\"\n    ManagedBy:    \"Terragrunt\"\n    Team:         \"platform\"\n    ClusterName:  \"dev-eks-cluster\"\n...\n```\n\n### 3. Deployment Order\n\n#### 1. Core Platform\n\n```bash\nterragrunt run-all apply --terragrunt-working-dir core-platform\n```\n\n#### 2. Service Mesh & Networking\n\n```bash\nterragrunt run-all apply --terragrunt-working-dir service-mesh\n```\n\n#### 3. Observability\n\n```bash\nterragrunt run-all apply --terragrunt-working-dir observability\n```\n\n#### 4. Platform Tools\n\n```bash\nterragrunt run-all apply --terragrunt-working-dir platform-tools\n```\n\n## Day 2 Operations\n\n### Updating a Component\n\n```bash\ncd component-name\nterragrunt apply\n```\n\n*This allows you to quickly apply changes for a single module without affecting the rest of the platform.*\n\n### Backing Up Terraform State\n\n```bash\nterragrunt state pull > backup.tfstate\n```\n\n*Always keep regular state backups to ensure a smooth recovery if something goes wrong.*\n\n## Security Considerations\n\n- **IRSA**: Ensure each Kubernetes service account has the minimum privileges needed.\n- **Network Policies**: Use Istio and Kong to manage traffic flow and encrypt communication.\n- **Vault & External Secrets**: Keep sensitive data out of your Git repository and manage secrets securely.\n\n## Monitoring & Observability\n\nLeverage best-in-class tools right out of the box:\n\n- **Loki Stack** for log aggregation\n- **Jaeger** for distributed tracing\n- **Kubecost** for granular cost monitoring\n- **Grafana** dashboards for custom insights\n\n## CI/CD Integration\n\nThe repository's ci-cd-templates folder includes reusable workflows for:\n\n- **Docker Builds**\n- **Terragrunt Plan/Apply**\n- **Environment Variable Management**\n\nAdditionally, you'll find test coverage action templates for multiple languages like Java, .NET, Node.js, and Python.\n\n## Ready to Dive In?\n\nThis guide scratches what's possible with a well-structured Terragrunt + Kubernetes setup.\n\nFor detailed configurations, advanced workflows, and troubleshooting tips, check out the [k8s-platform-tools GitHub repository](https://github.com/cloudon-one/k8s-platform-tools).\n\n## Contributing\n\nWe welcome contributions! Fork the repo, make changes, and open a Pull Request to get your updates reviewed and merged.\n\n## License\n\nThis project is available under the MIT License. Details can be found in the repository's LICENSE file.\n\n## Final Thoughts\n\nThe configuration gives each platform component its own module while sharing environment settings. Start with a small set of components and check their dependencies before expanding the platform.\n\nQuestions and proposed improvements are welcome in the repository’s issues and pull requests.\n",
  "content_sha256": "64b9816520960ef77eaa19c3a902a94684c84d0b2057286fae334e1726c1c265"
}
