fluxcd / flux2-kustomize-helm-example

A GitOps workflow example for multi-env deployments with Flux, Kustomize and Helm.
https://fluxcd.io
Apache License 2.0
935 stars 992 forks source link

HelmController missing key 'values.yaml' in ConfigMap when using values file #53

Closed HenrikDK closed 2 years ago

HenrikDK commented 2 years ago

Hi, didn't know if this was the correct place to ask. But i'll try here :)

I'm currently trying to get the helm controller on our cluster to deploy a release with a values.yaml file, I discovered this repo and tried following the "redis" example:

https://github.com/fluxcd/flux2-kustomize-helm-example/tree/main/infrastructure/redis

I have a folder with 6 files (i can upload them in a zip file if thats needed):

kustomization.yaml:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: logging
resources:
  - humio-token.yaml
  - namespace.yaml
  - release.yaml
configMapGenerator:
- name: fluentbit-values
  files:
    - values.yaml=values.yaml
configurations:
  - kustomizeconfig.yaml

kustomizeconfig.yaml:

# Kustomize config for enabling HelmRelease values from
# ConfigMaps and Secrets generated by Kustomize
nameReference:
- kind: ConfigMap
  version: v1
  fieldSpecs:
  - path: spec/valuesFrom/name
    kind: HelmRelease

namespace.yaml:

apiVersion: v1
kind: Namespace
metadata:
  name: logging
  labels:
    kubernetes.io/metadata.name: logging

release.yaml:

apiVersion: source.toolkit.fluxcd.io/v1beta1
kind: HelmRepository
metadata:
  name: humio-repository
  namespace: logging
spec:
  interval: 30m
  url: https://humio.github.io/humio-helm-charts
---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
  name: humio-fluentbit
  namespace: logging
spec:
  releaseName: humio-fluentbit
  chart:
    spec:
      chart: humio-helm-charts
      version: 0.8.29
      sourceRef:
        kind: HelmRepository
        name: humio-repository
        namespace: logging
  interval: 10m0s
  install:
    remediation:
      retries: 3
  valuesFrom:
    - kind: ConfigMap
      name: fluentbit-values

values.yaml

humio-fluentbit:
  enabled: true
  humioHostname: cloud.humio.com
  es:
    tls: true
  tokenSecretName: humio-token

  inputConfig: |-
    [INPUT]
        Name             tail
        Path             /var/log/containers/*.log
        Parser           cri
        Tag              kube.*
        Refresh_Interval 5
        Mem_Buf_Limit    5MB
        Skip_Long_Lines  On

  parserConfig: |-
      [PARSER]
          Name        cri
          Format      regex
          Regex       ^(?<time>[^ ]+) (?<stream>stdout|stderr) (?<logtag>[^ ]*) [^{]*(?<message>.*)$
          Time_Key    time
          Time_Format %Y-%m-%dT%H:%M:%S.%L%z

And a humio-token containing a secret access token.

But the Helm Controller keeps throwing an error:

"missing key 'values.yaml' in ConfigMap 'logging/fluentbit-values-7fffgftbhb'"

This has me puzzled cause when i describe the generated config map as yaml I can se a Binary Data entry with a values.yaml:

configMap

Is Binary Data not supported for the flux v2 helm controller? Or have I missed something somewhere?

/Henrik

stefanprodan commented 2 years ago

Is Binary Data not supported for the flux v2 helm controller? Or have I missed something somewhere?

It is not supported, you need to use Data.

HenrikDK commented 2 years ago

Ok, that explains it.

How does the Kustomize controller determin if it creates a binary data or data entry?

Is it the formatting of the values.yaml thats incorrect?

stefanprodan commented 2 years ago

Kustomize will automatically add any value that is not valid utf8 to the BinaryData, your values.yaml seems malformed.

HenrikDK commented 2 years ago

Ok thanks for the prompt response :)