File tree Expand file tree Collapse file tree 5 files changed +140
-3
lines changed
Expand file tree Collapse file tree 5 files changed +140
-3
lines changed Original file line number Diff line number Diff line change @@ -10,9 +10,10 @@ data "http" "myip" {
1010}
1111
1212locals {
13- my_ip = " ${ chomp (data. http . myip . response_body )} /32"
14- elia-ip = " 185.178.95.235/32"
15- mariadb_internal_ip = " mariadb-service.mariadb.svc.cluster.local"
13+ my_ip = " ${ chomp (data. http . myip . response_body )} /32"
14+ elia-ip = " 185.178.95.235/32"
15+ mariadb_internal_ip = " mariadb-service.mariadb.svc.cluster.local"
16+ postgres_internal_ip = " postgres-service.postgres.svc.cluster.local"
1617}
1718
1819module "aks" {
@@ -200,3 +201,15 @@ module "mariadb" {
200201 rg_name = azurerm_resource_group. rg . name
201202}
202203
204+ module "postgres" {
205+ depends_on = [
206+ module . aks ,
207+ module . argo-cd
208+ ]
209+
210+ source = " ./modules/postgres/"
211+ postgres_internal_ip = local. postgres_internal_ip
212+
213+ location = azurerm_resource_group. rg . location
214+ rg_name = azurerm_resource_group. rg . name
215+ }
Original file line number Diff line number Diff line change 1+ resource "kubernetes_namespace" "postgres" {
2+ metadata {
3+ name = " postgres"
4+ }
5+ }
6+
7+ resource "azurerm_managed_disk" "storage" {
8+ name = " md-polinetwork-postgres"
9+ location = var. location
10+ resource_group_name = var. rg_name
11+ storage_account_type = " Premium_LRS"
12+ create_option = " Empty"
13+ disk_size_gb = " 32"
14+ tier = " P4"
15+ }
16+
17+ resource "kubernetes_persistent_volume" "storageaks" {
18+ metadata {
19+ name = " postgres-persistent-volume"
20+ }
21+ spec {
22+ capacity = {
23+ storage = " 32Gi"
24+ }
25+ storage_class_name = " managed-csi"
26+ access_modes = [" ReadWriteOnce" ]
27+ persistent_volume_source {
28+ csi {
29+ driver = " disk.csi.azure.com"
30+ volume_handle = azurerm_managed_disk. storage . id
31+ }
32+ }
33+ }
34+
35+ depends_on = [
36+ azurerm_managed_disk . storage
37+ ]
38+ }
39+
40+ resource "kubernetes_persistent_volume_claim" "postgres_storage" {
41+ metadata {
42+ name = " postgres-pvc"
43+ namespace = " postgres"
44+ }
45+ spec {
46+ access_modes = [" ReadWriteOnce" ]
47+ storage_class_name = " managed-csi"
48+ resources {
49+ requests = {
50+ storage = " 32Gi"
51+ }
52+ }
53+ volume_name = kubernetes_persistent_volume. storageaks . metadata [0 ]. name
54+ }
55+ }
Original file line number Diff line number Diff line change 1+ terraform {
2+ required_version = " ~> 1.0"
3+ required_providers {
4+ kubernetes = {
5+ source = " hashicorp/kubernetes"
6+ version = " 2.21.1"
7+ }
8+ azurerm = {
9+ source = " hashicorp/azurerm"
10+ version = " =4.23.0"
11+ }
12+ }
13+ }
Original file line number Diff line number Diff line change 1+ variable "postgres_internal_ip" {
2+ type = string
3+ nullable = false
4+ }
5+
6+ variable "location" {
7+ type = string
8+ nullable = false
9+ }
10+
11+ variable "rg_name" {
12+ type = string
13+ nullable = false
14+ }
You can’t perform that action at this time.
0 commit comments