Добавлен код и промты.
This commit is contained in:
56
terraform/infra/dev/main.tf
Normal file
56
terraform/infra/dev/main.tf
Normal file
@@ -0,0 +1,56 @@
|
||||
locals {
|
||||
# Load environment variables if .env file exists
|
||||
env_vars = fileexists("${path.module}/.env") ? {
|
||||
for line in [
|
||||
for line in split("\n", file("${path.module}/.env"))
|
||||
: line if length(regexall("^[A-Za-z][A-Za-z0-9_]*=.*$", line)) > 0
|
||||
] : split("=", line)[0] => join("=", slice(split("=", line), 1, length(split("=", line))))
|
||||
} : {}
|
||||
}
|
||||
|
||||
module "k3s_cluster" {
|
||||
source = "../../modules/k3s-install"
|
||||
|
||||
# Required parameters
|
||||
server_ip = var.server_ip
|
||||
worker_ips = var.worker_ips
|
||||
ssh_user = var.ssh_user
|
||||
ssh_private_key = var.ssh_private_key
|
||||
replace_url = var.replace_url != "" ? var.replace_url : var.server_ip
|
||||
|
||||
# Optional parameters with defaults
|
||||
k3s_version = var.k3s_version
|
||||
k3s_channel = var.k3s_channel
|
||||
kubeconfig_path = var.kubeconfig_path
|
||||
node_token_path = var.node_token_path
|
||||
|
||||
# Conditional extra arguments
|
||||
k3s_extra_server_args = join(" ", compact([
|
||||
var.enable_traefik_dashboard ? "--set traefik.dashboard.enabled=true" : "",
|
||||
var.enable_ssl ? "--tls-san=${var.domain}" : "",
|
||||
var.k3s_extra_server_args
|
||||
]))
|
||||
|
||||
k3s_extra_agent_args = var.k3s_extra_agent_args
|
||||
}
|
||||
|
||||
# Output information about the deployed cluster
|
||||
output "kubeconfig" {
|
||||
description = "Path to the kubeconfig file"
|
||||
value = module.k3s_cluster.kubeconfig_path
|
||||
}
|
||||
|
||||
output "server_ip" {
|
||||
description = "IP address of the K3s server"
|
||||
value = module.k3s_cluster.server_ip
|
||||
}
|
||||
|
||||
output "worker_ips" {
|
||||
description = "IP addresses of K3s workers"
|
||||
value = module.k3s_cluster.worker_ips
|
||||
}
|
||||
|
||||
output "cluster_ready" {
|
||||
description = "Indicator that the cluster is ready"
|
||||
value = module.k3s_cluster.cluster_ready
|
||||
}
|
||||
Reference in New Issue
Block a user