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: Init helm release #5

Merged
merged 9 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
20 changes: 20 additions & 0 deletions example/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,21 @@ module "gke" {

depends_on = [module.networking, module.service_accounts]
}

module "helm_release" {
source = "./modules/helm_release"

redis_host = module.redis.redis_host
redis_port = module.redis.redis_port
redis_password = module.redis.redis_auth_string

postgres_user = module.database.sql_user_username
postgres_password = module.database.sql_user_password
postgres_host = module.database.database_instance_private_ip_address
postgres_port = 3306
postgres_database = module.database.database_name

service_account_email = module.service_accounts.service_account_email

depends_on = [module.gke]
}
81 changes: 81 additions & 0 deletions modules/helm_release/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
resource "helm_release" "this" {
name = "ctrlplane"
chart = "ctrlplane"
repository = "https://charts.ctrlplane.dev/"

set {
name = "global.redis.host"
value = var.redis_host
}

set {
name = "global.redis.port"
value = var.redis_port
}

set {
name = "global.redis.password"
value = var.redis_password
}

set {
name = "global.postgresql.user"
value = var.postgres_user
}

set {
name = "global.postgresql.password"
value = var.postgres_password
}

set {
name = "global.postgresql.host"
value = var.postgres_host
}

set {
name = "global.postgresql.port"
value = var.postgres_port
}

set {
name = "global.postgresql.database"
value = var.postgres_database
}

set {
name = "global.webservice.serviceAccount.create"
value = true
}

set {
name = "global.webservice.serviceAccount.annotations"
value = yamlencode({
"iam.gke.io/gcp-service-account" = var.service_account_email
})
}

set {
name = "global.job-policy-checker.serviceAccount.create"
value = true
}

set {
name = "global.job-policy-checker.serviceAccount.annotations"
value = yamlencode({
"iam.gke.io/gcp-service-account" = var.service_account_email
})
}

set {
name = "global.migrations.serviceAccount.create"
value = true
}

set {
name = "global.migrations.serviceAccount.annotations"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wtf? gloabl

value = yamlencode({
"iam.gke.io/gcp-service-account" = var.service_account_email
})
}
}
44 changes: 44 additions & 0 deletions modules/helm_release/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
variable "redis_host" {
type = string
description = "The host for the Redis instance."
}

variable "redis_port" {
type = number
description = "The port for the Redis instance."
}

variable "redis_password" {
type = string
description = "The password for the Redis instance."
}

variable "postgres_user" {
type = string
description = "The user for the Postgres instance."
}

variable "postgres_password" {
type = string
description = "The password for the Postgres instance."
}

variable "postgres_host" {
type = string
description = "The host for the Postgres instance."
}

variable "postgres_port" {
type = number
description = "The port for the Postgres instance."
}

variable "postgres_database" {
type = string
description = "The database for the Postgres instance."
}

variable "service_account_email" {
type = string
description = "The service account email."
}
2 changes: 1 addition & 1 deletion modules/service_accounts/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ resource "google_service_account_iam_binding" "this" {
service_account_id = google_service_account.this.id
role = "roles/iam.workloadIdentityUser"
members = [
"serviceAccount:${local.project_id}.svc.id.goog[default/ctrlplane-${var.namespace}-sa]"
"serviceAccount:${local.project_id}.svc.id.goog[default/${google_service_account.this.email}]"
]
}
5 changes: 5 additions & 0 deletions versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@ terraform {
source = "hashicorp/google"
version = "~> 5.42"
}

helm = {
source = "hashicorp/helm"
version = "~> 2.15"
}
}
}
Loading