home-cloud/k3s_cluster_v2/flux.tf
Julian Tölle 6ea9911f29 fix: remove broken kube configs from state
Broke when i redid the cluster ca stuff to fix an expired cert. Cant
figure out how to fix the state to read from the cluster.
2023-02-25 23:24:23 +01:00

66 lines
1.7 KiB
HCL

provider "github" {
owner = var.github_owner
token = var.github_token
}
# SSH
locals {
known_hosts = "github.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg="
}
resource "tls_private_key" "main" {
algorithm = "ECDSA"
ecdsa_curve = "P256"
}
# Flux
data "flux_install" "main" {
target_path = var.target_path
version = var.flux_version
}
data "flux_sync" "main" {
target_path = var.target_path
url = "ssh://git@github.com/${var.github_owner}/${var.repository_name}.git"
branch = var.branch
}
# GitHub
resource "github_repository" "main" {
name = var.repository_name
visibility = var.repository_visibility
auto_init = true
}
resource "github_branch_default" "main" {
repository = github_repository.main.name
branch = var.branch
}
resource "github_repository_deploy_key" "main" {
title = "staging-cluster"
repository = github_repository.main.name
key = tls_private_key.main.public_key_openssh
read_only = true
}
resource "github_repository_file" "install" {
repository = github_repository.main.name
file = data.flux_install.main.path
content = data.flux_install.main.content
branch = var.branch
}
resource "github_repository_file" "sync" {
repository = github_repository.main.name
file = data.flux_sync.main.path
content = data.flux_sync.main.content
branch = var.branch
}
resource "github_repository_file" "kustomize" {
repository = github_repository.main.name
file = data.flux_sync.main.kustomize_path
content = data.flux_sync.main.kustomize_content
branch = var.branch
}