Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add required kubernetes provider to ASM module #1221

Conversation

Monkeyanator
Copy link
Contributor

This makes it so that if a user wants to create multiple clusters in a single application, they can pass a provider alias into the module to install ASM on both.

Example:

provider "kubernetes" {
  host                   = "https://${google_container_cluster.alpha.endpoint}"
  token                  = data.google_client_config.default.access_token
  cluster_ca_certificate = base64decode(google_container_cluster.alpha.master_auth[0].cluster_ca_certificate)
  alias                  = "cluster-alpha"
}

provider "kubernetes" {
  host                   = "https://${google_container_cluster.beta.endpoint}"
  token                  = data.google_client_config.default.access_token
  cluster_ca_certificate = base64decode(google_container_cluster.beta.master_auth[0].cluster_ca_certificate)
  alias                  = "cluster-beta"
}

resource "google_container_cluster" "alpha" {
  project            = var.project_id
  name               = "cluster-alpha"
  location           = var.region
  initial_node_count = 3
  workload_identity_config {
    workload_pool = "${var.project_id}.svc.id.goog"
  }
  timeouts {
    create = "30m"
    update = "40m"
  }
}

resource "google_container_cluster" "beta" {
  project            = var.project_id
  name               = "cluster-beta"
  location           = var.region
  initial_node_count = 3
  workload_identity_config {
    workload_pool = "${var.project_id}.svc.id.goog"
  }
  timeouts {
    create = "30m"
    update = "40m"
  }
}

module "asm-alpha" {
  source                    = "../modules/asm"
  project_id                = var.project_id
  cluster_name              = local.cluster_alpha_computed_name
  cluster_location          = var.region
  enable_cni                = true
  multicluster_mode         = "connected"
  enable_fleet_registration = true
  providers = {
    kubernetes = kubernetes.cluster-alpha
  }
}

module "asm-beta" {
  source                    = "../modules/asm"
  project_id                = var.project_id
  cluster_name              = local.cluster_beta_computed_name
  cluster_location          = var.region
  enable_cni                = true
  multicluster_mode         = "connected"
  enable_fleet_registration = true
  providers = {
    kubernetes = kubernetes.cluster-beta
  }
}

@comment-bot-dev
Copy link

Thanks for the PR! 🚀
✅ Lint checks have passed.

@morgante morgante merged commit 77d08e0 into terraform-google-modules:master Apr 13, 2022
CPL-markus pushed a commit to WALTER-GROUP/terraform-google-kubernetes-engine that referenced this pull request Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants