Skip to content

Commit db38742

Browse files
wip: fix bots
1 parent 6c67f24 commit db38742

File tree

7 files changed

+283
-35
lines changed

7 files changed

+283
-35
lines changed

argocd-applications.yaml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,29 +42,29 @@ applications:
4242
info:
4343
- name: url
4444
value: https://argoproj.github.io/
45-
bot-mat:
46-
name: bot-mat
47-
namespace: argocd
48-
project: default
49-
source:
50-
repoURL: https://github.com/poliNetworkOrg/polinetwork-cd
51-
targetRevision: HEAD
52-
path: bot-mat
53-
directory:
54-
recurse: true
55-
destination:
56-
server: https://kubernetes.default.svc
57-
namespace: bot-mat
58-
syncPolicy:
59-
automated:
60-
prune: true
61-
selfHeal: true
62-
syncOptions:
63-
- CreateNamespace=false
64-
- Replace=true
65-
info:
66-
- name: url
67-
value: https://argoproj.github.io/
45+
# bot-mat:
46+
# name: bot-mat
47+
# namespace: argocd
48+
# project: default
49+
# source:
50+
# repoURL: https://github.com/poliNetworkOrg/polinetwork-cd
51+
# targetRevision: HEAD
52+
# path: bot-mat
53+
# directory:
54+
# recurse: true
55+
# destination:
56+
# server: https://kubernetes.default.svc
57+
# namespace: bot-mat
58+
# syncPolicy:
59+
# automated:
60+
# prune: true
61+
# selfHeal: true
62+
# syncOptions:
63+
# - CreateNamespace=false
64+
# - Replace=true
65+
# info:
66+
# - name: url
67+
# value: https://argoproj.github.io/
6868
mariadb:
6969
name: mariadb
7070
namespace: argocd

main.tf

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module "aks" {
3636
location = azurerm_resource_group.rg.location
3737
rg_name = azurerm_resource_group.rg.name
3838

39-
kubernetes_orchestrator_version = "1.26.3"
39+
kubernetes_orchestrator_version = "1.32.0"
4040

4141
}
4242

@@ -55,6 +55,15 @@ module "argo-cd" {
5555
]
5656
}
5757

