############################################################ # Outputs for Hetzner Talos Kubernetes Cluster ############################################################ # Cluster Information output "cluster_name" { description = "The name of the Kubernetes cluster" value = local.cluster_name } output "cluster_id" { description = "The unique identifier for the cluster" value = random_string.cluster_id.result } # Network Information output "network_id" { description = "The ID of the cluster's private network" value = hcloud_network.cluster.id } output "network_cidr" { description = "The CIDR range of the cluster network" value = hcloud_network_subnet.cluster.ip_range } # Control Plane Information output "control_plane_ip" { description = "Public IP address of the control plane (LB or Floating IP)" value = local.cluster_endpoint_ip } output "load_balancer_ip" { description = "Public IP of the Load Balancer (if enabled)" value = var.enable_loadbalancer ? hcloud_load_balancer.cluster[0].ipv4 : null } output "control_plane_private_ips" { description = "Private IP addresses of control plane nodes" value = [for cp in hcloud_server_network.control_plane : cp.ip] } output "control_plane_ids" { description = "Server IDs of control plane nodes" value = [for cp in hcloud_server.control_plane : cp.id] } # Worker Nodes Information output "worker_ips" { description = "Public IP addresses of worker nodes" value = [for w in hcloud_server.worker : w.ipv4_address] } output "worker_private_ips" { description = "Private IP addresses of worker nodes" value = [for w in hcloud_server_network.worker : w.ip] } output "worker_ids" { description = "Server IDs of worker nodes" value = [for w in hcloud_server.worker : w.id] } # Kubernetes Access output "kubeconfig_path" { description = "Path to the generated kubeconfig file" value = local_sensitive_file.kubeconfig.filename } output "talosconfig_path" { description = "Path to the generated talosconfig file" value = local_sensitive_file.talosconfig.filename } # API Endpoints output "kubernetes_api_endpoint" { description = "Kubernetes API server endpoint" value = "https://${local.cluster_endpoint_ip}:6443" } output "talos_api_endpoint" { description = "Talos API endpoint for management" value = "https://${local.cluster_endpoint_ip}:50000" } # Cost Information output "estimated_monthly_cost" { description = "Estimated monthly cost for the infrastructure (USD)" value = { control_plane = local.control_plane_count * 4.59 worker = 1 * 4.59 load_balancer = var.enable_loadbalancer ? 5.99 : 0 floating_ip = var.enable_loadbalancer ? 0 : 3.29 total = (local.control_plane_count + 1) * 4.59 + (var.enable_loadbalancer ? 5.99 : 3.29) } } # Connection Instructions output "connection_instructions" { description = "Instructions for connecting to the cluster" value = <<-EOT ==================================== Kubernetes Cluster Ready! ==================================== 1. Configure kubectl: export KUBECONFIG=${local_sensitive_file.kubeconfig.filename} kubectl get nodes 2. Configure talosctl: export TALOSCONFIG=${local_sensitive_file.talosconfig.filename} talosctl --nodes ${local.cluster_endpoint_ip} health 3. Access Kubernetes API: https://${local.cluster_endpoint_ip}:6443 4. Nodes: Control Plane: ${local.control_plane_count}x CAX11 (ARM64) Workers: 1x CAX11 (ARM64) ${var.enable_loadbalancer ? "Load Balancer: LB11" : "Floating IP: IPv4"} ==================================== EOT } # Cluster Autoscaler Configuration output "autoscaler_worker_config" { description = "Worker machine config for cluster autoscaler (base64)" value = base64encode(data.talos_machine_configuration.worker[0].machine_configuration) sensitive = true } output "autoscaler_image_id" { description = "Talos image ID for cluster autoscaler" value = var.talos_image_id } # Resource Labels output "resource_labels" { description = "Labels applied to all resources" value = local.common_labels } # Firewall Information output "firewall_id" { description = "ID of the firewall protecting the cluster" value = hcloud_firewall.cluster.id } # SSH Key Information (for autoscaler) output "ssh_key_name" { description = "Name of the SSH key used by the cluster" value = length(local.ssh_key_matches) > 0 ? [ for key in data.hcloud_ssh_keys.all.ssh_keys : key.name if key.id == local.ssh_key_matches[0] ][0] : "${local.cluster_name}-admin" }