mirror of
https://github.com/outbackdingo/homelab-v.git
synced 2026-08-25 14:53:19 +00:00
feat(tofu): better way of using inlineManifests for bootstrapping Cilium
This solves #145
This commit is contained in:
@@ -7,7 +7,6 @@ module "talos" {
|
|||||||
|
|
||||||
image = var.talos_image
|
image = var.talos_image
|
||||||
cluster = var.talos_cluster_config
|
cluster = var.talos_cluster_config
|
||||||
cilium = var.cilium_config
|
|
||||||
nodes = var.talos_nodes
|
nodes = var.talos_nodes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,29 @@ data "talos_client_configuration" "this" {
|
|||||||
endpoints = [for k, v in var.nodes : v.ip if v.machine_type == "controlplane"]
|
endpoints = [for k, v in var.nodes : v.ip if v.machine_type == "controlplane"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resource "terraform_data" "cilium_bootstrap_inline_manifests" {
|
||||||
|
input = [
|
||||||
|
{
|
||||||
|
name = "cilium-bootstrap"
|
||||||
|
contents = file("${path.root}/${var.cluster.cilium.bootstrap_manifest_path}")
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = "cilium-values"
|
||||||
|
contents = yamlencode({
|
||||||
|
apiVersion = "v1"
|
||||||
|
kind = "ConfigMap"
|
||||||
|
metadata = {
|
||||||
|
name = "cilium-values"
|
||||||
|
namespace = "kube-system"
|
||||||
|
}
|
||||||
|
data = {
|
||||||
|
"values.yaml" = file("${path.root}/${var.cluster.cilium.values_file_path}")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
data "talos_machine_configuration" "this" {
|
data "talos_machine_configuration" "this" {
|
||||||
for_each = var.nodes
|
for_each = var.nodes
|
||||||
cluster_name = var.cluster.name
|
cluster_name = var.cluster.name
|
||||||
@@ -34,9 +57,8 @@ data "talos_machine_configuration" "this" {
|
|||||||
vip = var.cluster.vip
|
vip = var.cluster.vip
|
||||||
}), each.value.machine_type == "controlplane" ?
|
}), each.value.machine_type == "controlplane" ?
|
||||||
templatefile("${path.module}/machine-config/control-plane.yaml.tftpl", {
|
templatefile("${path.module}/machine-config/control-plane.yaml.tftpl", {
|
||||||
cilium_values = file("${path.root}/${var.cilium.values_path}")
|
|
||||||
cilium_install = file("${path.root}/${var.cilium.install_manifest_path}")
|
|
||||||
api_server = var.cluster.api_server
|
api_server = var.cluster.api_server
|
||||||
|
inline_manifests = jsonencode(terraform_data.cilium_bootstrap_inline_manifests.output)
|
||||||
}) : ""
|
}) : ""
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,18 +21,4 @@ cluster:
|
|||||||
extraManifests:
|
extraManifests:
|
||||||
- https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.2.1/standard-install.yaml
|
- https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.2.1/standard-install.yaml
|
||||||
- https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/v1.2.1/config/crd/experimental/gateway.networking.k8s.io_tlsroutes.yaml
|
- https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/v1.2.1/config/crd/experimental/gateway.networking.k8s.io_tlsroutes.yaml
|
||||||
inlineManifests:
|
inlineManifests: ${inline_manifests}
|
||||||
- name: cilium-values
|
|
||||||
contents: |
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: ConfigMap
|
|
||||||
metadata:
|
|
||||||
name: cilium-values
|
|
||||||
namespace: kube-system
|
|
||||||
data:
|
|
||||||
values.yaml: |-
|
|
||||||
${indent(10, cilium_values)}
|
|
||||||
- name: cilium-bootstrap
|
|
||||||
contents: |
|
|
||||||
${indent(6, cilium_install)}
|
|
||||||
|
|||||||
@@ -24,6 +24,10 @@ variable "cluster" {
|
|||||||
proxmox_cluster = string
|
proxmox_cluster = string
|
||||||
kubernetes_version = string
|
kubernetes_version = string
|
||||||
api_server = optional(string)
|
api_server = optional(string)
|
||||||
|
cilium = object({
|
||||||
|
bootstrap_manifest_path = string
|
||||||
|
values_file_path = string
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,11 +47,3 @@ variable "nodes" {
|
|||||||
igpu = optional(bool, false)
|
igpu = optional(bool, false)
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "cilium" {
|
|
||||||
description = "Cilium configuration"
|
|
||||||
type = object({
|
|
||||||
install_manifest_path = string
|
|
||||||
values_path = string
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -13,6 +13,10 @@ talos_cluster_config = {
|
|||||||
talos_machine_config_version = "v1.9.2"
|
talos_machine_config_version = "v1.9.2"
|
||||||
proxmox_cluster = "homelab"
|
proxmox_cluster = "homelab"
|
||||||
kubernetes_version = "1.32.0" # renovate: github-releases=kubernetes/kubernetes
|
kubernetes_version = "1.32.0" # renovate: github-releases=kubernetes/kubernetes
|
||||||
|
cilium = {
|
||||||
|
bootstrap_manifest_path = "talos/inline-manifests/cilium-install.yaml"
|
||||||
|
values_file_path = "../../k8s/infra/network/cilium/values.yaml"
|
||||||
|
}
|
||||||
api_server = <<-EOT
|
api_server = <<-EOT
|
||||||
extraArgs:
|
extraArgs:
|
||||||
oidc-issuer-url: "https://authelia.stonegarden.dev"
|
oidc-issuer-url: "https://authelia.stonegarden.dev"
|
||||||
@@ -23,8 +27,3 @@ talos_cluster_config = {
|
|||||||
oidc-groups-prefix: "authelia:"
|
oidc-groups-prefix: "authelia:"
|
||||||
EOT
|
EOT
|
||||||
}
|
}
|
||||||
|
|
||||||
cilium_config = {
|
|
||||||
values_path = "../../k8s/infra/network/cilium/values.yaml"
|
|
||||||
install_manifest_path = "talos/inline-manifests/cilium-install.yaml"
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -40,14 +40,10 @@ variable "talos_cluster_config" {
|
|||||||
proxmox_cluster = string
|
proxmox_cluster = string
|
||||||
kubernetes_version = string
|
kubernetes_version = string
|
||||||
api_server = optional(string)
|
api_server = optional(string)
|
||||||
})
|
cilium = object({
|
||||||
}
|
bootstrap_manifest_path = string
|
||||||
|
values_file_path = string
|
||||||
variable "cilium_config" {
|
})
|
||||||
description = "Path to Cilium installation manifest and configuration values"
|
|
||||||
type = object({
|
|
||||||
install_manifest_path = string
|
|
||||||
values_path = string
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user