diff --git a/bin/dev b/bin/dev index be053b9..9616236 100755 --- a/bin/dev +++ b/bin/dev @@ -41,7 +41,7 @@ function run-upload-tfvars() { kubectl -n $tfvar_ns create secret generic tfvars \ --dry-run=client \ --save-config \ - --from-file=tfvars=./$tfvar_file \ + --from-file=tfvars=$tfvar_file \ -o yaml | \ kubectl -n $tfvar_ns apply -f - } @@ -52,4 +52,24 @@ function run-download-tfvars() { kubectl -n $tfvar_ns get secrets/tfvars -o jsonpath='{.data.tfvars}' | base64 -d > $tfvar_file } +function run-template() { + : + : + app_name=${1} + tmp_folder=$ROOT_FOLDER/.tmp/homelab/tpl-$app_name + rm -rf $tmp_folder + mkdir -p $tmp_folder + kubectl get -n plugin-argo-cd applications.argoproj.io $app_name -o jsonpath='{.spec.source}' > $tmp_folder/spec.json + folder=$(cat $tmp_folder/spec.json | jq -r '.path') + cat $tmp_folder/spec.json | jq -r '.helm.values' > $tmp_folder/v.yaml + valuesFiles="--values "$(cat $tmp_folder/spec.json | jq -r '.helm.valueFiles | join(" --values ")') + pushd $ROOT_FOLDER/$folder &> /dev/null + hcmd="helm template --debug $valuesFiles --values $tmp_folder/v.yaml ." + echo $hcmd + $hcmd > $tmp_folder/rendered.yaml + cat $tmp_folder/rendered.yaml + echo $tmp_folder/rendered.yaml + popd &> /dev/null +} + start_cli $@ \ No newline at end of file diff --git a/tf-modules.tf b/tf-modules.tf index 1afeab8..c6a856f 100644 --- a/tf-modules.tf +++ b/tf-modules.tf @@ -17,8 +17,17 @@ resource "helm_release" "local-chart-infrastructure" { value = var.ssh_key } ] - timeout = 120 - force_update = true + values = [ + yamlencode({ + "global" : var.globals + }) + ] + timeout = 120 + force_update = true + lint = true + wait = true + wait_for_jobs = true + max_history = 4 } module "k8s-helm-charts" { diff --git a/tf-ns-ingress.tf b/tf-ns-ingress.tf new file mode 100644 index 0000000..8e0ea0f --- /dev/null +++ b/tf-ns-ingress.tf @@ -0,0 +1,14 @@ +resource "kubernetes_namespace_v1" "certs" { + metadata { + name = "certs" + } +} +resource "kubernetes_secret_v1" "cloudflare" { + metadata { + name = "cloudflare-api-token" + namespace = kubernetes_namespace_v1.certs.id + } + data = { + "api_token" : var.cloudflare.cm_api_token + } +} diff --git a/tf-variables.tf b/tf-variables.tf index faf0871..13686d5 100644 --- a/tf-variables.tf +++ b/tf-variables.tf @@ -1,8 +1,9 @@ variable "cloudflare" { sensitive = true type = object({ - api_token = string - account_id = string + api_token = string + account_id = string + cm_api_token = string }) } variable "main_domain" { @@ -27,3 +28,38 @@ variable "tailscale" { }) sensitive = true } + +variable "globals" { + type = object({ + deployment = string + email = string + timezone = string + + dns = object({ + primary = object({ + domain = string + root = optional(string, "") + }) + secondary = object({ + domain = string + root = optional(string, "") + }) + tls = object({ + enabled = bool + useWildCard = optional(bool, true) + skipTLSVerify = optional(bool, true) + issuer = optional(string, "letsencrypt") + acmeServer = optional(string, "https://acme-v02.api.letsencrypt.org/directory") + }) + }) + nfs = object({ + server = string + shares = object({ + k3s-cluster-pvc = string + }) + }) + smtp = object({ + email = string + }) + }) +}