-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
163 lines (143 loc) · 3.66 KB
/
main.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
terraform {
required_providers {
ionoscloud = {
source = "ionos-cloud/ionoscloud"
version = "= 6.3.5"
}
kubernetes = {}
}
}
variable "ionos_api_url" {
type = string
default = ""
}
variable "datacenter_name" {
default = "Digital Ecosystems"
}
variable "datacenter_location" {
default = "de/txl"
}
variable "kubernetes_cluster_name" {
default = "federated-catalog"
}
variable "node_memory" {
type = number
default = 6144
}
variable "node_count" {
type = number
default = 1
}
variable "cores_count" {
type = number
default = 2
}
variable "create_private_lan" {
description = "Determines whether to create a private LAN for the Kubernetes cluster"
type = bool
default = true
}
provider "ionoscloud" {
endpoint = var.ionos_api_url
}
resource "ionoscloud_datacenter" "digital_ecosystems" {
name = var.datacenter_name
location = var.datacenter_location
description = ""
sec_auth_protection = false
}
##### Managed IONOS K8S
resource "ionoscloud_lan" "lan1" {
count = var.create_private_lan ? 1 : 0
datacenter_id = ionoscloud_datacenter.digital_ecosystems.id
public = false
name = "k8s-lan"
lifecycle {
create_before_destroy = true
}
timeouts {}
}
resource "ionoscloud_k8s_cluster" "kubernetes1" {
name = var.kubernetes_cluster_name
k8s_version = "1.28.6"
maintenance_window {
day_of_the_week = "Sunday"
time = "09:00:00Z"
}
timeouts {
}
}
resource "ionoscloud_k8s_node_pool" "pool2" {
datacenter_id = ionoscloud_datacenter.digital_ecosystems.id
k8s_cluster_id = ionoscloud_k8s_cluster.kubernetes1.id
name = "pool2"
k8s_version = ionoscloud_k8s_cluster.kubernetes1.k8s_version
maintenance_window {
day_of_the_week = "Sunday"
time = "03:01:04Z"
}
# auto_scaling {
# max_node_count = 2
# min_node_count = 1
# }
dynamic "lans" {
for_each = var.create_private_lan ? [1] : []
content {
id = ionoscloud_lan.lan1[0].id
dhcp = true
}
}
cpu_family = "INTEL_SKYLAKE"
availability_zone = "AUTO"
storage_type = "HDD"
node_count = var.node_count
cores_count = var.cores_count
ram_size = var.node_memory
storage_size = 20
timeouts {}
}
resource "ionoscloud_k8s_node_pool" "ingresspool" {
datacenter_id = ionoscloud_datacenter.digital_ecosystems.id
k8s_cluster_id = ionoscloud_k8s_cluster.kubernetes1.id
name = "federated-catalog-ingress-pool"
k8s_version = ionoscloud_k8s_cluster.kubernetes1.k8s_version
maintenance_window {
day_of_the_week = "Sunday"
time = "03:01:04Z"
}
dynamic "lans" {
for_each = var.create_private_lan ? [1] : []
content {
id = ionoscloud_lan.lan1[0].id
dhcp = true
}
}
cpu_family = "INTEL_SKYLAKE"
availability_zone = "AUTO"
storage_type = "HDD"
node_count = 1
cores_count = var.cores_count
ram_size = var.node_memory
storage_size = 20
timeouts {}
labels = {
nodepool = "ingress"
}
}
## configure access to the Container Registry in the K8S cluster
data "ionoscloud_k8s_cluster" "kubernetes1" {
id = ionoscloud_k8s_cluster.kubernetes1.id
}
resource "local_sensitive_file" "kubeconfig" {
content = yamlencode(jsondecode(data.ionoscloud_k8s_cluster.kubernetes1.kube_config))
filename = "kubeconfig-ionos.yaml"
}
provider "kubernetes" {
config_path = "kubeconfig-ionos.yaml"
config_context = "cluster-admin@federated-catalog"
}
provider "helm" {
kubernetes {
config_path = "kubeconfig-ionos.yaml"
}
}