From fe149a318179912c9757d1bb85bd4a885f7470d4 Mon Sep 17 00:00:00 2001 From: BryanFauble <17128019+BryanFauble@users.noreply.github.com> Date: Mon, 20 May 2024 12:39:13 -0700 Subject: [PATCH] Set kube context via config path --- modules/internal-k8-infra/provider.tf | 4 ++-- modules/internal-k8-infra/variables.tf | 6 ++++++ provider.tf | 1 + variables.tf | 6 ++++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/modules/internal-k8-infra/provider.tf b/modules/internal-k8-infra/provider.tf index d771695a..451c9b98 100644 --- a/modules/internal-k8-infra/provider.tf +++ b/modules/internal-k8-infra/provider.tf @@ -8,7 +8,7 @@ provider "spotinst" { } provider "kubernetes" { - config_path = "~/.kube/config" + config_path = var.kube_config_path host = data.aws_eks_cluster.cluster.endpoint cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority[0].data) token = data.aws_eks_cluster_auth.cluster.token @@ -16,6 +16,6 @@ provider "kubernetes" { provider "helm" { kubernetes { - config_path = "~/.kube/config" + config_path = var.kube_config_path } } diff --git a/modules/internal-k8-infra/variables.tf b/modules/internal-k8-infra/variables.tf index 113e2d23..8c8cde6f 100644 --- a/modules/internal-k8-infra/variables.tf +++ b/modules/internal-k8-infra/variables.tf @@ -4,6 +4,12 @@ variable "cluster_name" { default = "dpe-k8" } +variable "kube_config_path" { + description = "Kube config path" + type = string + default = "~/.kube/config" +} + variable "region" { description = "AWS region" type = string diff --git a/provider.tf b/provider.tf index 02104066..e57ccf43 100644 --- a/provider.tf +++ b/provider.tf @@ -8,6 +8,7 @@ provider "spotinst" { } provider "kubernetes" { + config_path = var.kube_config_path host = data.aws_eks_cluster.cluster.endpoint cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority.0.data) token = data.aws_eks_cluster_auth.cluster.token diff --git a/variables.tf b/variables.tf index c3e737d4..9eb7308d 100644 --- a/variables.tf +++ b/variables.tf @@ -10,6 +10,12 @@ variable "cluster_version" { default = "1.29" } +variable "kube_config_path" { + description = "Kube config path" + type = string + default = "~/.kube/config" +} + variable "cidr" { description = "CIDR block for the VPC" type = string