-
Notifications
You must be signed in to change notification settings - Fork 87
/
Copy pathmain.tf
73 lines (62 loc) · 1.79 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
terraform {
required_version = ">= 1.7.0"
required_providers {
flux = {
source = "fluxcd/flux"
version = ">= 1.2"
}
github = {
source = "integrations/github"
version = ">= 6.1"
}
kind = {
source = "tehcyx/kind"
version = ">= 0.4"
}
tls = {
source = "hashicorp/tls"
version = ">= 4.0"
}
}
}
# ==========================================
# Construct KinD cluster
# ==========================================
resource "kind_cluster" "this" {
name = "flux-e2e"
}
# ==========================================
# Initialise a Github project
# ==========================================
resource "github_repository" "this" {
name = var.github_repository
description = var.github_repository
visibility = "private"
auto_init = true # This is extremely important as flux_bootstrap_git will not work without a repository that has been initialised
}
# ==========================================
# Add deploy key to GitHub repository
# ==========================================
resource "tls_private_key" "flux" {
algorithm = "ECDSA"
ecdsa_curve = "P256"
}
resource "github_repository_deploy_key" "this" {
title = "Flux"
repository = github_repository.this.name
key = tls_private_key.flux.public_key_openssh
read_only = "false"
}
# ==========================================
# Bootstrap KinD cluster
# ==========================================
resource "flux_bootstrap_git" "this" {
depends_on = [github_repository_deploy_key.this]
components_extra = [
"image-reflector-controller",
"image-automation-controller"
]
embedded_manifests = true
kustomization_override = file("${path.root}/resources/flux-kustomization-patch.yaml")
path = "clusters/my-cluster"
}