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

Helm Chart: .values.affinity won't work as expected #898

Closed
kmizumar opened this issue Apr 3, 2024 · 1 comment
Closed

Helm Chart: .values.affinity won't work as expected #898

kmizumar opened this issue Apr 3, 2024 · 1 comment

Comments

@kmizumar
Copy link

kmizumar commented Apr 3, 2024

Describe the bug
It seems that it's impossible to specify affinity for pod assignment.

Environment
Provide accurate information about the environment to help us reproduce the issue.

  • Trident version: 24.02
  • Trident operator version: 100.2402.0
  • Kubernetes version: v1.28.3
  • OS: Ubuntu 24.04LTS
  • Other:
    • Kustomize version: 5.3.0

To Reproduce
Steps to reproduce the behavior:

❯ cat kustomization.yaml 
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: trident
helmCharts:
- name: trident-operator
  releaseName: trident-operator
  namespace: trident
  includeCRDs: true
  version: 100.2402.0
  repo: https://netapp.github.io/trident-helm-chart
  skipTests: true
  skipHooks: true
  valuesInline:
    affinity:
      nodeAffinity:
        requiredDuringSchedulingIgnoredDuringExecution:
          nodeSelectorTerms:
          - matchExpressions:
            - key: node.owner
              operator: NotIn
              values:
              - org-foo
              - org-bar
              - org-baz

Then try to generate YAML files:

❯ kustomize version
5.3.0

❯ kustomize build . --enable-helm
Error: map[string]interface {}(nil): yaml: unmarshal errors:
  line 37: mapping key "affinity" already defined at line 23

Expected behavior
A clear and concise description of what you expected to happen.

YAML files should be rendered without any errors.

Additional context
Add any other context about the problem here.

Defining .values.affinity leads to duplicate spec.affinity definitions, I guess:

affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/arch
operator: In
values:
- arm64
- amd64
- key: kubernetes.io/os
operator: In
values:
- linux
{{- if .Values.nodeSelector }}
{{- range $key, $value := .Values.nodeSelector}}
- key: {{ $key }}
operator: In
values:
- {{ $value }}
{{- end }}
{{- end }}
{{- if .Values.affinity }}
affinity:
{{ toYaml .Values.affinity | indent 8 }}
{{- end }}
{{- if .Values.tolerations }}
tolerations:

@torirevilla
Copy link
Contributor

This fix will be in the 24.10 release: 608ee80

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants