Skip to content

Add mesh_id label from ASM module #1287

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

Conversation

Monkeyanator
Copy link

Up to now users have added the mesh_id label to their clusters after running the TF apply (usually after they realize metrics aren't working for their ASM install). This labels the cluster as part of the ASM module.

Not ideal since it adds another imperative step to the module but this is an important thing to get right out of the box and won't be needed at some point in the future.

@Monkeyanator Monkeyanator requested review from a team, Jberlinsky and bharathkkb as code owners June 9, 2022 23:49
@comment-bot-dev
Copy link

comment-bot-dev commented Jun 10, 2022

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

@Monkeyanator Monkeyanator force-pushed the add-cluster-labeling-to-module branch from f9a9185 to ca99fea Compare June 10, 2022 01:28
Copy link
Member

@bharathkkb bharathkkb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @Monkeyanator

Comment on lines +62 to +63
create_cmd_entrypoint = "gcloud"
create_cmd_body = "container clusters update ${var.cluster_name} --project=${var.project_id} --zone=${var.cluster_location} --update-labels=mesh_id=proj-${data.google_project.fleet.number}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will cause a diff when users manage clusters via TF. If users are managing ASM via TF, it seems reasonable to assume they will be managing clusters via TF too which means they can follow the docs in #1284

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, so the suggestion is to keep this as a documented step instead of including in the module? I'm fine with that as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think docs is easiest. Something we could investigate is if we can fail fast and surface error using https://www.terraform.io/language/meta-arguments/lifecycle#custom-condition-checks.

resource "kubernetes_namespace" "system" {
  metadata {
    name = "istio-system"
  }
    lifecycle {
    # The cluster must have mesh-id label
    precondition {
      condition     = contains( keys(data. google_container_cluster.asm.labels), "mesh_id") && maybe validate value too
      error_message = "The GKE cluster must have mesh_id label"
    }
  }
}

This will be a breaking change (due to min TF version bump) and require customers to upgrade to TF 1.2

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. Do we know how long before we expect it's reasonable to allow 1.2 features in our modules? Looks like it just released <1 month ago.

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.

3 participants