58+
module "aule_bot" {
59+
depends_on = [
60+
module.mariadb
61+
]
62+
63+
source = "./modules/bots-migration/"
64+
bot_namespace = "bot-rooms"
65+
}
66+
5867
module "cloudflare" {
5968
depends_on = [
6069
module.aks
@@ -127,22 +136,13 @@ module "bot_mat_migration" {
127136
module.mariadb
128137
]
129138

130-
source = "./modules/bots/"
139+
source = "./modules/bots-migration/"
131140

132141
bot_namespace = "bot-mat"
133-
bot_token = data.azurerm_key_vault_secret.prod_mat_token.value
134-
bot_onMessage = "mat"
135-
db_database = "polinetwork_materials"
136-
db_host = local.mariadb_internal_ip
137-
db_password = data.azurerm_key_vault_secret.prod_mat_db_password.value
138-
db_user = data.azurerm_key_vault_secret.prod_mat_db_user.value
139142
persistent_storage = true
140143
persistent_storage_size_gi = "250"
141144
persistent_storage_location = azurerm_resource_group.rg.location
142145
persistent_storage_rg_name = azurerm_resource_group.rg.name
143-
144-
material_password = data.azurerm_key_vault_secret.dev_mat_config_password.value
145-
material_root_dir = "/Repos/"
146146
}
147147

148148
module "keyvault" {

modules/bots-migration/.terraform.lock.hcl

Lines changed: 62 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/bots-migration/bots.tf

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
resource "random_uuid" "volume" {
2+
}
3+
4+
resource "kubernetes_namespace" "bot-namespace" {
5+
metadata {
6+
name = var.bot_namespace
7+
}
8+
}
9+
10+
resource "azurerm_managed_disk" "storage" {
11+
count = var.persistent_storage ? 1 : 0
12+
name = "md-polinetwork-${random_uuid.volume.result}"
13+
location = var.persistent_storage_location
14+
resource_group_name = var.persistent_storage_rg_name
15+
storage_account_type = "Standard_LRS"
16+
create_option = "Empty"
17+
disk_size_gb = var.persistent_storage_size_gi
18+
}
19+
20+
resource "kubernetes_persistent_volume" "storage" {
21+
count = var.persistent_storage ? 1 : 0
22+
23+
metadata {
24+
name = "${random_uuid.volume.result}-bot-pv"
25+
}
26+
spec {
27+
capacity = {
28+
storage = "${var.persistent_storage_size_gi}Gi"
29+
}
30+
storage_class_name = "managed-csi"
31+
access_modes = ["ReadWriteOnce"]
32+
persistent_volume_source {
33+
csi {
34+
driver = "disk.csi.azure.com"
35+
volume_handle = azurerm_managed_disk.storage[0].id
36+
}
37+
}
38+
}
39+
40+
depends_on = [
41+
azurerm_managed_disk.storage
42+
]
43+
}
44+
45+
resource "kubernetes_persistent_volume_claim" "storage_pvc" {
46+
count = var.persistent_storage ? 1 : 0
47+
metadata {
48+
name = var.pvc_name == "" ? "bot-pvc" : var.pvc_name
49+
namespace = var.bot_namespace
50+
}
51+
spec {
52+
access_modes = ["ReadWriteOnce"]
53+
storage_class_name = "managed-csi"
54+
resources {
55+
requests = {
56+
storage = "${var.persistent_storage_size_gi}Gi"
57+
}
58+
}
59+
volume_name = kubernetes_persistent_volume.storage[0].metadata[0].name
60+
}
61+
}
62+
63+
resource "kubernetes_secret" "git_config" {
64+
count = var.git_config ? 1 : 0
65+
metadata {
66+
name = "git-config"
67+
namespace = var.bot_namespace
68+
}
69+
70+
data = {
71+
"git_info.json" = jsonencode({
72+
user = var.git_user,
73+
email = var.git_email,
74+
data_repo = var.git_data_repo,
75+
remote_repo = var.git_remote_repo,
76+
path = var.git_path
77+
})
78+
"ssh-key" = var.git_password
79+
}
80+
}
81+
82+
resource "kubernetes_secret" "git_ssh_config" {
83+
count = var.git_config ? 1 : 0
84+
metadata {
85+
name = "ssh-config"
86+
namespace = var.bot_namespace
87+
}
88+
89+
data = {
90+
"config" = <<EOF
91+
Host github
92+
HostName github.com
93+
User git
94+
IdentityFile /git/ssh-key
95+
IdentitiesOnly yes
96+
EOF
97+
}
98+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
variable "bot_namespace" {
2+
type = string
3+
nullable = false
4+
}
5+
6+
variable "persistent_storage" {
7+
type = bool
8+
description = "Volume claim for the bot"
9+
default = false
10+
}
11+
12+
variable "persistent_storage_location" {
13+
type = string
14+
default = ""
15+
}
16+
17+
variable "persistent_storage_rg_name" {
18+
type = string
19+
default = ""
20+
}
21+
22+
variable "persistent_storage_size_gi" {
23+
type = string
24+
description = "Requested storage"
25+
default = ""
26+
}
27+
28+
variable "git_user" {
29+
type = string
30+
sensitive = false
31+
default = ""
32+
}
33+
34+
variable "git_email" {
35+
type = string
36+
sensitive = true
37+
default = ""
38+
}
39+
variable "git_password" {
40+
type = string
41+
sensitive = true
42+
default = ""
43+
}
44+
variable "git_data_repo" {
45+
type = string
46+
sensitive = false
47+
default = ""
48+
}
49+
variable "git_remote_repo" {
50+
type = string
51+
sensitive = false
52+
default = ""
53+
}
54+
55+
variable "git_path" {
56+
type = string
57+
sensitive = false
58+
default = "/Repos"
59+
}
60+
61+
variable "git_config" {
62+
type = bool
63+
sensitive = false
64+
default = false
65+
}
66+
67+
variable "pvc_name" {
68+
type = string
69+
sensitive = false
70+
default = ""
71+
}

modules/bots-migration/versions.tf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
terraform {
2+
required_version = "~> 1.0"
3+
required_providers {
4+
azurerm = {
5+
source = "hashicorp/azurerm"
6+
version = "3.63.0"
7+
}
8+
random = {
9+
source = "hashicorp/random"
10+
version = "3.5.1"
11+
}
12+
kubernetes = {
13+
source = "hashicorp/kubernetes"
14+
version = "2.21.1"
15+
}
16+
}
17+
}

modules/bots/bots.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,4 @@ Host github
136136
IdentitiesOnly yes
137137
EOF
138138
}
139-
}
139+
}

0 commit comments

Comments
 (0)