-1

Pretty new to helm. I'm using terraform (helm_release) to deploy it. The helm chart is a local directory making a simple cluster role and role binding. I'm having an issue where the values.yaml isn't being picked up or recognized at run time. This is causing the places in the template with values like: {{ with .Values.clusterRoleBinding.clusterRoleBindingName }} To throw errors about issues converting yaml to json (instead of getting the value from the values.yaml file) I feel like I'm missing something simple (yet critical) here. Anyone available to give it a look? white_check_mark eyes raised_hands

Dir structure: main.tf

    - templates
        rolebinding.yaml
        role.yaml
   chart.yaml
   values.yaml

Terraform

resource "helm_release" "cluster_role_one" {
  name       = "rbac"
  chart      = "./helm"

    values = [
    "${file("./helm/values.yaml")}"
  ]

  set {
    name  = "clusterRoleBinding.clusterRoleBindingName"
    value = "cluster_role_binding_one"
  }

  set {
    name  = "clusterRoleBinding.groupName"
    value = "cluster_group_one"
  }

  set {
    name  = "clusterRole.roleName"
    value = "cluster_role_binding_one"
  }
}

One of the templates for reference:

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
    name: { { .Values.clusterRole.clusterRoleName } }
rules:
    - apiGroups: [""] # "" indicates the core API group
      resources: ["pods"]
      verbs: ["get", "watch", "list"]

values.yaml:

clusterRoleBinding:
  clusterRoleBindingName: Developer
  groupName: Developer
  roleName: Developer

clusterRole:
  clusterRoleName: Developer

chart.yaml:

name: "rbac"
apiVersion: v1
version: 0.1.0
description: Setup RBAC for clusters
maintainers:
- name: "****"
  email: 123@aol.com

If I hardcode the fields (mostly names) in the templates it deploys to my cluster no problem with the hardcoded values. Not what I want though. Expectation is the values from the value file would be injected into the templates OR from the set parameters in main.tf (edited)

Cythrex
  • 21
  • 3

1 Answers1

0

My problem was solved. Silly issue.

my auto save formatter was changing

{{ .Values.clusterRole.clusterRoleName }} 

to

{{ .Values.clusterRole.clusterRoleName }} 

and those extra spaces is all it took to throw helm off

J00MZ
  • 675
  • 1
  • 10
  • 27
Cythrex
  • 21
  • 3