Terraform-provider-kubernetes: Feature Request: Affinity

Created on 28 Nov 2018  路  19Comments  路  Source: hashicorp/terraform-provider-kubernetes

Having Affinity in Deployment and StatefulSet resources facilitate running HA clusters on kubernetes (think Redis or NATS). Without it, we can not guarantee that the pods will be scheduled in such a way that if a node fails, the cluster will not go offline.

https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity

Most helpful comment

This is coming soon!

I'm working on adding all the newer attributes for Pod which are missing since the Pod resource is quite old. This change will include the affinity attributes.

I will link the PR here once it's up.

All 19 comments

This is coming soon!

I'm working on adding all the newer attributes for Pod which are missing since the Pod resource is quite old. This change will include the affinity attributes.

I will link the PR here once it's up.

Hi!
@alexsomesan does the newer attributes you're talking about includes also toleration ?

https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/

I thinks this issue can be closed because node affinity (and toleration) are fully supported and works well :+1:

@alexsomesan Is this released? I'm not seeing affinity/antiaffinity rules on statefulsets or deployments in the docs.

Not yet. I'm aiming for a release early next week.

Hi,
is the support for Affinity and Anti-Affinity feature coming soon-ish, or shall I look for a workaround?

thanks

Can we help you in some way to get this released?

@alexsomesan is this going to be released soon? I'm stuck mid-migration fromsl1pm4t/terraform-provider-kubernetes until this is released.

@alexsomesan if it hasn't been released yet, then why is this issue closed? am I missing something?

@yacut, you're right. This shouldn't have been closed. Someone mentioned that "it works fine" but I think they were referring to the affinity mechanism on volumes. Pod affinity is not yet released.

I thinks this issue can be closed because node affinity (and toleration) are fully supported and works well

My bad, these features are not yet working in this provider but on sl1pm4t fork.
Can't wait to have those on official provider! ;)
Furthermore, sl1pm4t fork doesn't fully follow v1 apps API objects definition (selector/match_labels for example).

Any progress on this? How can we help?

I'd love to use this for my Consul cluster, please update us on the progress and if we can help!

I would like to use pod affinity/anti-affinity to prevent statefulset templated pods from being scheduled on the same node. Due to the past confusion in this issue, I'm specifically referring to https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity Which, when supported in pod spec, would cover Deployments, StatefulSets, etc.

Any progress on this? So far I patched the deployments created by terraform to add affinity rules but since v0.12.0 and v1.7.0 is out that seems to trigger resource updates when running apply. Previously the unsupported affinity properties were ignored now I get this:

...
                  - affinity {
                      - node_affinity {

                          - required_during_scheduling_ignored_during_execution {
                              - node_selector_term {
                                  - match_expressions {
                                      - key      = "cloud.google.com/gke-preemptible" -> null
                                      - operator = "DoesNotExist" -> null
                                      - values   = [] -> null
                                    }
                                }
                            }
                        }
                    }
...

So the above was a result of a manual patch and terraform now wants to remove it even though it has no support to set it, this should be changed and there should be a way to ignore all unsupported fields that exists in the resource.

I believe this issue can be closed..

https://github.com/terraform-providers/terraform-provider-kubernetes/pull/328

The docs seem to be missing on the official terraform documentation even though the PR is already merged: https://github.com/terraform-providers/terraform-provider-kubernetes/pull/430

I suspect the docs deployment went into conflict with the Terraform 0.12 rollout that was happening at the same time.
I鈥檒l will fixit.

@weeco The docs were there. I didn't have to repeat the deployment. Can you confirm that you can access them too?

Yes I can access them now, thank you!

Was this page helpful?
0 / 5 - 0 ratings