Skip to content

Conversation

@scientress
Copy link

I need to use nodeAffinity or nodeSelector to limit the nodes to the correct architecture in a multi architecture cluster. While I tried to do that I noticed the the hook-verify-mongodb-version.yaml templates currently produces invalid yaml if you provide either.

Example of malformed yaml output by the template:
# https://kubernetes.io/docs/concepts/workloads/pods/
apiVersion: batch/v1
kind: Job
metadata:
  name: 'rocketchat-rocketchat-pre-upgrade'
  annotations:
    "helm.sh/hook": pre-upgrade
    "helm.sh/hook-delete-policy": hook-succeeded
spec:
  backoffLimit: 5
  parallelism: 1
  completions: 1
  template:
    metadata:
      name: 'rocketchat-rocketchat-pre-upgrade'
      labels:
        app.kubernetes.io/managed-by: "Helm"
        app.kubernetes.io/instance: "rocketchat"
        helm.sh/chart: "rocketchat-6.25.1"
    spec:
      restartPolicy: OnFailure
      tolerations:
        - effect: NoSchedule
          key: special
          operator: Equal
          value: highcpu
      nodeSelector:
              beta.kubernetes.io/arch: amd64
        other.label: foo
      affinity:
              nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: beta.kubernetes.io/arch
                operator: In
                values:
                - amd64

The error is caussed by an incorrect ussage of the indent filter. I fixed this and also improved the indentation of nodeAffinity and nodeSelector in the Deployments.

Fixed output of the tamplate with the purposed changes:
# Source: rocketchat/templates/hook-verify-mongodb-version.yaml
# https://kubernetes.io/docs/concepts/workloads/pods/
apiVersion: batch/v1
kind: Job
metadata:
  name: 'rocketchat-rocketchat-pre-upgrade'
  annotations:
    "helm.sh/hook": pre-upgrade
    "helm.sh/hook-delete-policy": hook-succeeded
spec:
  backoffLimit: 5
  parallelism: 1
  completions: 1
  template:
    metadata:
      name: 'rocketchat-rocketchat-pre-upgrade'
      labels:
        app.kubernetes.io/managed-by: "Helm"
        app.kubernetes.io/instance: "rocketchat"
        helm.sh/chart: "rocketchat-6.25.1"
    spec:
      restartPolicy: OnFailure
      tolerations:
        - effect: NoSchedule
          key: special
          operator: Equal
          value: highcpu
      nodeSelector:
        beta.kubernetes.io/arch: amd64
        other.label: foo
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: beta.kubernetes.io/arch
                operator: In
                values:
                - amd64

@CLAassistant
Copy link

CLAassistant commented Jul 4, 2025

CLA assistant check
All committers have signed the CLA.

@geekgonecrazy
Copy link
Contributor

@scientress please resolve merge conflicts

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.

3 participants