++ fall back to in-cluster kubernetes auth when KUBECONFIG file doesn't exist
All checks were successful
Terraform Terragrunt (contour) / validate (push) Successful in 1m14s
Terraform Terragrunt (contour) / plan (push) Successful in 1m35s
Terraform Terragrunt (contour) / apply (push) Successful in 1m19s

This commit is contained in:
Kochetkov S 2026-08-05 17:59:23 +03:00
parent 74f4e11b1d
commit 573e8d04f6

View File

@ -58,8 +58,14 @@ variable "kube_context" {
} }
provider "kubernetes" { provider "kubernetes" {
config_path = var.kubeconfig_path != "" ? var.kubeconfig_path : null # KUBECONFIG is set unconditionally at job level for the external-runner case
config_context = var.kube_context != "" ? var.kube_context : null # (see .gitea/workflows/terraform.yml "Prepare kubeconfig"); on an in-cluster
# runner that file is never written (no KUBECONFIG_B64), so fileexists() must
# gate this - a non-empty path alone isn't enough, else the provider tries to
# read a file that was never created and falls over instead of using the pod
# ServiceAccount / in-cluster config.
config_path = var.kubeconfig_path != "" && fileexists(var.kubeconfig_path) ? var.kubeconfig_path : null
config_context = var.kubeconfig_path != "" && fileexists(var.kubeconfig_path) ? var.kube_context : null
} }
# Vault: static VAULT_TOKEN if provided, else in-cluster k8s auth by the runner SA. # Vault: static VAULT_TOKEN if provided, else in-cluster k8s auth by the runner SA.