Skip to content
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

Enable pod antiaffinity by default #285

Open
anubisg1 opened this issue Sep 8, 2022 · 5 comments · May be fixed by #927
Open

Enable pod antiaffinity by default #285

anubisg1 opened this issue Sep 8, 2022 · 5 comments · May be fixed by #927
Labels
enhancement New feature or request

Comments

@anubisg1
Copy link
Contributor

anubisg1 commented Sep 8, 2022

When installing a cluster via the operator, pod antiaffinity should be enabled by default (and user should be allowed to override it) so that each opensearch cluster node runs on a separate k8s node in order to provide an appropriate level of HA and fault tolerance

something similar to the following should exist by default (without any user configuration)

      spec:
        affinity:
          podAntiAffinity:
            preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 100
              podAffinityTerm:
                labelSelector:
                  matchLabels:
                    opster.io/opensearch-cluster: secure-cluster
                topologyKey: kubernetes.io/hostname
@swoehrl-mw swoehrl-mw added the enhancement New feature or request label Sep 10, 2022
@idanl21
Copy link
Collaborator

idanl21 commented Sep 13, 2022

Hey @anubisg1, pod affinity is a configurable option, that is indeed a good idea, do you want to raise a PR on it?

@anubisg1
Copy link
Contributor Author

i can try but i never looked into an operator implementation :) let me see what i can come out with

@rajeshm90
Copy link

it would be good to use labels on each nodePools component based on the roles and then use antiaffinity against that label. Otherwise, each cluster setup requires a greater number of nodes to host (in case bigger setup).

@arshashi
Copy link

arshashi commented Jan 6, 2025

This is what i used as affinity rules

nodePools: - component: masters affinity: podAntiAffinity: preferredDuringSchedulingIgnoredDuringExecution: - weight: 100 podAffinityTerm: labelSelector: matchLabels: opster.io/opensearch-nodepool: masters topologyKey: kubernetes.io/hostname

rajeshm90 pushed a commit to rajeshm90/opensearch-k8s-operator that referenced this issue Jan 6, 2025
…iAffinity

This PR helps to add a default podAntiAffinity rule in each nodePool
component with the cluster-name as selector to schedule the replicas on
different nodes on Kubernetes.

All components using the same rule, thus each replica from nodePool
components schedules on different nodes. This can be improved on
component wise in nodePool in future if needed.

Fixes opensearch-project#285

- [x] Commits are signed per the DCO using --signoff
- [x] Unittest added for the new/changed functionality and all unit
tests are successful
- [x] Customer-visible features documented
- [x] No linter warnings (`helm lint` and `helm template`)

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and
signing off your commits, please check
[here](https://github.com/opensearch-project/OpenSearch/blob/main/CONTRIBUTING.md#developer-certificate-of-origin).

Signed-off-by: Rajesh M <[email protected]>
rajeshm90 added a commit to rajeshm90/opensearch-k8s-operator that referenced this issue Jan 6, 2025
…iAffinity

This PR helps to add a default podAntiAffinity rule in each nodePool
component with the cluster-name as selector to schedule the replicas on
different nodes on Kubernetes.

All components using the same rule, thus each replica from nodePool
components schedules on different nodes. This can be improved on
component wise in nodePool in future if needed.

Fixes opensearch-project#285

- [x] Commits are signed per the DCO using --signoff
- [x] Unittest added for the new/changed functionality and all unit
tests are successful
- [x] Customer-visible features documented
- [x] No linter warnings (`helm lint` and `helm template`)

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and
signing off your commits, please check
[here](https://github.com/opensearch-project/OpenSearch/blob/main/CONTRIBUTING.md#developer-certificate-of-origin).

Signed-off-by: Rajesh M <[email protected]>
@rajeshm90
Copy link

podAntiAffinity

Thanks! updated the PR with this way!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: 📦 Backlog
5 participants