Initial Implementation of K3S Cluster with YoshiK3S

This commit is contained in:
2024-07-11 03:37:34 -03:00
parent 60cf7ab1b2
commit 9146eebe73
4 changed files with 163 additions and 44 deletions

63
kubernetes/kubernetes.tf Normal file
View File

@@ -0,0 +1,63 @@
terraform {
required_providers {
yoshik3s = {
source = "HideyoshiNakazone/yoshik3s"
version = "0.1.1"
}
}
}
# Cluster Configuration
resource "yoshik3s_cluster" "main_cluster" {
name = "main-cluster"
token = var.cluster_token
k3s_version = "v1.30.2+k3s2"
}
resource "yoshik3s_master_node" "master_node" {
cluster = {
token = yoshik3s_cluster.main_cluster.token
k3s_version = yoshik3s_cluster.main_cluster.k3s_version
}
count = length(var.cluster_main_node)
node_connection = {
host = var.cluster_main_node[count.index].host
port = var.cluster_main_node[count.index].port
user = var.cluster_main_node[count.index].user
private_key = var.cluster_main_node[count.index].private_key
}
node_options = [
"--disable traefik",
"--node-label node_type=master",
"--tls-san ${var.cluster_domain}"
]
}
resource "yoshik3s_worker_node" "worker_node" {
master_server_address = var.master_server_address
cluster = {
token = yoshik3s_cluster.main_cluster.token
k3s_version = yoshik3s_cluster.main_cluster.k3s_version
}
count = length(var.cluster_worker_node)
node_connection = {
host = var.cluster_worker_node[count.index].host
port = var.cluster_worker_node[count.index].port
user = var.cluster_worker_node[count.index].user
private_key = var.cluster_worker_node[count.index].private_key
}
node_options = [
"--node-label node_type=worker",
]
}