-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from FriedCircuits/feature/Generic-Helm-Chart-M…
…odule Generic Helm Chart Module
- Loading branch information
Showing
4 changed files
with
127 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
resource "kubernetes_namespace" "namespace" { | ||
count = var.create_namespace ? 1 : 0 | ||
metadata { | ||
name = var.namespace | ||
} | ||
} | ||
|
||
locals { | ||
values = yamlencode( | ||
merge(var.persistence != {} ? tomap({ | ||
persistence = merge({ | ||
enabled = true | ||
}, | ||
var.persistence) | ||
}) : {}, var.ingress != {} ? tomap({ | ||
ingress = merge({ | ||
enabled = true | ||
}, tomap({ | ||
annotations = var.ingress_annotations}), | ||
var.ingress) | ||
}) : {}, | ||
var.helm_envs, | ||
var.helm_values | ||
) | ||
) | ||
} | ||
|
||
resource "helm_release" "k8s" { | ||
repository = var.helm_repo | ||
name = var.name | ||
chart = var.chart | ||
version = var.chart_version | ||
namespace = var.namespace | ||
|
||
values = [ | ||
local.values, | ||
] | ||
|
||
depends_on = [ | ||
kubernetes_namespace.namespace, | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
variable "chart_version" { | ||
description = "The version of the helm chart to use. Note that this is different from the app/container version." | ||
type = string | ||
} | ||
|
||
variable "create_namespace" { | ||
description = "Create namespace or deploy to existing." | ||
type = bool | ||
default = true | ||
} | ||
|
||
variable "namespace" { | ||
description = "Which Kubernetes Namespace to deploy the chart into." | ||
type = string | ||
default = "default" | ||
} | ||
|
||
variable "helm_repo" { | ||
description = "Helm chart repo URL." | ||
type = string | ||
} | ||
|
||
variable "name" { | ||
description = "Name of chart deployment." | ||
type = string | ||
} | ||
|
||
variable "chart" { | ||
description = "Name of helm chart." | ||
type = string | ||
} | ||
|
||
variable "persistence" { | ||
description = "Configure persistence volume on this deployment." | ||
type = any | ||
default = {} | ||
# Example | ||
} | ||
|
||
variable "ingress" { | ||
description = "Configure ingress on this deployment." | ||
type = any | ||
default = {} | ||
# Example | ||
} | ||
|
||
variable "ingress_annotations" { | ||
description = "Configure ingress annotations on this deployment." | ||
type = map(string) | ||
default = {} | ||
} | ||
|
||
variable "helm_envs" { | ||
description = "Map of envs for helm chart. Merged with timezone." | ||
type = any | ||
default = {} | ||
} | ||
|
||
variable "helm_values" { | ||
description = "Additional helm values to pass in as a map. Timezone will be included already." | ||
type = any | ||
default = {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
terraform { | ||
required_version = ">= 1.0" | ||
|
||
required_providers { | ||
kubernetes = { | ||
source = "hashicorp/kubernetes" | ||
version = "~> 1.0" | ||
} | ||
helm = { | ||
source = "hashicorp/helm" | ||
version = "~> 2.0" | ||
} | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "~> 3.0" | ||
} | ||
} | ||
} |