I understand that {{.Release.namespace}} will render the namespace where the application being installed by helm. In that case, helm template command will render it as empty string (since it doesn't know yet the release namespace).
However, what makes me surprise is helm upgrade --install command (i haven't tried other command such as helm install) also renders it empty on some cases.
Here is the example of my helm chart template:
apiVersion: v1
kind: Service
metadata:
name: {{.Values.app.name}}-{{.Values.app.track}}-internal
namespace: {{.Release.namespace}}
annotations:
testAnnotate: "{{.Release.namespace}}"
spec:
ports:
- protocol: TCP
port: 80
targetPort: 8080
selector:
app: {{.Values.app.name}}
environment: {{.Values.app.env}}
track: {{.Values.app.track}}
type: ClusterIP
After invoke helm upgrade --install on that chart template (and installed it successfully), I then try to see the output of my resource
> kubectl get -o yaml svc java-maven-app-stable-internal -n data-devops
apiVersion: v1
kind: Service
metadata:
annotations:
testAnnotate: ""
creationTimestamp: 2018-08-09T06:56:41Z
name: java-maven-app-stable-internal
namespace: data-devops
resourceVersion: "62906341"
selfLink: /api/v1/namespaces/data-devops/services/java-maven-app-stable-internal
uid: 5e888e6a-9ba1-11e8-912b-42010a9400fa
spec:
clusterIP: 10.32.76.208
ports:
- port: 80
protocol: TCP
targetPort: 8080
selector:
app: java-maven-app
environment: stg
track: stable
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}
As you can see, I put {{.Release.namespace}} on 2 places:
metadata.namespace fieldmetadata.annotations.testAnnotate field.But it only renders the correct namespace on metadata.namespace field. Any idea why?
Release. Namespace : The namespace to be released into (if the manifest doesn't override) Release. IsUpgrade : This is set to true if the current operation is an upgrade or rollback. Release.
A Release is an instance of a chart running in a Kubernetes cluster. One chart can often be installed many times into the same cluster. And each time it is installed, a new release is created. Consider a MySQL chart. If you want two databases running in your cluster, you can install that chart twice.
The generated value .Release.Namespace is case-sensitive. The letter N in "namespace" should be capitalized.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With