Skip to content

Values.image parameters not honored by helm chart in ArgoCD #336

Closed

Description

@jessebot

With chart version: 3.4.1 I can only get the parameters under image to work if I put them under nextcloud in my values.yaml. As an example, I would like to use the 25.0.3-fpm image.tag.

This is from the current values.yaml in this repo and if I use it, but just change the tag, it does not honor the tag I have specified:

image:
  repository: nextcloud
  tag: 25.0.3-fpm
  pullPolicy: IfNotPresent

and it produces this (with helm template nextcloud . from the directory where I have a Chart.yaml that just references the current nextcloud chart version and a values.yaml):

Wrong output rendered template
# Source: nextcloud/charts/nextcloud/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nextcloud
  labels:
    app.kubernetes.io/name: nextcloud
    helm.sh/chart: nextcloud-3.4.1
    app.kubernetes.io/instance: nextcloud
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: app
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app.kubernetes.io/name: nextcloud
      app.kubernetes.io/instance: nextcloud
      app.kubernetes.io/component: app
  template:
    metadata:
      labels:
        app.kubernetes.io/name: nextcloud
        app.kubernetes.io/instance: nextcloud
        app.kubernetes.io/component: app
      annotations:
        nextcloud-config-hash: a5aae02b1b8278a9c8a2dc143e82d3737fc295f62c34afd617207f37d1b2b438
        php-config-hash: 44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a
    spec:
      containers:
      - name: nextcloud
        image: nextcloud:25.0.3-apache
        imagePullPolicy: IfNotPresent
...

If I change my local values.yaml to put image.tag under nextcloud it succeeds in the way I would expect:

nextcloud:
  image:
    repository: nextcloud
    tag: 25.0.3-fpm
    pullPolicy: IfNotPresent

And produces this when I run helm template:

Correct expected template rendered output
# Source: nextcloud/charts/nextcloud/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nextcloud
  labels:
    app.kubernetes.io/name: nextcloud
    helm.sh/chart: nextcloud-3.4.1
    app.kubernetes.io/instance: nextcloud
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: app
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app.kubernetes.io/name: nextcloud
      app.kubernetes.io/instance: nextcloud
      app.kubernetes.io/component: app
  template:
    metadata:
      labels:
        app.kubernetes.io/name: nextcloud
        app.kubernetes.io/instance: nextcloud
        app.kubernetes.io/component: app
      annotations:
        nextcloud-config-hash: a5aae02b1b8278a9c8a2dc143e82d3737fc295f62c34afd617207f37d1b2b438
        php-config-hash: 44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a
    spec:
      containers:
      - name: nextcloud
        image: nextcloud:25.0.3-fpm
        imagePullPolicy: IfNotPresent

This could be because we're only looking for nextcloud.image in the deployment.yaml template:

