Skip to content

Commit

Permalink
feat: modular folder structure to install infra-helm-chart dependency
Browse files Browse the repository at this point in the history
- Install Kafka dependency chart to the cluster defined in `KUBECONFIG`
- 3 Kafka brokers
- `healthcheck` topic with 3 partitions
- `tfvars` to define `values.yaml` for the Helm chart

Fixes issue #1
  • Loading branch information
sydrawat01 committed Nov 11, 2023
1 parent d8b9e9f commit 1d8d0fe
Show file tree
Hide file tree
Showing 14 changed files with 87 additions and 27 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Terraform Helm Provider

This terraform code is to deploy Helm charts on GKE(GCP) cluster using terraform [`Terraform Helm Provider`](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release)
This terraform code is to deploy Helm charts on GKE(GCP) cluster in prod OR minikube cluster locally using terraform [`Terraform Helm Provider`](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release)

The helm chart installation cluster depends on the `kubernetes` `config_path` in the `helm` provider.

```tf
provider "helm" {
kubernetes {
config_path = "~/.kube/config"
}
}
```

Based on the `KUBECONFIG` value, the helm chart will be installed on that particular cluster.

> Due to an on-going issue with Terraform Helm Provider [[reference](https://github.com/hashicorp/terraform-provider-helm/issues/932)] which prevents the Terraform resource to pull a chart from a private GitHub repository (even after providing a GitHub PAT), we are forced to install the Helm chart locally.
2 changes: 0 additions & 2 deletions example.tfvars

This file was deleted.

10 changes: 0 additions & 10 deletions main.tf

This file was deleted.

Binary file not shown.
12 changes: 12 additions & 0 deletions modules/infra_helm/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# https://github.com/hashicorp/terraform-provider-helm/issues/467#issuecomment-617856419
resource "helm_release" "infra_dependencies" {
name = var.release_name
namespace = var.namespace
create_namespace = true
repository = "https://github.com/csye7125-fall2023-group05/infra-helm-chart.git"
chart = "${var.chart_path}/infra-helm-chart-1.1.0.tar.gz"
wait = false # prevents "pending-install" helm install state
version = "1.1.0"
values = ["${file(var.values_file)}"]
timeout = var.timeout
}
Empty file added modules/infra_helm/output.tf
Empty file.
5 changes: 5 additions & 0 deletions modules/infra_helm/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
variable "namespace" {}
variable "timeout" {}
variable "values_file" {}
variable "chart_path" {}
variable "release_name" {}
3 changes: 2 additions & 1 deletion .gitignore → root/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ override.tf.json

# variables
dev.tfvars
prod.tfvars
prod.tfvars
values.yaml
8 changes: 8 additions & 0 deletions root/backend.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# terraform {
# backend "s3" {
# bucket = "tfstate-sid"
# key = "backend/infra-jenkins.tfstate"
# region = "us-east-1"
# dynamodb_table = "infra-state"
# }
# }
5 changes: 5 additions & 0 deletions root/example.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace = "webapp"
timeout = 600
values_file = "./values.yaml"
chart_path = "../modules/infra_helm/charts"
release_name = "infra-helm-release"
8 changes: 8 additions & 0 deletions root/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module "infra_dependencies" {
source = "../modules/infra_helm"
namespace = var.namespace
timeout = var.timeout
values_file = var.values_file
chart_path = var.chart_path
release_name = var.release_name
}
6 changes: 3 additions & 3 deletions provider.tf → root/provider.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "4.63.1"
helm = {
source = "hashicorp/helm"
version = "2.11.0"
}
}
}
Expand Down
29 changes: 29 additions & 0 deletions root/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
variable "namespace" {
default = "default"
type = string
description = "Namespace in which to deploy the chart"
}

variable "timeout" {
type = number
description = "The max time to run the helm release"
default = 30
}

variable "values_file" {
type = string
description = "The path to the values.yaml file for the helm chart"
default = "./values.yaml"
}

variable "chart_path" {
type = string
description = "The path to the charts/ directory to install local charts"
default = "../modules/infra_helm/charts"
}

variable "release_name" {
type = string
description = "The name of the helm chart release"
default = "infra-helm-release"
}
10 changes: 0 additions & 10 deletions variables.tf

This file was deleted.

0 comments on commit 1d8d0fe

Please sign in to comment.