infinispan / infinispan-helm-charts

Apache License 2.0
14 stars 29 forks source link

Add affinity to template #89

Closed oburd closed 2 months ago

oburd commented 11 months ago

Hello! Can you create affinity template for deployment ? Because i don need hostname, i need zones Is this possible ? Thank you

ryanemerson commented 11 months ago

That's not currently possible. PRs are welcome though :slightly_smiling_face:

We could add deploy.affinity to the values.yaml and make it so the default value is what's currently specified in the template, e.g. values.yaml would look like:

deploy:
  affinity:
    podAntiAffinity:
      preferredDuringSchedulingIgnoredDuringExecution:
        - podAffinityTerm:
            labelSelector:
              matchLabels:
                clusterName: {{ include "infinispan-helm-charts.name" . }}
                app: infinispan-pod
            topologyKey: kubernetes.io/hostname
          weight: 100
oburd commented 11 months ago

You mean it's me need to create PR ? About affinity, so i can add in values.yml ? Something like this affinity: podAntiAffinity: preferredDuringSchedulingIgnoredDuringExecution:

ryanemerson commented 11 months ago

You mean it's me need to create PR ?

The feature may get added in the future by someone else (thanks for raising the issue), but submitting a PR yourself will definitely speed things up and ensure the feature is added.

About affinity, so i can add in values.yml ?

In order for us to support this there are two changes required:

  1. We need to update the default values.yaml included with the chart to include the yaml I posted. This is to ensure that the existing behaviour doesn't changes.
  2. The templates/statefulset.yaml template needs to be updated to remove the existing podAntiAffinity and instead include .Values.deploy.affinity. See how the spec.nodeSelector value is configured in this template for a similar example.
oburd commented 11 months ago

If i right understand in stateful.yml instead of this

affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - podAffinityTerm:
                labelSelector:
                  matchLabels:
                    clusterName: {{ include "infinispan-helm-charts.name" . }}
                    app: infinispan-pod
                topologyKey: kubernetes.io/hostname
              weight: 100

add this to statefulset template

 {{- if .Values.deploy.affinity }}
      affinity :
      {{- with .Values.deploy.affinity }}
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- end }}

And need to add in value.yml:

affinity: {}
ryanemerson commented 11 months ago

That looks correct :+1:

oburd commented 11 months ago

So should i do the PR ? for this ?

ryanemerson commented 11 months ago

If you're able to, it would be much appreciated!

oburd commented 11 months ago

Hello! I will do little later