Skip to content

Add support anti-affinity - #242

Merged
m-terra merged 1 commit into
six-group:mainfrom
kenichi-mashiyama:add-podAntiAffinity
Oct 2, 2026
Merged

m-terra merged 1 commit into
six-group:mainfrom
kenichi-mashiyama:add-podAntiAffinity

Conversation

@kenichi-mashiyama

Copy link
Copy Markdown
Contributor

Summary

This PR adds support for pod anti-affinity configurations (enforcePodAntiAffinity and antiAffinity) within the Placement spec of the Instance CRD.

Motivation

Previously, the HAProxy Operator did not provide a native mechanism to configure pod anti-affinity rules for HAProxy instances. This meant users could not easily prevent multiple pods of the same instance from landing on the same node, nor could they define custom anti-affinity rules against other pod workloads or specific topology domains. By introducing enforcePodAntiAffinity (a simple toggle to ensure one pod per node) and antiAffinity (PodAntiAffinityRule for custom label-selector-based rules), users can now flexibly configure scheduling isolation to improve high availability.

Changes

  • Added the EnforcePodAntiAffinity (bool) field, PodAntiAffinityRule struct, and AntiAffinity field to the Placement struct in apis/proxy/v1alpha1/instance_types.go.
  • Updated reconcileStatefulSet in controllers/instance/statefulset.go to inject PodAntiAffinity terms into the StatefulSet spec when EnforcePodAntiAffinity or AntiAffinity is configured.
  • Added unit tests in controllers/instance/statefulset_test.go to verify the generation of StatefulSet affinity rules for both enforcePodAntiAffinity and custom antiAffinity configurations.
  • Regenerated CRDs, DeepCopy methods, and API documentation to reflect the new schema fields.

Checklist

  • Code changes implemented
  • Unit tests added/updated
  • Generated CRDs and API docs updated

@kenichi-mashiyama

Copy link
Copy Markdown
Contributor Author

Hi @xosk31 @m-terra,

Friendly ping when you have a chance! Could you please take a look at this PR?
All CI checks have passed. Thanks!

@m-terra
m-terra merged commit fc97e51 into six-group:main Oct 2, 2026
4 checks passed
@kenichi-mashiyama
kenichi-mashiyama deleted the add-podAntiAffinity branch October 3, 2026 02:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants