When I try to install a Helm chart with a template file:
{{ if eq .Release.Namespace "fedx-app-1100" }}{{ $nodePort := 30106 }}{{ end }}
apiVersion: v1
kind: Service
metadata:
name: mysql
namespace: {{ .Release.Namespace }}
labels:
app: mysql
spec:
type: NodePort
ports:
- port: 3306
targetPort: 3306
nodePort: {{ $nodePort }}
It produces an error:
Error: parse error at (fedx-install/templates/mysql.yaml:21): undefined variable "$nodePort"
What causes this error? How can I restructure the template file to avoid it?