k8s_helm - henk52/knowledgesharing GitHub Wiki
Helm seems to be like a container deployment like what puppet/ansible is for application deployment/installation.
tar up all the yaml files used to deploy the whole solution. Includeing deployments, services, ingress etc.
- Where are the charts stored locally
- how does the helm thing map to
apt
- is it like terraform, but for k8s container instead of VMs?
- Helm home page
- Blo20 - 'Learning HELM' by Andrew Block and Austin Dewey, 2020 Packt Publishing
- Nan20 -
- Chart - an archived set of Kubernetes resource manifests that make up a distributed applicationLFS258.
- ConfigMap - TODO
- CR - Custom Resource[Blo20,p115]
- CRD - Custom Resource Definition[Blo20,p115]
- Helm uses the kubeconfig(Nan20, 4.6)
- e.g. /home/ubuntu/.kube/config
- so whatever kubectl is poiting to is what helm is using as well(Nan20, 4.6).
- helm create first-chart
- helm dependency
- helm dependency build - Rebuilds the charts/directory based on the Chart.lock file[Blo20,p122]
- TODO improve description
- If a Chart.lock file is not found, this command will mirror the behavior of the
helm dependency update
command
- helm dependency list - List the dependencies for the given chart[Blo20,p122]
- helm dependency update - Updates the charts/directory based on the content of Chart.yaml and generate a Chart.lock file[Blo20,p122]
- To download dependencies for the first time, you can run the helm dependency update command, which downloads each dependency into the charts/ directory of the given Helm chart[Blo20,p122]
- helm dependency update $CHART_PATH
- The helm dependency update command downloads dependencies from repositories in the form of GZip archives with the .tgz file extension[Blo20,p122].
- This command also generates a file called Chart.lock[Blo20,p122].
- The Chart.lock file is similar to the Chart.yaml file[Blo20,p122].
- However, while the Chart.yaml file contains the desired state of the chart dependencies,
- the Chart.lock file defines the actual state of the dependencies that were applied[Blo20,p122].
- To download dependencies for the first time, you can run the helm dependency update command, which downloads each dependency into the charts/ directory of the given Helm chart[Blo20,p122]
- helm dependency build - Rebuilds the charts/directory based on the Chart.lock file[Blo20,p122]
- helm lint .
- helm template first-chart .
- show how changes you have made?
- helm install first-chart .
- helm install wordpress bitnami/wordpress --values=wordpress-values.yaml --namespace chapter3 --version 8.1.0
- helm upgrade first-chart .
- helm history first-chart
- helm repo add
helm repo add bitnami https://charts.bitnami.com/bitnami
- helm search repo bitnami
- helm search repo wordpress
- helm search repo wordpress --versions
- helm rollback first-chart
- helm rollback first-chart 2
- helm search hub - search the helm hub for charts(Blo20, 56)
- helm search hub wordpress --output yaml
- helm search hub wordpress --max-col-width=0
- helm search repo - search the local repo for charts(Blo20, 56)
- helm show
- helm show values bitnami/wordpress --version 13.2.1
- helm show readme bitnami/wordpress --version 8.1.0
- helm search hub wordpress --list-repo-url | grep bitnami
- put the URL into your web browser:
https://artifacthub.io/packages/helm/bitnami/wordpress
- Go to the TL;DR; for the installation step
helm repo add bitnami https://charts.bitnami.com/bitnami
- helm install my-release bitnami/wordpress
- mk service list
- or
mk service my-release-wordpress
which will open the browser to the service - helm delete my-release
The primary purpose of a Helm chart is to create and manage the Kubernetes resources that make up an application[Bol20,p?].
- .helmignore
- Chart.lock
- Chart.yaml - contains some metadata about the Chart, like its name, version, keywords, and so on[lfs258]
- templates - contains the resource manifests that make up the application[lfs258]
- values*.yaml - contains keys and values that are used to generate the release in your cluster[lfs258].
- These values are replaced in the resource manifests using the Go templating syntax[lfs258]
File/Directory | Required | Notes |
---|---|---|
.helmignore | no | list of files and dirs that should be omitted from the helm chart's packaging. |
Chart.lock | (*) | A files used to save the previously applied dependency versions. *) Helm's dependency mgmt will create if missing. |
Chart.yaml | yes | metadata about the helm chart TODO embellish |
charts/ | (*) | store sub-charts that are dependencies of the top level chart *) Helm's dependency mgmt will create if missing. |
crds/ | no | Custom Resource Definition(CRD) YAML resources to be installed before resources under 'templates/' TODO figure out what this is about??? |
LICENSE | no | charts license. |
README.md | no(*) | *) every chart should contain this file as a best practice. |
templates/ | yes(*) | defines the Kubernetes resources to be deployed *) not required if dependencies are declared in Chart.yaml |
templates/NOTES.txt | no | Provide usage instructions during chart installation. displayed in the terminal when someone downloads this chart. |
values.yaml | no(*) | Charts default values. *) every chart should contain this file as a best practice. |
values.schema.json | no | charts values schema in JSON format. |
- string:
- integer:
- boolean:
- true
- false
- yes
- no
- on
- off
- y
- n
- Y
- N
- list
Relevant fields[Bo20,p118]:
- apiVersion - chart API version
- v2
- appVersion - Application version
- TODO where is this used?
- name - name of the helm chart
- version - version of the helm chart
- TODO where is this used?
Other metadata
- dependencies -
- description -
- home -
- icon - an icon in SVG/PNG (TODO is this the content or a reference). Displayed in the chart's page on Helm hub[Bo20,p119].
- type - application/library[Blo20,p115]
- This schema can be used to validate the provided values during an installation or an upgrade[Blo20,p105].
- This file is a good way of ensuring users only provide the values that are supported as parameters in the chart's templates[Blo20,p105].
TODO how to use this?
[Blo20,p120]
TODO could you use this, to install the whole system (all applications in the system)
dependencies:
- condition: memcached.enabled
name: memcached
repository: https://charts.bitnami.com/bitnami
version: 6.x.x
- condition: mariadb.enabled
name: mariadb
repository: https://charts.bitnami.com/bitnami
version: 11.x.x
- name - [Required]Name of the dependency chart[Blo20,p121]
- repository - [Required] [Blo20,p121]
- version - [Required] version of the depency chart to include[Blo20,p121]
- 7.x.x, which instructs Helm to download the latest version of the chart that matches the wildcard[Blo20,p121].
- alias - [optional] alternative name to give a dependency[Blo20,p121]
- condition - [optional] A boolean value that determines whether the dependency should be included or not[Blo20,p121]
- import-values - [optional] [Blo20,p121]
- tags - [optional] [Blo20,p121]
[Blo20,p115]
- Application charts are used to deploy full applications to Kubernetes[Blo20,p115].
- Library charts are used to provide named templates that may be used across multiple different charts[Blo20,p115].
- If set to library, the chart provides functions to other charts through the form of helper templates[Blo20,p119].
[Blo20,p115]
-
CRDs that must be presented before templates are installed[Blo20,p115]
-
CRs can be created using Helm templates such as native Kubernetes resources, but there must first be a Custom Resource Definition (CRD) that defines the CR[Blo20,p115].
- If the CRD is not present before the CR is created, the installation will fail[Blo20,p115].
-
creating CRDs requires escalated privileges, requiring the user to be a cluster administrator[Blo20,p116].
Helm templates are the 'brains' of your Helm chart and are used to generate Kubernetes resources[Bol20,p116].
It seems that '{{ }}' are referred to as Go templates(lrn103)
-
.Capabilities.APIVersions - return a list of the API versions available in the k8s cluster.[Blo20,p104]
- TODO what is this used for?
-
.Chart - refer to fiels in the Chart.yaml file[Blo20,p104].
-
.Files - file operations?
- .Files.AsConfig - Returns file bodies as a YAML map to create ConfigMap data from files in a chart directory[Blo20,p104]
- .Files.AsSecrets - Returns a file as a Base64-encoded string to create secret data from files a chart directory[Blo20,p104]
- TODO figure out what this means.
- .Files.Get - get a file in a chart directory.
-
.Release - provided by helm/read from helm
- e.g.
.Release.Namespace
The namespace to operate on.
- e.g.
-
.Template.Name - Returns the relative file path to the template that this object uses[Blo20,p104]
-
.Values - refer to values in the values.yaml files
-
The dot (.) prefixed to each object represents the object scope[Blo20,p104].
- A dot followed by an object name limits the scope to that object.
- For example,
- the .Values scope only makes a chart's values visible;
- the .Release scope only makes fields under the Release object visible;
- the . scope represents global scope, making all of these objects visible, plus the common objects defined in the preceding table
- For example,
- A dot followed by an object name limits the scope to that object.
[Blo20,p108]
{{ $myvar := 'Hello World!' }}
data:
greeting.txt: |
{{ $myvar }}
[Blo20,p110]
[Blo20,p113]
- if/else - [Blo20,p106]
- with - [Blo20,p106]
- range - [Blo20,p106]
[Blo20,p112]
- and
- or
- not
- eq (short for equal)
- ne (short for not equal)
- lt (short for less than)
- le (short for less than or equal to)
- gt (short for greater than)
- ge (short for greater than or equal to)
[Blo20,p108]
spec:
ports:
{{- range .Values.servicePorts }}
- name: {{ - name }}
port: {{ .port }}
{{- end }}
The with action allows a developer to modify the scope of these values and reference them with a shortened syntax[Blo20,p107]:
{{- with .Values.application.resources.limits }}
cpu: {{ .cpu }}
memory: {{ .memory }}
{{- end }}
It seems like this contains the .yaml files you would normally use for kubernetes, like configmap.yaml, service.yaml etc.
These files are templating files, which can contain references to variables '{{ .Release.Name }}', these templates will be rendered into full kubernetes yaml files, during install and upgrade.
This file declares all of a chart's default values, which are referenced by Go templates and processed by Helm to dynamically generate Kubernetes resources(lrn).
curl https://baltocdn.com/helm/signing.asc | sudo apt-key add -
- sudo apt-get install apt-transport-https --yes
echo "deb https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list
- sudo apt-get update
- sudo apt-get install helm
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx(Nan20, 4.6)
- helm repo update
- helm install ingress-nginx ingress-nginx/ingress-nginx
- helm install <release_name> <chart_name>
- mkdir helm-course
- cd helm-course
- helm create first-chart
- find first-chart
- values.yaml - various config values? Used in the interpretation of the various other files like the files in 'templates/'
- templates/ - used for generating kubernetes manifests
- _helpers.tpl
- deployment.yaml
- serviceaccount.yaml
- hpa.yaml
- ingress.yaml
- NOTES.txt - displayed in the terminal when someone downloads this chart.
- service.yaml
- tests/
- test-connection.yaml
- Chart.yaml
- charts/ - store sub-charts that are dependencies of the top level chart
- .helmignore
Helm plugins
- helm secrets
- helm unittest
- helm monitor
helm plugin CMD
Chart.yaml missing[Bol20,p116]