infra: deploy kube-vip with terraform

This commit is contained in:
2025-07-01 09:50:55 +03:00
parent 82421c60cb
commit 79e4a02657
5 changed files with 35 additions and 8 deletions

View File

@ -7,12 +7,12 @@
This directory contains Terraform configurations for managing This directory contains Terraform configurations for managing
infrastructure resources. It includes configurations for Proxmox. infrastructure resources. It includes configurations for Proxmox.
The plan is to eventually migrate all infrastructure management to Terraform, Currently, only the Proxmox virtual machines are managed using Terraform.
including Kubernetes clusters and other resources. Currently, the Proxmox Kubernetes clusters are still created with Ansible, and Kubernetes resources are
configuration is fully managed by Terraform, while Kubernetes resources are managed using Helm charts and kubectl. Previously, Proxmox was also managed with
managed using Helm charts and kubectl commands. Previously, the Proxmox Ansible, but it has been moved to Terraform for improved consistency and state
configuration was managed using Ansible, but it has been migrated to Terraform management. The goal is to eventually manage all infrastructure—including
for better consistency and state management. Kubernetes clusters—using Terraform.
The terraform state files are stored in a remote backend, which allows for The terraform state files are stored in a remote backend, which allows for
collaboration and state management across different environments. The backend collaboration and state management across different environments. The backend

View File

@ -0,0 +1,16 @@
# No new namespace is required since it is being deployed in kube-system namespace.
resource "helm_release" "kube_vip" {
name = "kube-vip"
repository = "https://kube-vip.github.io/helm-charts"
chart = "kube-vip"
version = "0.6.6"
atomic = true
namespace = "kube-system"
values = [
templatefile("${var.kubernetes_project_path}/kube-vip/values.yaml", {
VIP_ADDRESS = var.vip_address
})
]
}

View File

@ -16,7 +16,7 @@ provider "kubernetes" {
} }
provider "helm" { provider "helm" {
kubernetes { kubernetes = {
config_path = "~/.kube/config" config_path = "~/.kube/config"
} }
} }

View File

@ -32,4 +32,15 @@ variable "docker_username" {
variable "docker_password" { variable "docker_password" {
description = "Docker registry password" description = "Docker registry password"
type = string type = string
}
variable "kubernetes_project_path" {
description = "Path to the Kubernetes configuration files"
type = string
default = "../../../kubernetes"
}
variable "vip_address" {
description = "VIP address for kube-vip"
type = string
} }

View File

@ -1,6 +1,6 @@
# custom-values.yaml # custom-values.yaml
config: config:
address: $VIP_ADDRESS address: "${VIP_ADDRESS}"
env: env:
# Ensure the interface name is correct for the Nodes # Ensure the interface name is correct for the Nodes
# Can be found using `ip a` command # Can be found using `ip a` command