-
Notifications
You must be signed in to change notification settings - Fork 1
/
spoke-k8s_application-ollama.tf
103 lines (96 loc) · 3.62 KB
/
spoke-k8s_application-ollama.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
data "azurerm_public_ip" "hub-nva-vip_ollama_public_ip" {
count = var.APPLICATION_OLLAMA ? 1 : 0
name = azurerm_public_ip.hub-nva-vip_ollama_public_ip[0].name
resource_group_name = azurerm_resource_group.azure_resource_group.name
}
resource "azurerm_dns_cname_record" "ollama" {
count = var.APPLICATION_OLLAMA ? 1 : 0
name = "ollama"
zone_name = azurerm_dns_zone.dns_zone.name
resource_group_name = azurerm_resource_group.azure_resource_group.name
ttl = 300
record = data.azurerm_public_ip.hub-nva-vip_ollama_public_ip[0].fqdn
}
resource "azurerm_public_ip" "hub-nva-vip_ollama_public_ip" {
count = var.APPLICATION_OLLAMA ? 1 : 0
name = "hub-nva-vip_ollama_public_ip"
location = azurerm_resource_group.azure_resource_group.location
resource_group_name = azurerm_resource_group.azure_resource_group.name
allocation_method = "Static"
sku = "Standard"
domain_name_label = "${azurerm_resource_group.azure_resource_group.name}-ollama"
}
resource "kubernetes_namespace" "ollama" {
count = var.APPLICATION_OLLAMA ? 1 : 0
depends_on = [
azurerm_kubernetes_cluster.kubernetes_cluster
]
metadata {
name = "ollama"
labels = {
name = "ollama"
}
}
}
resource "kubernetes_secret" "ollama_fortiweb_login_secret" {
count = var.APPLICATION_OLLAMA ? 1 : 0
metadata {
name = "fortiweb-login-secret"
namespace = kubernetes_namespace.ollama[0].metadata[0].name
}
data = {
username = var.HUB_NVA_USERNAME
password = var.HUB_NVA_PASSWORD
}
type = "Opaque"
}
locals {
ollama_manifest_repo_fqdn = "[email protected]:${var.GITHUB_ORG}/${var.MANIFESTS_APPLICATIONS_REPO_NAME}.git"
}
resource "azurerm_kubernetes_flux_configuration" "ollama" {
count = var.APPLICATION_OLLAMA ? 1 : 0
name = "ollama"
cluster_id = azurerm_kubernetes_cluster.kubernetes_cluster.id
namespace = "cluster-config"
scope = "cluster"
continuous_reconciliation_enabled = true
git_repository {
url = local.ollama_manifest_repo_fqdn
reference_type = "branch"
reference_value = "ollama-version"
sync_interval_in_seconds = 60
ssh_private_key_base64 = base64encode(var.MANIFESTS_APPLICATIONS_SSH_PRIVATE_KEY)
}
kustomizations {
name = "ollama-dependencies"
recreating_enabled = true
garbage_collection_enabled = true
path = "./ollama-dependencies"
sync_interval_in_seconds = 60
}
kustomizations {
name = "ollama"
recreating_enabled = true
garbage_collection_enabled = true
path = "./ollama"
depends_on = ["ollama-dependencies"]
sync_interval_in_seconds = 60
}
#kustomizations {
# name = "ollama-post-deployment-config"
# recreating_enabled = true
# garbage_collection_enabled = true
# path = "./ollama-post-deployment-config"
# depends_on = ["ollama"]
# sync_interval_in_seconds = 60
#}
depends_on = [
azurerm_kubernetes_flux_configuration.infrastructure
]
}
resource "null_resource" "trigger_ollama-version_workflow" {
count = var.APPLICATION_OLLAMA ? 1 : 0
provisioner "local-exec" {
command = "gh workflow run ollama-version --repo ${var.GITHUB_ORG}/${var.MANIFESTS_APPLICATIONS_REPO_NAME} --ref main"
}
}