RocketChat / helm-charts

Repository for RocketChat helm charts
37 stars 67 forks source link

Need Support for Node Affinity/Selector in Job Spec #154

Open millaguie opened 2 months ago

millaguie commented 2 months ago

Description: We have a use case where we need to ensure that the pods created by the Job defined in the Helm chart only run on amd64 architecture nodes. However, the current Helm template does not pass nodeSelector or nodeAffinity settings to the Job specification. This limitation makes it impossible to restrict the Job’s pods to specific node types, which is a requirement in environments with heterogeneous node architectures (e.g., clusters with both amd64 and arm nodes).

Proposed Solution: Please add support for nodeSelector and nodeAffinity in the Job specification. This can be done by allowing these fields to be configurable via values.yaml and then passing them to the Job’s pod template spec.

Example configuration in values.yaml:

job:
  nodeSelector:
    kubernetes.io/arch: amd64

  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
          - matchExpressions:
              - key: kubernetes.io/arch
                operator: In
                values:
                  - amd64

These values should then be injected into the Job’s pod spec like this:

spec:
  template:
    spec:
      nodeSelector:
        {{- toYaml .Values.job.nodeSelector | nindent 8 }}

      affinity:
        {{- toYaml .Values.job.affinity | nindent 8 }}

Impact: Without this capability, users in mixed-architecture clusters are at risk of having their Jobs scheduled on incompatible nodes, leading to failures. This change would allow for more flexible and robust deployments across diverse Kubernetes environments.

Workaround: Currently, the lack of support for nodeSelector or nodeAffinity forces users to consider complex workarounds, such as setting up a custom Mutating Admission Webhook, which is over-engineered for this purpose and adds unnecessary operational complexity.

Request: Please consider implementing this enhancement to make the Helm chart more versatile and applicable to a broader range of Kubernetes environments.