-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4add8fe
commit b492f4a
Showing
4 changed files
with
130 additions
and
52 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1249,3 +1249,7 @@ azwi | |
Entra | ||
ServiceAccounts | ||
pluggable | ||
cyrilgdn | ||
secretStore | ||
postgreSQL | ||
postgres |
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
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,89 @@ | ||
terraform { | ||
required_providers { | ||
kubernetes = { | ||
source = "hashicorp/kubernetes" | ||
version = ">= 2.0" | ||
} | ||
postgresql = { | ||
source = "cyrilgdn/postgresql" | ||
version = "1.16.0" | ||
} | ||
} | ||
} | ||
|
||
variable "context" { | ||
description = "This variable contains Radius recipe context." | ||
type = any | ||
} | ||
|
||
variable "password" { | ||
description = "The password for the PostgreSQL database" | ||
type = string | ||
} | ||
|
||
resource "kubernetes_deployment" "postgres" { | ||
metadata { | ||
name = "postgres" | ||
namespace = var.context.runtime.kubernetes.namespace | ||
} | ||
|
||
spec { | ||
selector { | ||
match_labels = { | ||
app = "postgres" | ||
} | ||
} | ||
|
||
template { | ||
metadata { | ||
labels = { | ||
app = "postgres" | ||
} | ||
} | ||
|
||
spec { | ||
container { | ||
image = "postgres:latest" | ||
name = "postgres" | ||
|
||
env { | ||
name = "POSTGRES_PASSWORD" | ||
value = var.password | ||
} | ||
|
||
port { | ||
container_port = 5432 | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
resource "kubernetes_service" "postgres" { | ||
metadata { | ||
name = "postgres" | ||
namespace = var.context.runtime.kubernetes.namespace | ||
} | ||
|
||
spec { | ||
selector = { | ||
app = "postgres" | ||
} | ||
|
||
port { | ||
port = 5432 | ||
target_port = 5432 | ||
} | ||
} | ||
} | ||
|
||
resource "time_sleep" "wait_20_seconds" { | ||
depends_on = [kubernetes_service.postgres] | ||
create_duration = "20s" | ||
} | ||
|
||
resource postgresql_database "pg_db_test" { | ||
depends_on = [time_sleep.wait_20_seconds] | ||
name = "pg_db_test" | ||
} |