spec:
{{- if .Values.image.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.pullSecrets }}
- name: {{ . }}
{{- end}}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: {{ include "nextcloud.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy }}

Perhaps something is not working here:

{{/*
Create image name that is used in the deployment
*/}}
{{- define "nextcloud.image" -}}
{{- if .Values.image.tag -}}
{{- printf "%s:%s" .Values.image.repository .Values.image.tag -}}
{{- else -}}
{{- printf "%s:%s-%s" .Values.image.repository .Chart.AppVersion (default "apache" .Values.image.flavor) -}}
{{- end -}}
{{- end -}}

If I clone this repo, and cd into charts/nexcloud, update the values.yaml parameter image.tag to 25.0.3-fpm, then run helm template nextcloud . from that directory, the resulting rendered manifests are correct, so I think the _helpers.tpl only applies to the base template and does not take into account additional values.yaml passed in by end users.

Activity

  1. jessebot commented on Jan 24, 2023

    @jessebot
    CollaboratorAuthor

    Not sure if this is related to #112 or not, but still refining the backlog to research if others are having this issue.

  2. provokateurin commented on Jan 25, 2023

    @provokateurin
    Member

    I don't think it's related

  3. jessebot commented on Apr 10, 2023

    @jessebot
    CollaboratorAuthor

    I'm still having this problem with the latest version of the helm chart.

    I think a solution could be to changed this line here:

    image: {{ include "nextcloud.image" . }}

    to be something like this in charts/nextcloud/templates/deployment.yaml:

         {{- if .Values.image.tag }}
         image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
         {{ else }}
         image: {{ .Values.image.repository }}:{{ .Chart.AppVersion }}-{{( .Values.image.flavor }} 
         {{- end }}

    And then we remove the stuff about this in _helpers.tpl and update values.yaml to actually specify the image.flavor by default? Creating a draft PR, #375, to show what I mean.

  4. jessebot commented on Apr 10, 2023

    @jessebot
    CollaboratorAuthor

    Closed the draft PR as I've just realized this is only happening through Argo CD for some reason 😨 This issue doesn't occur when I just use k3s with helm directly. I'll report in more as I figure out what the issue is!

  5. changed the title [-]Values.image parameters not honored by helm chart[/-] [+]Values.image parameters not honored by helm chart in ArgoCD[/+] on Apr 10, 2023
  6. jessebot commented on Apr 15, 2023

    @jessebot
    CollaboratorAuthor

    So, this happens if you were using argocd the old way, before they introduced the beta multiple sources feature. Here's an example of how it was broken before. You could previously only use the values.yaml in the source helm chart repo, so the only way to use your own values.yaml was to have a repo where you created a helm chart like this:

    Broken argocd setup causing this github issue `Chart.yaml`: ```yaml --- apiVersion: v2 version: 0.1.0 name: nextcloud dependencies: - name: nextcloud repository: https://nextcloud.github.io/helm/ version: 3.4.1 ```

    With the above Chart.yaml, the only way to get the values.yaml to work was to do this:

    nextcloud:
      image:
        repository: nextcloud
        tag: 25.0.3-fpm

    This is the argo manifest I was using:

    ---
    # webapp is deployed LAST because we need secrets and persistent volumes up 1st
    apiVersion: argoproj.io/v1alpha1
    kind: Application
    metadata:
      name: nextcloud-web-app
      namespace: argocd
      annotations:
        argocd.argoproj.io/sync-wave: "3"
    spec:
      project: default
      destination:
        server: "https://kubernetes.default.svc"
        namespace: nextcloud
      source:
        # helm repo
        repoURL: https://gitlab.com/vleermuis_tech/goobernetes/nextcloud.git
        path: helm/
        helm:
          valueFiles:
            - values.yaml
      syncPolicy:
        syncOptions:
          - Replace=true
        automated:
          prune: true
          selfHeal: true

    Now with the Argo CD app version 2.6.x, you can do the following to use a different source for your values.yaml than the source with the actual helm chart like this:

    ---
    # webapp is deployed LAST because we need secrets and persistent volumes up 1st
    apiVersion: argoproj.io/v1alpha1
    kind: Application
    metadata:
      name: nextcloud-minimal-web-app
      namespace: argocd
      annotations:
        argocd.argoproj.io/sync-wave: "3"
    spec:
      project: default
      destination:
        server: "https://kubernetes.default.svc"
        namespace: nextcloud
      sources:
        # official nextcloud helm repo
        - repoURL: 'https://nextcloud.github.io/helm'
          chart: nextcloud
          targetRevision: 3.5.7
          helm:
            valueFiles:
            - $values/values.yaml
        # our values.yaml file locally
        - repoURL: 'https://gitlab.com/vleermuis_tech/goobernetes/nextcloud.git'
          targetRevision: main
          ref: values
      syncPolicy:
        syncOptions:
          - ApplyOutOfSyncOnly=true
        automated:
          prune: true
          selfHeal: true
    ...

    This solves the problem entirely, but since this is a beta feature, it might break again 🙃 :
    Screenshot 2023-04-15 at 15 31 12

    Closing as this is fixed in my testing with Argo CD helm chart version 5.28.1 using the nextcloud helm chart version 3.5.7 though via an argo Application that uses two sources: 1 for this helm chart repo, 1 for my actual values.yaml :)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions