terraform-provider-kubernetes icon indicating copy to clipboard operation
terraform-provider-kubernetes copied to clipboard

kubernetes_deployment does not support namespace_selector for pod_anti_affinity

Open matpen opened this issue 3 years ago • 8 comments

Description

It looks like neither kubernetes_deployment nor kubernetes_deployment_v1 support the namespace_selector field for pod_anti_affinity (and possibly for pod_affinity). This is unfortunate, because it is the only way to specify a match in "all namespaces" (by passing an empty selector).

Potential Terraform Configuration

resource "kubernetes_deployment" "my_app" {
  ...
  spec {
    ...
    template {
      ...
      spec {
        ...
        affinity {
          pod_anti_affinity {
            required_during_scheduling_ignored_during_execution {
              label_selector {
                match_expressions {
                  key = "app"
                  operator = "In"
                  values = ["my-app"]
                }
              }
              namespace_selector = {} # TODO this does not work
              topology_key = "kubernetes.io/hostname"
            }
          }
        }
        ...

References

n / a

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

matpen avatar Sep 04 '22 12:09 matpen

@alexsomesan, I can see other resources already have support for namespace_selector, are you be open to a PR for this enhancement?

flynnhandley avatar Sep 22 '22 08:09 flynnhandley

Marking this issue as stale due to inactivity. If this issue receives no comments in the next 30 days it will automatically be closed. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. This helps our maintainers find and focus on the active issues. Maintainers may also remove the stale label at their discretion. Thank you!

github-actions[bot] avatar Sep 23 '23 00:09 github-actions[bot]

I can confirm that also in pod_affinity the block namespace_selector isn't recognized.

The block namespace_selector isn't recognized also under deployment.spec.template.spec.affinity.pod_affinity.preferred_during_scheduling_ignored_during_execution.pod_affinity_term.

AlbertoSpinella avatar Sep 23 '23 10:09 AlbertoSpinella

Hello, is there any plan to implement this ?

nox-404 avatar Dec 19 '23 10:12 nox-404

just noticed this PR: https://github.com/hashicorp/terraform-provider-kubernetes/pull/2020

nox-404 avatar Dec 19 '23 10:12 nox-404

@Nox-404 it seems like the author of #2020 is taking some time to respond. You are more than welcome to grab what they've worked on and make the requested changes to get this merged

BBBmau avatar Jan 03 '24 19:01 BBBmau