-
Notifications
You must be signed in to change notification settings - Fork 0
Various bug fixes and improvements #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| .PHONY: init plan deploy destroy | ||
|
|
||
| TERRAFORM_DIR := terraform | ||
|
|
||
| init: | ||
| cd $(TERRAFORM_DIR) && terraform init | ||
|
|
||
| plan: | ||
| cd $(TERRAFORM_DIR) && terraform plan | ||
|
|
||
| deploy: | ||
| cd $(TERRAFORM_DIR) && terraform apply | ||
|
|
||
| destroy: | ||
| cd $(TERRAFORM_DIR) && terraform destroy |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| locals { | ||
| lb_ip = try(data.kubernetes_service_v1.ingress_nginx.status[0].load_balancer[0].ingress[0].ip, null) | ||
| } | ||
|
|
||
| resource "digitalocean_domain" "main" { | ||
| name = var.domain_name | ||
| } | ||
|
|
||
| resource "digitalocean_record" "gitlab" { | ||
| count = local.lb_ip != null ? 1 : 0 | ||
|
|
||
| domain = digitalocean_domain.main.name | ||
| type = "A" | ||
| name = var.gitlab_host | ||
| value = locals.lb_ip | ||
| ttl = 300 | ||
| } | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,11 +23,30 @@ resource "kubernetes_namespace_v1" "gitlab" { | |
| } | ||
|
|
||
| resource "kubernetes_manifest" "cluster_issuer" { | ||
| manifest = yamldecode(file("${path.module}/../kubernetes/cluster-issuer.yaml")) | ||
| manifest = yamldecode(templatefile("${path.module}/../kubernetes/cluster-issuer.yaml", { | ||
| email = var.email | ||
| })) | ||
|
|
||
| depends_on = [ helm_release.cert_manager ] | ||
| } | ||
|
|
||
| resource "random_password" "gitlab_root" { | ||
| length = 64 | ||
| } | ||
|
|
||
| resource "kubernetes_secret_v1" "gitlab_initial_root_password" { | ||
| metadata { | ||
| name = "gitlab-initial-root-password" | ||
| namespace = kubernetes_namespace_v1.gitlab.metadata[0].name | ||
| } | ||
|
|
||
| data = { | ||
| password = random_password.gitlab_root.result | ||
| } | ||
|
|
||
| type = "Opaque" | ||
| } | ||
|
Comment on lines
+37
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add this secret to
🛠 Follow-up change outside this hunk resource "helm_release" "gitlab" {
...
depends_on = [
+ kubernetes_secret_v1.gitlab_initial_root_password,
kubernetes_secret_v1.gitlab_postgres,
kubernetes_secret_v1.gitlab_redis,
kubernetes_secret_v1.gitlab_s3_main,
digitalocean_database_db.gitlab
]
} |
||
|
|
||
| resource "kubernetes_secret_v1" "gitlab_postgres" { | ||
| metadata { | ||
| name = "gitlab-postgres-secret" | ||
|
|
@@ -111,4 +130,13 @@ resource "kubernetes_secret_v1" "gitlab_s3_backup" { | |
| } | ||
|
|
||
| type = "Opaque" | ||
| } | ||
|
|
||
| data "kubernetes_service_v1" "ingress_nginx" { | ||
| metadata { | ||
| name = "ingress-nginx-controller" | ||
| namespace = kubernetes_namespace_v1.ingress_nginx.metadata[0].name | ||
| } | ||
|
|
||
| depends_on = [helm_release.ingress_nginx] | ||
|
Comment on lines
+135
to
+141
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: git ls-files | grep -E '\.tf$' | head -20Repository: clofour/gitlab-kubernetes Length of output: 316 🏁 Script executed: wc -l terraform/kubernetes.tfRepository: clofour/gitlab-kubernetes Length of output: 96 🏁 Script executed: cat -n terraform/kubernetes.tfRepository: clofour/gitlab-kubernetes Length of output: 4560 🏁 Script executed: cat -n terraform/dns.tfRepository: clofour/gitlab-kubernetes Length of output: 445 🏁 Script executed: cat -n terraform/helm.tfRepository: clofour/gitlab-kubernetes Length of output: 2275 🏁 Script executed: rg "ingress_nginx" terraform/ -A 3 -B 3Repository: clofour/gitlab-kubernetes Length of output: 1448 🏁 Script executed: rg "digitalocean_record\|digitalocean_domain" terraform/ -A 2 -B 2Repository: clofour/gitlab-kubernetes Length of output: 51 🏁 Script executed: cat -n terraform/dns.tfRepository: clofour/gitlab-kubernetes Length of output: 445 🏁 Script executed: rg "timeouts\|wait" terraform/ -iRepository: clofour/gitlab-kubernetes Length of output: 51 🏁 Script executed: rg "lifecycle\|create_before_destroy" terraform/Repository: clofour/gitlab-kubernetes Length of output: 51 🏁 Script executed: cat -n terraform/outputs.tfRepository: clofour/gitlab-kubernetes Length of output: 1478 Add timeout to data source to wait for load balancer provisioning. The Add a |
||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -39,6 +39,14 @@ variable "node_count" { | |||||||||||||||||||||
| default = 2 | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| variable "email" { | ||||||||||||||||||||||
| type = string | ||||||||||||||||||||||
| validation { | ||||||||||||||||||||||
| condition = trimspace(var.email) != "" | ||||||||||||||||||||||
| error_message = "email must not be empty." | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
+42
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: git ls-files | grep -E "terraform|kubernetes" | head -20Repository: clofour/gitlab-kubernetes Length of output: 419 🏁 Script executed: cat -n terraform/variables.tf | head -60Repository: clofour/gitlab-kubernetes Length of output: 1245 🏁 Script executed: cat -n terraform/kubernetes.tf | grep -A 5 -B 5 "email"Repository: clofour/gitlab-kubernetes Length of output: 434 🏁 Script executed: cat -n kubernetes/cluster-issuer.yamlRepository: clofour/gitlab-kubernetes Length of output: 485 🏁 Script executed: cat -n terraform/variables.tf | grep -A 10 "validation"Repository: clofour/gitlab-kubernetes Length of output: 51 🏁 Script executed: web_search
What is the Terraform variable validation block syntax for string variables?Repository: clofour/gitlab-kubernetes Length of output: 162 🌐 Web query:
💡 Result: The syntax for a Terraform variable validation block using trimspace checks if a string variable has no leading or trailing whitespace by comparing the original value to its trimmed version. Example: variable "hostname" { type = string validation { condition = var.hostname == trimspace(var.hostname) error_message = "Hostname must not contain leading or trailing whitespace." } } This uses the built-in trimspace function, which removes Unicode whitespace (spaces, tabs, newlines, etc.) from both ends of the string. The validation block requires a boolean condition expression that must evaluate to true and a descriptive error_message. Terraform evaluates this during plan creation; if false, it errors with the message and halts. You can add multiple validation blocks for different checks or use trimspace(var.name) in locals for normalization without validation. Citations:
Reject empty ACME emails at plan time. This variable is required, but 🔍 Suggested change variable "email" {
type = string
+ validation {
+ condition = trimspace(var.email) != ""
+ error_message = "email must be non-empty."
+ }
}📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| variable "domain_name" { | ||||||||||||||||||||||
| type = string | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use
var.gitlab_hostfor the A record name.The chart already allows overriding the GitLab hostname, but this record is pinned to
"gitlab". Any non-defaultgitlab_hostwill publish the wrong DNS name and the ingress host won't resolve.🛠 Suggested change
resource "digitalocean_record" "gitlab" { domain = digitalocean_domain.main.name type = "A" - name = "gitlab" + name = var.gitlab_host value = data.kubernetes_service_v1.ingress_nginx.status[0].load_balancer[0].ingress[0].ip ttl = 300 }📝 Committable suggestion