Hi,
I try to add {{ .Namespace }} in the .gotmpl file, but it can't be rendered.
Below are my helmfile.yaml and values.yaml.gotmpl
# helmfile.yaml
releases:
- name: demo
namespace: demo
chart: incubator/raw
version: 0.2.3
labels:
app: demo
values:
- values.yaml.gotmpl
# values.yaml.gotmpl
resources:
- apiVersion: v1
kind: ServiceAccount
metadata:
name: cloudwatch-agent
namespace: {{ .Namespace }}
- kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: cloudwatch-agent-role
rules:
- apiGroups: [""]
resources: ["pods", "nodes", "endpoints"]
verbs: ["list", "watch"]
- apiGroups: ["apps"]
resources: ["replicasets"]
verbs: ["list", "watch"]
- apiGroups: ["batch"]
resources: ["jobs"]
verbs: ["list", "watch"]
- apiGroups: [""]
resources: ["nodes/proxy"]
verbs: ["get"]
- apiGroups: [""]
resources: ["nodes/stats", "configmaps", "events"]
verbs: ["create"]
- apiGroups: [""]
resources: ["configmaps"]
resourceNames: ["cwagent-clusterleader"]
verbs: ["get","update"]
- kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: cloudwatch-agent-role-binding
subjects:
- kind: ServiceAccount
name: cloudwatch-agent
namespace: {{ .Namespace }}
roleRef:
kind: ClusterRole
name: cloudwatch-agent-role
apiGroup: rbac.authorization.k8s.io
Type helmfile template, it shows the {{ .Namespace }} was rendered to null
---
# Source: raw/templates/resources.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app: raw
chart: raw-0.2.3
heritage: Helm
release: demo
name: cloudwatch-agent
namespace: null
---
# Source: raw/templates/resources.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
app: raw
chart: raw-0.2.3
heritage: Helm
release: demo
name: cloudwatch-agent-role
rules:
- apiGroups:
- ""
resources:
- pods
- nodes
- endpoints
verbs:
- list
- watch
- apiGroups:
- apps
resources:
- replicasets
verbs:
- list
- watch
- apiGroups:
- batch
resources:
- jobs
verbs:
- list
- watch
- apiGroups:
- ""
resources:
- nodes/proxy
verbs:
- get
- apiGroups:
- ""
resources:
- nodes/stats
- configmaps
- events
verbs:
- create
- apiGroups:
- ""
resourceNames:
- cwagent-clusterleader
resources:
- configmaps
verbs:
- get
- update
---
# Source: raw/templates/resources.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
app: raw
chart: raw-0.2.3
heritage: Helm
release: demo
name: cloudwatch-agent-role-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cloudwatch-agent-role
subjects:
- kind: ServiceAccount
name: cloudwatch-agent
namespace: null
But it's interesting if I type helm -n demo template, the {{ .Namespace }} can be rendered to 'demo' string.
---
# Source: raw/templates/resources.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app: raw
chart: raw-0.2.3
heritage: Helm
release: demo
name: cloudwatch-agent
namespace: demo
---
# Source: raw/templates/resources.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
app: raw
chart: raw-0.2.3
heritage: Helm
release: demo
name: cloudwatch-agent-role
rules:
- apiGroups:
- ""
resources:
- pods
- nodes
- endpoints
verbs:
- list
- watch
- apiGroups:
- apps
resources:
- replicasets
verbs:
- list
- watch
- apiGroups:
- batch
resources:
- jobs
verbs:
- list
- watch
- apiGroups:
- ""
resources:
- nodes/proxy
verbs:
- get
- apiGroups:
- ""
resources:
- nodes/stats
- configmaps
- events
verbs:
- create
- apiGroups:
- ""
resourceNames:
- cwagent-clusterleader
resources:
- configmaps
verbs:
- get
- update
---
# Source: raw/templates/resources.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
app: raw
chart: raw-0.2.3
heritage: Helm
release: demo
name: cloudwatch-agent-role-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cloudwatch-agent-role
subjects:
- kind: ServiceAccount
name: cloudwatch-agent
namespace: demo
Hi,
I try to add {{ .Namespace }} in the .gotmpl file, but it can't be rendered.
Below are my
helmfile.yamlandvalues.yaml.gotmplType
helmfile template, it shows the {{ .Namespace }} was rendered tonullBut it's interesting if I type
helm -n demo template, the {{ .Namespace }} can be rendered to 'demo' string.