Search code examples
dockerkubernetesminikubeterragrunt

Terraform / terragrunt and minikube: What is my host IP?


I have installed an started minikube like within the offical docs.

My minikube is running fine and "minikube dashboard" shows me all running things.

Now I want to deploy my terraform code to it. I start with a test namespace to see if it is working. I use terragrunt to capsule my code:

local/terragrunt.hcl*

locals {
  environment    = "dev"
  workload       = "rk"
}

inputs = {
  environment    = local.environment
  azure_region   = "local"
  workload       = local.workload
  kube_namespace = "one"

  kube_host                   = "https://172.17.0.2:55010"
  kube_client_certificate     = file("C:/Users/R/.minikube/profiles/minikube/client.crt")
  kube_client_key             = file("C:/Users/R/.minikube/profiles/minikube/client.key")
  kube_cluster_ca_certificate = file("C:/Users/R/.minikube/ca.crt")
}

remote_state {
  backend = "local"
  generate = {
    path      = "backend.tf"
    if_exists = "overwrite_terragrunt"
  }
  config = {
    path = "./terraform.tfstate"
  }
}

local/ns/terragrunt.hcl

include "environment_configration" {
  path   = find_in_parent_folders()
  expose = true
}

terraform {
  source = "../../../modules/services/azure-kubernetes-namespace///"
}

inputs = {

}

module

provider "kubernetes" {
  host                   = "${var.kube_host}"
  client_certificate     = "${var.kube_client_certificate}"
  client_key             = "${var.kube_client_key}"
  cluster_ca_certificate = "${var.kube_cluster_ca_certificate}"
}

resource "kubernetes_namespace" "ns" {
  metadata {
    name = var.kube_namespace
  }
}

Now I start "terragrund run-all apply" in the main forder, but terragrunt can't connect to the kubernetes cluster. All IPs seems wrong.

What I tried:

  • The "minikube IP"-Command and the output of this with several ports
  • The ip shown in my docker desktop of my windows 11 machine with several ports
  • localhost
  • The kubernetes cluster IP from "kubectl get svc" command with several ports

Nothing...

Any idea?


Solution

  • Found it.

    You need to see the conf file: "kubectl config view" and there the server IP with the correct port is written (cluster name minikube)