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

Support podAntiAffinity namespaceSelector field

Open kuldazbraslav opened this issue 1 year ago • 0 comments

Description

Kubernetes supports namespaceSelector in podAntiAffinity configuration:

Namespace selector FEATURE STATE: Kubernetes v1.24 [stable] You can also select matching namespaces using namespaceSelector, which is a label query over the set of namespaces. The affinity term is applied to namespaces selected by both namespaceSelector and the namespaces field. Note that an empty namespaceSelector ({}) matches all namespaces, while a null or empty namespaces list and null namespaceSelector matches the namespace of the Pod where the rule is defined.

This configuration allows matching labels across namespaces which is useful in some namespace layouts.

Potential Terraform Configuration

          pod_anti_affinity {
            required_during_scheduling_ignored_during_execution {
              topology_key = "kubernetes.io/hostname"
              label_selector {
                match_labels = {
                  "mylabel" : "mylabelvalue"
                }
              }
              # Proposed form for all namespaces:
              namespace_selector {}
              # Proposed form for specific namespaces:
              namespace_selector {
                match_labels = {
                  "mynamespacelabel" = "excludethis"
                }
              }
            }
          }

References

https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#namespace-selector

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

kuldazbraslav avatar Jun 24 '24 07:06 kuldazbraslav