0

I am trying to install akv28s secrets using helm template but it fails, I am unable to diagnose the issue in helm, have tried online yaml validators but no help. Using --debug flags renders me the expected manifest

values.yaml

akv2k8s:
  enabled: true
  vaults:
    vaultcmms:
      secretkey: secretvalue
      secretkey1: secretvalue1
    vaulttenant:
      secretkey: secretvalue
      secretkey1: secretvalue2

akv28s.yaml

{{- if .Values.akv2k8s.enabled -}}
{{- range $vault, $content := .Values.akv2k8s.vaults }}
  {{- range $key, $value := $content }}
    apiVersion: spv.no/v2beta1
    kind: AzureKeyVaultSecret
    spec:
      vault: {{ $vault }}
        name: {{ $key}}
        object:
          name: {{ $value}}
          type: secret
    {{- end }}
    {{- end }}
    {{- end }}

David Maze
  • 130,717
  • 29
  • 175
  • 215
  • It's hard to tell exactly what is required here, but those two "range" operators, combined with the data you appear to be iterating over, don't make much sense to me. I assume that first range would be iterating over a list, but you don't have a list in your data. – David M. Karr Nov 27 '22 at 00:22
  • The `-` to remove the leading/trailing spaces might be messing up your data. – P.... Nov 27 '22 at 02:41
  • You got bitten by [this same question](https://stackoverflow.com/a/73642950/225016); it's the leading spaces in your yaml – mdaniel Nov 27 '22 at 02:56
  • Separately, you're not inserting delimiters between those resources, so it's going to see all those ranged text blocks as **one yaml dict** which isn't what you want; you'll want to put `---` before that `apiVersion:` to start new resources for each range – mdaniel Nov 27 '22 at 02:57

1 Answers1

0

I was making a mistake by specifying the vault value in the wrong hierarchy It should be like

spec:
  vault: 
    name: {{ $vault }}
    object:
      name: {{ $value }}
      type: secret

This solved my issue.