Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: install infra and webapp helm charts using tf #5

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ provider "helm" {
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.

## Configuring the chart values

For specific `values.yaml`, refer their specific charts and create their respective `values.yaml` files based on the dummy `values.yaml` file.
Binary file added modules/charts/infra-helm-chart-1.4.0.tar.gz
Binary file not shown.
Binary file added modules/charts/webapp-helm-chart-1.1.3.tar.gz
Binary file not shown.
Binary file not shown.
9 changes: 4 additions & 5 deletions modules/infra_helm/main.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# https://github.com/hashicorp/terraform-provider-helm/issues/467#issuecomment-617856419
resource "helm_release" "infra_dependencies" {
name = var.release_name
namespace = var.namespace
name = "infra-helm-release"
namespace = "deps"
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"
chart = "${var.chart_path}/${var.infra_chart}"
wait = false # prevents "pending-install" helm install state
version = "1.1.0"
values = ["${file(var.values_file)}"]
values = ["${file(var.infra_values_file)}"]
timeout = var.timeout
}
5 changes: 2 additions & 3 deletions modules/infra_helm/variables.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
variable "namespace" {}
variable "timeout" {}
variable "values_file" {}
variable "infra_values_file" {}
variable "chart_path" {}
variable "release_name" {}
variable "infra_chart" {}
11 changes: 11 additions & 0 deletions modules/webapp_helm/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# https://github.com/hashicorp/terraform-provider-helm/issues/467#issuecomment-617856419
resource "helm_release" "webapp_release" {
name = "webapp-helm-release"
namespace = "webapp"
create_namespace = true
repository = "https://github.com/csye7125-fall2023-group05/webapp-helm-chart.git"
chart = "${var.chart_path}/${var.webapp_chart}"
wait = false # prevents "pending-install" helm install state
values = ["${file(var.webapp_values_file)}"]
timeout = var.timeout
}
Empty file added modules/webapp_helm/output.tf
Empty file.
4 changes: 4 additions & 0 deletions modules/webapp_helm/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
variable "timeout" {}
variable "webapp_values_file" {}
variable "chart_path" {}
variable "webapp_chart" {}
2 changes: 1 addition & 1 deletion root/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ override.tf.json
# variables
dev.tfvars
prod.tfvars
values.yaml
*values.yaml
20 changes: 14 additions & 6 deletions root/main.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
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
source = "../modules/infra_helm"
timeout = var.timeout
infra_values_file = var.infra_values_file
chart_path = var.chart_path
infra_chart = var.infra_chart
}

module "webapp_dependencies" {
depends_on = [module.infra_dependencies]
source = "../modules/webapp_helm"
timeout = var.timeout
webapp_values_file = var.webapp_values_file
chart_path = var.chart_path
webapp_chart = var.webapp_chart
}
32 changes: 19 additions & 13 deletions root/variables.tf
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
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" {
variable "infra_values_file" {
type = string
description = "The path to the values.yaml file for the helm chart"
default = "./values.yaml"
description = "The path to the infra_values.yaml file for the helm chart"
default = "./infra_values.yaml"
}

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

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

variable "webapp_chart" {
type = string
description = "The exact name of the webapp-helm-chart"
default = "webapp-helm-chart.tar.gz"
}

variable "release_name" {
variable "infra_chart" {
type = string
description = "The name of the helm chart release"
default = "infra-helm-release"
description = "The exact name of the infra-helm-chart"
default = "infra-helm-chart.tar.gz"
}