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

Failed to get namespace #2558

Open
MonicaMagoniCom opened this issue Jul 23, 2024 · 3 comments
Open

Failed to get namespace #2558

MonicaMagoniCom opened this issue Jul 23, 2024 · 3 comments
Assignees
Labels

Comments

@MonicaMagoniCom
Copy link

MonicaMagoniCom commented Jul 23, 2024

Terraform version: 1.7.4
Kubernetes provider version: 2.31.0
Kubernetes version: 1.28

I have a module called 'kube' where I create the following namespace:

resource "kubernetes_namespace" "pulsar-ns" {
  metadata {
    name = "pulsar2"
  }
}

Then in another module (which has a dependency on the kube module), so it is applied after the 'kube' module, I do:

resource "terraform_data" "prepare-pulsar-helm-release" {
  provisioner "local-exec" {
    command     = "./prepare_helm_release.sh -k pulsar -s -n ${var.pulsar-ns}"
    interpreter = ["bash", "-c"]
    working_dir = path.module
  }
  depends_on = [var.pulsar-ns]
}

When doing terraform apply, it correctly creates the namespace, but the local-exec fails with error (even though the ns exists):

exit status 1. Output: error: failed to get namespace 'pulsar2'
│ please check that this namespace exists, or use the '-c' option to create it
@jrhouston
Copy link
Collaborator

Thanks for opening an issue @MonicaMagoniCom – I suspect the problem may be with your depends_on configuration. Can you try the configuration with your terraform_data resource depending on the kubernetes_namespace directly instead of the var? This would tell us if there's a bug in the provider.

@MonicaMagoniCom
Copy link
Author

Actually it is not deterministic, sometimes it happens, sometimes it works. Anyway I'm going to remove the var and let you know, thank you.

@MonicaMagoniCom
Copy link
Author

I'm still experiecing the same issue. The namespace is created in the same apply command and it seems that the resource "prepare-pulsar-helm-release" sometimes does not find the namespace even if it was created some steps before.
Maybe do I have to split it into 2 terraform apply?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants