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

Cannot create ingress in a different namespace than the backend #1198

Closed
goobysnack opened this issue Mar 14, 2021 · 3 comments
Closed

Cannot create ingress in a different namespace than the backend #1198

goobysnack opened this issue Mar 14, 2021 · 3 comments

Comments

@goobysnack
Copy link

goobysnack commented Mar 14, 2021

Terraform Version, Provider Version and Kubernetes Version

Terraform version: v0.12.28
Kubernetes provider version: 2.02
Kubernetes version: 1.18.12

Affected Resource(s)

  • kubernetes_ingress

Terraform Configuration Files

I removed the other data blocks as they are working fine.

data "kubernetes_service" "service" {
  metadata {
    name = "hellonode"
    namespace = "default"
  }
}

resource "kubernetes_ingress" "ingress" {
  depends_on = [google_compute_global_address.vs_address]
  wait_for_load_balancer = true
  metadata {
    name = "hello-test3-foo-io"
    //namespace = "edge" <-- I'd like to create the ingress in this namespace and use a backend service in default
    annotations = {
      "kubernetes.io/ingress.global-static-ip-name" = google_compute_global_address.vs_address.name
      "kubernetes.io/ingress.class" = "gce"  
    }
  }

  spec {
    backend {
      service_name = data.kubernetes_service.service.metadata.0.name
      service_port = 80
    }
  }
}

Debug Output

no gist

Panic Output

none

Steps to Reproduce

Expected Behavior

ingress created in edge namespace with backend in default

Actual Behavior

This error:
"Translation failed: invalid ingress spec: could not find service "edge/hellonode""
It's looking for the service name in the same namespace instead of using the default based on the data resource:

Important Factoids

None

References

None

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
@goobysnack goobysnack added the bug label Mar 14, 2021
@goobysnack
Copy link
Author

If I put the namespace in the name, it gives this error:

service_name = "default/${data.kubernetes_service.service.metadata.0.name}"

Error: Failed to create Ingress 'edge/hello-test3-foo-io' because: Ingress.extensions "hello-test3-foo-io" is invalid: spec.backend.serviceName: Invalid value: "default/hellonode": a DNS-1035 label must consist of lower case alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character (e.g. 'my-name',  or 'abc-123', regex used for validation is '[a-z]([-a-z0-9]*[a-z0-9])?')

@jrhouston
Copy link
Contributor

Thanks for opening this @goobysnack – unfortunately this is not possible and is a limitation of this API. The documentation says the backend must be in the same namespace as the ingress so this is not something we can change in Terraform.

There is a closed issue about this on the Kubernetes repo for context: kubernetes/kubernetes#17088

@ghost
Copy link

ghost commented May 8, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@hashicorp hashicorp locked as resolved and limited conversation to collaborators May 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants