-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathgitea.tf
156 lines (154 loc) · 3.85 KB
/
gitea.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
locals {
gitea_domain = "gitea.${var.ingress_domain}"
gitea_namespace = "gitea"
gitea_manifests = [
{
apiVersion = "v1"
kind = "Namespace"
metadata = {
name = local.gitea_namespace
}
},
{
apiVersion = "cert-manager.io/v1"
kind = "Certificate"
metadata = {
name = "gitea"
namespace = local.gitea_namespace
}
spec = {
subject = {
organizations = [
var.ingress_domain,
]
organizationalUnits = [
"Kubernetes",
]
}
commonName = "gitea"
dnsNames = [
local.gitea_domain,
]
privateKey = {
algorithm = "ECDSA" # NB Ed25519 is not yet supported by chrome 93 or firefox 91.
size = 256
}
duration = "4320h" # NB 4320h (180 days). default is 2160h (90 days).
secretName = "gitea-tls"
issuerRef = {
kind = "ClusterIssuer"
name = "ingress"
}
}
},
]
gitea_manifest = join("---\n", [data.kustomizer_manifest.gitea.manifest], [for d in local.gitea_manifests : yamlencode(d)])
}
# set the configuration.
# NB the default values are described at:
# https://gitea.com/gitea/helm-chart/src/tag/v10.6.0/values.yaml
# NB make sure you are seeing the same version of the chart that you are installing.
# see https://registry.terraform.io/providers/hashicorp/helm/latest/docs/data-sources/template
data "helm_template" "gitea" {
namespace = local.gitea_namespace
name = "gitea"
repository = "https://dl.gitea.com/charts"
chart = "gitea"
# see https://artifacthub.io/packages/helm/gitea/gitea
# renovate: datasource=helm depName=gitea registryUrl=https://dl.gitea.com/charts
version = "10.6.0" # app version 1.22.3.
kube_version = var.kubernetes_version
api_versions = [
"networking.k8s.io/v1/Ingress",
]
values = [yamlencode({
redis-cluster = {
enabled = false
}
redis = {
enabled = false
}
postgresql = {
enabled = false
}
postgresql-ha = {
enabled = false
}
persistence = {
enabled = true
storageClass = "linstor-lvm-r1"
claimName = "gitea"
}
gitea = {
config = {
database = {
DB_TYPE = "sqlite3"
}
session = {
PROVIDER = "memory"
}
cache = {
ADAPTER = "memory"
}
queue = {
TYPE = "level"
}
}
admin = {
username = "gitea"
password = "gitea"
email = "gitea@${var.ingress_domain}"
}
}
service = {
http = {
type = "ClusterIP"
port = 3000
clusterIP = null
}
ssh = {
type = "ClusterIP"
port = 22
clusterIP = null
}
}
ingress = {
enabled = true
hosts = [
{
host = local.gitea_domain
paths = [
{
path = "/"
pathType = "Prefix"
}
]
}
]
tls = [
{
secretName = "gitea-tls"
hosts = [
local.gitea_domain,
]
}
]
}
})]
}
# NB we mainly use the Kustomization to set the gitea namespace (because the
# helm chart cannot do it).
# see https://gitea.com/gitea/helm-chart/issues/630
# see https://registry.terraform.io/providers/rgl/kustomizer/latest/docs/data-sources/manifest
data "kustomizer_manifest" "gitea" {
files = {
"kustomization.yaml" = <<-EOF
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: ${yamlencode(local.gitea_namespace)}
resources:
- resources/resources.yaml
EOF
"resources/resources.yaml" = data.helm_template.gitea.manifest
}
}