terraform-google-modules / terraform-google-kubernetes-engine

Configures opinionated GKE clusters
https://registry.terraform.io/modules/terraform-google-modules/kubernetes-engine/google
Apache License 2.0
1.13k stars 1.16k forks source link

ASM Module fails #609

Closed chanuka-techo closed 4 years ago

chanuka-techo commented 4 years ago

I have tried with both master and v10.0.0.

Since my attempt was failing, I just tried the code from the example but still the result is the same.

Error: Error running command 'printf "%s" "$GOOGLE_CREDENTIALS" > .terraform/modules/asm.asm_install/terraform-google-gcloud-1.3.0/terraform-google-credentials.json &&
gcloud auth activate-service-account --key-file .terraform/modules/asm.asm_install/terraform-google-gcloud-1.3.0/terraform-google-credentials.json
': exit status 1. Output: ERROR: (gcloud.auth.activate-service-account) Could not read json file .terraform/modules/asm.asm_install/terraform-google-gcloud-1.3.0/terraform-google-credentials.json: Expecting value: line 1 column 1 (char 0)

Please find the full apply output (personal info redacted) on this gist

morgante commented 4 years ago

@bharathkkb Any ideas?

bharathkkb commented 4 years ago

@chanuka-techo the example has use_tf_google_credentials_env_var enabled which expects $GOOGLE_CREDENTIALS . Could you try setting to false instead? https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/blob/8a9f9041c8f18ff7a873873e9b19e03dcdfe7d2a/examples/simple_zonal_with_asm/main.tf#L62

chanuka-techo commented 4 years ago

Thanks, tried that and got the following error.

Error: Error running command 'PATH=/google-cloud-sdk/bin:$PATH
.terraform/modules/asm/terraform-google-kubernetes-engine-10.0.0/modules/asm/scripts/install_asm.sh *<Project ID>* *<Cluster Name>* *<Zone>*
': exit status 1. Output: kustomize is unavailable. Skipping ASM installation. Please install kustomize, add to PATH and rerun terraform apply.

I will install kustomize and continue.

Error: Error running command 'PATH=/google-cloud-sdk/bin:$PATH
.terraform/modules/asm/terraform-google-kubernetes-engine-10.0.0/modules/asm/scripts/install_asm.sh <Project ID> <Cluster Name> <Zone>
': exit status 127. Output: ~/work/mb/asm-dir ~/work/mb
Updated property [core/project].
WARNING: You do not appear to have access to project [*<Project ID>*] or it does not exist.
Downloading ASM patch
.terraform/modules/asm/terraform-google-kubernetes-engine-10.0.0/modules/asm/scripts/install_asm.sh: line 48: kpt: command not found

1) I had a different gcloud profile activated. 2) kpt was not installed

Error: Error running command 'PATH=/google-cloud-sdk/bin:$PATH
.terraform/modules/asm/terraform-google-kubernetes-engine-10.0.0/modules/asm/scripts/install_asm.sh <Project ID> <Cluster Name> <Zone>
': exit status 1. Output: ~/work/mb/asm-dir ~/work/mb
Updated property [core/project].
Downloading ASM patch
fetching package /asm-patch from https://github.com/GoogleCloudPlatform/anthos-service-mesh-packages to asm-patch
ERROR: (gcloud.beta.anthos.export) Could not locate anthos executable [anthoscli] on the system PATH. Please ensure gcloud anthos component is properly installed. See https://cloud.google.com/sdk/docs/components for more details.

anthoscli needs to be installed.

Apparently anthoscli installation also installs kpt and warns about system kpt (Mac, installed with brew).

Error: Error running command 'PATH=/google-cloud-sdk/bin:$PATH
.terraform/modules/asm/terraform-google-kubernetes-engine-10.0.0/modules/asm/scripts/install_asm.sh <Project ID> <Cluster Name> <Zone>
': exit status 1. Output: ~/work/mb/asm-dir ~/work/mb
Updated property [core/project].
ASM patch directory exists. Skipping download...
ERROR: (gcloud.beta.anthos.export) Could not locate anthos executable [anthoscli] on the system PATH. Please ensure gcloud anthos component is properly installed. See https://cloud.google.com/sdk/docs/components for more details.

anthoscli is not on path. Neither is kpt. Will see what's up with that.

At this point the problem is probably not with the ASM module. But I just documented the errors hoping it'll help some unfortunate soul who takes the same route.

bharathkkb commented 4 years ago

@chanuka-techo thanks for the update. I am fixing the kustomize and beta (anthoscli) dependency in #602. However kpt should have been automatically installed. If you get a chance, could you give it a shot with #602?

module "acm-example" {
  source = "github.com/terraform-google-modules/terraform-google-kubernetes-engine//modules/acm?ref=fix-gcloud-install"
.
.
.
}

Ideally, all of these should be automatically installed by the ASM module :)

chanuka-techo commented 4 years ago

I have shot myself in the foot somewhere back in time and kpt and anthoscli weren't being linked to $PATH properly. Sorted that and it went through fine.

So the trick was use_tf_google_credentials_env_var =false (false is the default, BTW).

chanuka-techo commented 4 years ago

@bharathkkb I see your change refers to a module named 'gcloud_wait_for_cluster'. This is an aside but reminded me how cluster creation always failed for me citing the subnet being not valid. I had to plan/apply again to start going. Should we need changes for kubernetes-engine modules as well?

bharathkkb commented 4 years ago

@chanuka-techo

Should we need changes for kubernetes-engine modules as well?

I am not sure if I understood this correctly, but if you were asking whether to change the source for GKE module, it is not necessary but you can. The main change in the PR is a bump up for the gcloud module version across all modules and fixing ASM dependencies.

chanuka-techo commented 4 years ago

Sorry, I misinterpreted the situation. This is a completely different problem. Maybe I'll report in appropriate place if needed.

Terraform reports that the subnet creation succeeds.

module.vpc.module.subnets.google_compute_subnetwork.subnetwork["asia-southeast1/mb-poc-subnet-gke"]: Creation complete after 34s [id=projects/<project-id>/regions/asia-southeast1/subnetworks/mb-poc-subnet-gke]

Still, I get below error every time I start from scratch. Gotta plan/apply again to continue.

Error: googleapi: Error 400: Subnetwork "projects/<project-id>/regions/asia-southeast1/subnetworks/mb-poc-subnet-gke" is not valid for Network "mb-poc-vpc"., badRequest

  on .terraform/modules/gke/terraform-google-kubernetes-engine-10.0.0/modules/beta-public-cluster/cluster.tf line 22, in resource "google_container_cluster" "primary":
  22: resource "google_container_cluster" "primary" {

Thanks for the prompt support!

chanuka-techo commented 4 years ago

@bharathkkb As you requested, I'm trying out #602

Just noticed you mentioned acm in your reply, not asm. Either it's a mistake or I really don't follow what's going on. Anyhow, trying out #602 for ASM.

bharathkkb commented 4 years ago

@chanuka-techo my apologies, I meant asm