-
Notifications
You must be signed in to change notification settings - Fork 86
/
main.tf
68 lines (57 loc) · 1.58 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
terraform {
required_version = ">= 1.7.0"
required_providers {
flux = {
source = "fluxcd/flux"
version = ">= 1.2"
}
gitlab = {
source = "gitlabhq/gitlab"
version = ">= 16.10"
}
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 Gitlab project
# ==========================================
resource "gitlab_project" "this" {
name = var.gitlab_project
description = "flux-bootstrap"
visibility_level = "private"
initialize_with_readme = true # This is extremely important as Flux expects an initialised repository
}
# ==========================================
# Add deploy token to Gitlab repository
# ==========================================
resource "tls_private_key" "flux" {
algorithm = "ECDSA"
ecdsa_curve = "P256"
}
resource "gitlab_deploy_key" "this" {
project = gitlab_project.this.path_with_namespace
title = "Flux"
key = tls_private_key.flux.public_key_openssh
can_push = true
}
# ==========================================
# Bootstrap KinD cluster
# ==========================================
resource "flux_bootstrap_git" "this" {
depends_on = [gitlab_deploy_key.this]
embedded_manifests = true
path = "clusters/my-cluster"
}