Helm’s NOTES.txt file is a powerful, yet often overlooked, mechanism for providing essential post-installation information to users.
Here’s a simple chart to demonstrate:
my-chart/
├── Chart.yaml
├── templates/
│ └── deployment.yaml
└── NOTES.txt
Chart.yaml:
apiVersion: v2
name: my-chart
version: 0.1.0
description: A simple chart with notes
templates/deployment.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: 1
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-app
image: nginx:latest
ports:
- containerPort: 80
NOTES.txt:
This is my-chart version {{ .Chart.Version }}
Your application is now deployed!
To access your application, you can use:
1. Port-forwarding:
kubectl port-forward service/my-app 8080:80
2. If you have an Ingress configured, check its status.
Need help? Visit our documentation at https://example.com/docs
When you install this chart using helm install my-release ./my-chart, the output will include the rendered NOTES.txt content:
NAME: my-release
LAST DEPLOYED: Tue Oct 26 10:00:00 2023
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
This is my-chart version 0.1.0
Your application is now deployed!
To access your application, you can use:
1. Port-forwarding:
kubectl port-forward service/my-app 8080:80
2. If you have an Ingress configured, check its status.
Need help? Visit our documentation at https://example.com/docs
The most surprising thing about NOTES.txt is that it’s not just a static file; it’s a Go template that can dynamically access and display information about the deployed release and its resources. This means you can tailor the instructions to the specific values provided during installation or even query Kubernetes for information about deployed objects.
The primary purpose of NOTES.txt is to guide users on how to interact with their deployed application after Helm has done its job. This could include:
- Accessing the application: Providing specific
kubectlcommands for port-forwarding, or detailing how to find external IP addresses for LoadBalancers. - Configuration details: Reminding users of important configuration values they set, or pointing them to configuration files.
- Next steps: Suggesting further actions, like setting up monitoring, integrating with other services, or visiting documentation.
- Troubleshooting tips: Offering common solutions to potential issues.
Internally, Helm processes the NOTES.txt file as a Go template. This allows you to use template functions and variables to inject dynamic data. Key objects available within the template context include:
.Release: Information about the Helm release (e.g.,.Release.Name,.Release.Namespace,.Release.Service)..Chart: Information about the chart itself (e.g.,.Chart.Name,.Chart.Version,.Chart.AppVersion)..Values: The values provided for the release, either fromvalues.yamlor--setflags..Capabilities: Information about the Kubernetes cluster capabilities..Files: Access to files within the chart archive.
You can even use the toYaml or toJson functions to print out configuration objects, or use Kubernetes API access via Capabilities.APIVersions to conditionally display information. For example, you could check if a specific API resource exists before suggesting how to access it.
A common advanced technique is to use lookup within NOTES.txt to query the Kubernetes API for specific resource information. For instance, if your chart deploys a Service of type LoadBalancer, you might want to output its external IP. However, it’s crucial to understand that lookup has performance implications and can make helm status and helm history calls slower, as it needs to query the cluster. Therefore, use it judiciously.
The ultimate goal is to provide a seamless user experience, ensuring that users can quickly and effectively start using the deployed application without needing to dig through raw Kubernetes manifests or the Helm chart’s internal structure.
The next logical step after mastering NOTES.txt is to explore how to implement complex conditional logic within your Helm charts using Go templates for more dynamic deployments.