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

Kubernetes provider errors while running terraform plan #354

Open
7 tasks
dfernandezm opened this issue Oct 13, 2022 · 0 comments
Open
7 tasks

Kubernetes provider errors while running terraform plan #354

dfernandezm opened this issue Oct 13, 2022 · 0 comments
Labels
bug Something isn't working
Milestone

Comments

@dfernandezm
Copy link
Owner

Task

Even though the main user or a service account with regular access is exported via GOOGLE_APPLICATION_CREDENTIALS, running terraform plan on the the crawler infra gives error:

(feature/change-cron-schedule)⚡ % terraform plan                                                                           ~/development/repos/moneycol/data-collector/crawler/infra/terraform/data-collector
kubernetes_secret.data_collector_key_secret: Refreshing state... [id=default/data-collector-key]
google_service_account.gke_resize_main_service_account: Refreshing state... [id=projects/moneycol/serviceAccounts/[email protected]]
google_service_account.data_collector_main_service_account: Refreshing state... [id=projects/moneycol/serviceAccounts/[email protected]]
google_storage_bucket.functions_bucket: Refreshing state... [id=moneycol-functions]
google_project_iam_custom_role.data_collector_role: Refreshing state... [id=projects/moneycol/roles/data_collector]
google_project_iam_custom_role.gke_resize_role: Refreshing state... [id=projects/moneycol/roles/gke_resize]
google_service_account_key.gke_resize_sa_key: Refreshing state... [id=projects/moneycol/serviceAccounts/[email protected]/keys/6230032c9b887c3a7a9ddfcbf710388397dc10b7]
google_service_account_key.data_collector_sa_key: Refreshing state... [id=projects/moneycol/serviceAccounts/[email protected]/keys/4d5c2da5d7e033e4664ae2e038e8820ddb812dce]
google_cloud_scheduler_job.start_crawler_job: Refreshing state... [id=projects/moneycol/locations/europe-west1/jobs/start-crawler]
google_project_iam_binding.data_collector_sa_project_iam_binding: Refreshing state... [id=moneycol/projects/moneycol/roles/data_collector]
google_project_iam_binding.gke_resize_sa_project_iam_binding: Refreshing state... [id=moneycol/projects/moneycol/roles/gke_resize]
google_storage_bucket_object.archive: Refreshing state... [id=moneycol-functions-resize-down-indexer.zip#fed7fa94c81ada72baba99773d40c834]
google_cloudfunctions_function.resize_function: Refreshing state... [id=projects/moneycol/locations/europe-west1/functions/resize-down-indexer]
╷
│ Error: secrets "data-collector-key" is forbidden: User "xxx" cannot get resource "secrets" in API group "" in the namespace "default": requires one of ["container.secrets.get"] permission(s).
│
│
╵

This looks like it's using some cached credentials, but that's not the case. Mainly what's happening is that terraform is failing to communicate with GKE.

Running the auth manually via gcloud makes the above plan work:

gcloud container clusters get-credentials cluster-dev2 --zone europe-west1-b --project moneycol

But this issue should be solved by correctly authenticating the terraform provider with GKE. Information is at https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/using_gke_with_terraform#interacting-with-kubernetes

Acceptance criteria

  • Terraform kubernetes provider can be used against the existing GKE cluster to create a SA key without errors/extra auth

Definition of Done

    • Can run terraform plan without issuing any other gcloud command
    • Can run terraform plan outside local machine
    • Can run terraform apply and resources are created in the cluster
    • Pull Request and self review
    • Merge
    • Parent story linked
@dfernandezm dfernandezm added this to the 0.9.1 milestone Oct 13, 2022
@dfernandezm dfernandezm added the bug Something isn't working label Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant