From 93ee9e025e1e70b1d01dceb11c09a1d32ee106dc Mon Sep 17 00:00:00 2001 From: Khue Doan Date: Thu, 22 Apr 2021 00:12:14 +0700 Subject: [PATCH] Add cluster bootstrap --- infra/modules/kubernetes-cluster-bootstrap/terraform.tf | 8 ++++---- infra/modules/kubernetes-cluster-bootstrap/variables.tf | 3 +++ infra/platform/bootstrap.tf | 4 ++++ 3 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 infra/platform/bootstrap.tf diff --git a/infra/modules/kubernetes-cluster-bootstrap/terraform.tf b/infra/modules/kubernetes-cluster-bootstrap/terraform.tf index 224451e5..6e2b9244 100644 --- a/infra/modules/kubernetes-cluster-bootstrap/terraform.tf +++ b/infra/modules/kubernetes-cluster-bootstrap/terraform.tf @@ -9,9 +9,9 @@ terraform { provider "helm" { kubernetes { - host = var.kubeconfig.host - client_certificate = var.kubeconfig.client_certificate - client_key = var.kubeconfig.client_key - cluster_ca_certificate = var.kubeconfig.cluster_ca_certificate + host = yamldecode(var.kube_config)["clusters"][0]["cluster"]["server"] + cluster_ca_certificate = base64decode(yamldecode(var.kube_config)["clusters"][0]["cluster"]["certificate-authority-data"]) + client_certificate = base64decode(yamldecode(var.kube_config)["users"][0]["user"]["client-certificate-data"]) + client_key = base64decode(yamldecode(var.kube_config)["users"][0]["user"]["client-key-data"]) } } diff --git a/infra/modules/kubernetes-cluster-bootstrap/variables.tf b/infra/modules/kubernetes-cluster-bootstrap/variables.tf index e69de29b..bd7b3977 100644 --- a/infra/modules/kubernetes-cluster-bootstrap/variables.tf +++ b/infra/modules/kubernetes-cluster-bootstrap/variables.tf @@ -0,0 +1,3 @@ +variable "kube_config" { + description = "Kubernetes config" +} diff --git a/infra/platform/bootstrap.tf b/infra/platform/bootstrap.tf new file mode 100644 index 00000000..86059ed3 --- /dev/null +++ b/infra/platform/bootstrap.tf @@ -0,0 +1,4 @@ +module "rke_cluster_bootstrap" { + source = "../modules/kubernetes-cluster-bootstrap" + kube_config = rke_cluster.cluster.kube_config_yaml +}