Skip to content

🐛 Fix Pod spec toleration when the spec is a template #2380

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

Merged
merged 7 commits into from
Jun 13, 2025

Conversation

arybolovlev
Copy link
Contributor

@arybolovlev arybolovlev commented Jan 2, 2024

Description

This PR updates the logic of resources that use the Pod specification template such as Deployment, DaemonSet, etc. The provider will keep all tolerations(spec.template.spec.toleration) returned by Kubernetes for the Pod specification template. Those tolerations are usually added via Terraform code and aren't attached by any built-in controllers. The same applies to the data sources kubernetes_pod_v1 and kubernetes_pod, all tolerations remain unchanged. The behavior of resources kubernetes_pod_v1 and kubernetes_pod remains unchanged, i.e. the provider will keep removing tolerations with well-known taints since they might be attached to the object by Kubernetes controller and could lead to a perpetual diff.

Affected resources and data sources:

  • resource/kubernetes_replication_controller
  • resource/kubernetes_replication_controller_v1
  • resource/kubernetes_stateful_set
  • resource/kubernetes_stateful_set_v1
  • resource/kubernetes_deployment
  • resource/kubernetes_deployment_v1
  • resource/kubernetes_daemonset
  • resource/kubernetes_daemon_set_v1
  • resource/kubernetes_cron_job
  • resource/kubernetes_cron_job_v1
  • resource/kubernetes_job
  • resource/kubernetes_job_v1
  • data_source/kubernetes_pod
  • data_source/kubernetes_pod_v1

Acceptance tests

  • Have you added an acceptance test for the functionality being added?
  • Have you run the acceptance tests on this branch?

Release Note

Release note for CHANGELOG:

We have updated the logic of resources that use the Pod specification template, such as `kubernetes_deployment_v1`, `kubernetes_stateful_set_v1`, etc, and now the provider will keep all tolerations(`spec.toleration`) returned by Kubernetes. The same is applicable for the data sources `kubernetes_pod_v1` and `kubernetes_pod`. The behavior of resources `kubernetes_pod_v1` and `kubernetes_pod` remains unchanged, i.e. the provider will keep removing tolerations with well-known [taints](https://kubernetes.io/docs/reference/labels-annotations-taints/) since they might be attached to the object by Kubernetes controller and could lead to a perpetual diff.

Fix an issue when the provider cuts out toleration under pod spec template(`*.template.spec.toleration`) if it uses a well-known [taint](https://kubernetes.io/docs/reference/labels-annotations-taints/). That could lead to a perpetual diff behavior.

References

Fix: #2376

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

@github-actions github-actions bot added the size/M label Jan 2, 2024
@arybolovlev arybolovlev changed the title Add a new argument to function flattenPodSpec 🐛 Fix Pod spec toleration when the spec is a template Jan 2, 2024
@github-actions github-actions bot added size/L and removed size/M labels Jan 3, 2024
@arybolovlev arybolovlev marked this pull request as ready for review January 3, 2024 08:30
@arybolovlev arybolovlev requested a review from a team as a code owner January 3, 2024 08:31
@Restless-ET
Copy link

Hello @arybolovlev

Any expected date for when this will be merged?
Will it be for v2.26 only or as a patch to v2.25?

Best regards

@arybolovlev arybolovlev force-pushed the fix-tolerations-in-templates branch from c672a42 to 9b94b3b Compare March 26, 2025 15:05
@arybolovlev arybolovlev requested a review from a team as a code owner March 26, 2025 15:05
Copy link
Contributor

@sheneska sheneska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! 🚀

@arybolovlev arybolovlev merged commit d11bba6 into main Jun 13, 2025
25 checks passed
@arybolovlev arybolovlev deleted the fix-tolerations-in-templates branch June 13, 2025 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deployment tolerations using keys matching k8s node taints are being ignored for the tfstate
3 participants