Helm includes create command to make it easy for us to create charts
This command creates a new Nginx chart with name of our choice
Lets try to install the chart which we have create
The output from the command is
NAME: myapp
LAST DEPLOYED: Fri Aug 6 19:26:51 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
NOTES:
1. Get the application URL by running these commands:
export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=inventory,app.kubernetes.io/instance=myapp" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace default $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace default port-forward $POD_NAME 8080:$CONTAINER_PORT
Now refer the charts.yaml Refer Here for the offical docs
In this charts.yaml lets try to focus on some name value pairs
apiVersion: v2: This tells helm what structure of chart we are using. An apiVersion of v2 is designed for Helm3
name: inventory: The name used to identify the chart
version: 0.1.0: Charts can have many versions. Helm uses the version information to order and identify charts
Charts.yaml also contain descriptive information
home: URL of chart or projects
icon: an image in the form of URL
maintainers: contains list of maintainers
keywords: can hold list of keyworkds about the project
sources: list of URLs for the source code for project or chart
Helm is written in Go programming language and Go includes template packages. Helm leverages the text template package as the foundation for its templates Refer Here
{{ and }} are the opening and closing brackets to enter and exit the template logic
There are three parts to the template logic sepearted by a |. This is called as pipeline and works exactly in the sameway as pipeline in Unix/Linux Based system. The value or output of a function on the left is passed as a last argument to the next item in pipeline.
.Values.product This comes for the data passed in when the templates are rendered
This value is passed as last argument to the default function
The default is the helm function and output of default is passed to the quoted
The . at the start .Values.production is considered as root object in the current scope
Developing Templates
Helm uses the Go text template engine provided as part of standard Go Libarary
Actions:
Logic, control structures and data evaluations are wrapped by {{ and }}. These are called as actions.
Anything outside of actions is copied to output
When the curly braces are used to start and stop actions they can be accompanies by a – to remove leading or trailing white spaces.