Last active
April 16, 2020 13:13
-
-
Save zdtsw/fb11fe5f067e8d8547999b5f5162fb28 to your computer and use it in GitHub Desktop.
Usage of Helm and commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. DIR1>helm create $chart | |
in the current dir, create a folder "chart" with structure | |
├── charts | |
├── Chart.yaml | |
├── templates | |
│ ├── deployment.yaml | |
│ ├── _helpers.tpl | |
│ ├── ingress.yaml | |
│ ├── NOTES.txt | |
│ ├── service.yaml | |
│ └── tests | |
│ └── test-connection.yaml | |
└── values.yaml | |
2. DIR1> helm lint $chart | |
check all syntax fine for the edit | |
3. DIR1>helm template $chart | |
it render $chart's template with values injected and show output to stdout | |
4. DIR1> helm package $chart | |
archieve folder $chart into a chart-version.tgz file | |
the folder's name need to match the inside Chart.yaml's "name" value | |
5. DIR1> helm repo index $chart --url https://nexus.mycompany.com/repository/helm_internal/ | |
generate index.yaml file | |
or | |
DIR1> helm repo index --merge index.yaml --url https://nexus.mycompany.com/repository/helm_internal/ $chart | |
merge a new chart info into existing index.yaml | |
6. DIR1>curl -u admin:adminpassword https://nexus.mycompany.com/repository/helm_internal/ --upload-file $chart-$version.tgz -v | |
use curl to update or use WEB GUI | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
By default, tiller installed in kub-system as deployment "tiller-deploy" | |
By default, tiller stores release information in ConfigMaps in the namespace where it is running, but now support to user Secrets | |
1.download helm from official release | |
2.untar it and put the binary helm into your path | |
3.> helm init | |
which will create folder ~/.helm and sub folder and set this as a local repo (just like ~/.docker put later added repo config into it) | |
>helm version | |
to verify both client and tiller version | |
>helm init --client-only will only condig helm not install tiller | |
when you have a new version helm just do >./helm init --upgrade to update tiller | |
4. when you see "Error: incompatible versions client[v2.16.5] server[v2.14.1]" similarity | |
>helm init --upgrade | |
is need to upgrade tiller version to the same as the locla helm version |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A Chart is a Helm package | |
A Repository is the place where charts can be collected and shared | |
A Release is an instance of a chart running in a Kubernetes cluster | |
=>Helm installs charts into Kubernetes, creating a new release for each installation. And to find new charts, you can search Helm chart repositories. | |
3.>helm search $keyword [below 3.1.0 version] | |
>helm search repo $keyword [3.1.0 and above] | |
show charts in the repo with keyword in chart's inspect keywords | |
4.>helm inspect values $chart | |
check config values for non-default chart installation can be used | |
5.>helm install [--set key1=nonStringValue1, key2=nonStringValue2 | --set-string key3=straingValue3 | -f value4.yaml] [--version $version] [ --name $name ] $chart [--debug --dry-run] [--timeout $time] [--tiller-namespace $tiller_namespace] [--namespace $release_namespace] | |
install chart from any of the repo available | |
value4.yaml is only the contents of customized values, no need to including default values | |
if use --debug --dry-run will only generated yaml file but not install | |
all the value set/pass from commandline will have the later one overwrite the previous one | |
if not use --version, it set to use latest one | |
by default timeout is 300s | |
--set foo=true results an int64 value. | |
--set-string foo=true results in a string value of "true". | |
Examples of how to use set for different yaml and special cases: | |
--set key=value translate to yaml format | |
key:value | |
--------- | |
--set name="value1\,value2" will become: | |
name: "value1,value2" | |
--------- | |
--set nodeSelector."kubernetes\.io/role"=master becomes | |
nodeSelector: | |
kubernetes.io/role: master | |
---------- | |
--set outer.inner=value is translated | |
outer: | |
inner: value | |
--------- | |
--set key={v1, v2} translates to | |
key: | |
- v1 | |
- v2 | |
--------- | |
--set servers[0].port=80,servers[0].host=example becomes: | |
servers: | |
- port: 80 | |
host: example | |
There are five different ways you can express the chart you want to install: | |
By chart reference: helm install $repo/$chart | |
By path to a packaged chart: helm install ./$mychart.tgz | |
By path to an unpacked chart directory: helm install ./local_folder | |
By absolute URL: helm install https://example.com/charts/somechart.tgz | |
By chart reference and repo url: helm install --repo https://example.com/charts/ $chart | |
6. >helm status $chart | |
do a check see if status is "deployed" | |
7. >helm get values $releaseName | |
show the values passed when helm install/upgrade set | |
8.> helm fetch $repo/$chart | |
this only download the chart/tgz | |
9.> helm inspect [--version $version] $repo/$chart | |
get all information including readme including yalm | |
if not use --version, it set to use latest one | |
10.> helm list | |
list all currently deployed releases in the cluster | |
>helm list --deleted | |
list all deleted release in the cluster | |
>helm list --all | |
list all inlcuding deleted relases in the cluster | |
11.> helm delete $releasName | |
delete this release from cluster | |
12. >helm status $releaseName | |
do a check see if status is "deleted" | |
13. >helm upgrade -f my.yaml $releaseName $chart | |
upgrade to exisiting $releaseName with $chart' value.yaml but overwrite by my.yaml | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Helm plugins can be added and removed from a Helm installation without impacting the core Helm tool. | |
They can be written in any programming language. | |
Helm plugins live in $(helm home)/plugins | |
├── plugin.yaml | |
├── exe.sh (can be any name but need to be matching whats in plugin.yaml) | |
└── README.md | |
When Helm executes a plugin, it passes the outer environment to the plugin, and also injects some additional environment variables | |
1. >helm plugin install [$path|$url] | |
install a plugin either from local tgz file or from internet | |
2. >helm plugin list | |
list all the plugin installed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. >helm repo add dev https://example.com/dev-charts | |
Add a new repository, name as "dev" with url | |
2.> helm repo list | |
do a check you should see at least one local repo . | |
if you do not have problem to access https://kubernetes-charts.storage.googleapis.com/index.yam | |
3.> helm repo update | |
update list of charts from above repo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. >helm history $releaseName | |
check the release version. every install, upgrade, rollback, version increase 1 | |
2. > helm rollback $releaseName [$version] | |
re-install release from cluster |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{- (with the dash and space added) indicates that whitespace should be chomped left, while -}} means whitespace to the right should be consumed. Be careful! Newlines are whitespace! | |
if you want a new line, do not have - in front of }} on the previous line | |
It is considered preferable to use include over template in Helm templates simply so that the output formatting can be handled better for YAML documents. | |
While chart developers have a choice between include and template, one advantage of using include is that include can dynamically reference templates: | |
{{ include $mytemplate }} | |
The above will dereference $mytemplate. The template function, in contrast, will only accept a string literal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
YAML files that have template directives embedded in {{ }} | |
Release: This object describes the release itself. It has several objects inside of it: | |
.Release.Name: The release name | |
.Release.Time: The time of the release | |
.Release.Namespace: The namespace to be released into (if the manifest doesn’t override) | |
.Release.Service: The name of the releasing service (always Tiller). | |
.Release.Revision: The revision number of this release. It begins at 1 and is incremented for each helm upgrade. | |
.Release.IsUpgrade: This is set to true if the current operation is an upgrade or rollback. | |
.Release.IsInstall: This is set to true if the current operation is an install. | |
Values: Values passed into the template from the values.yaml file and from user-supplied files. By default, Values is empty | |
The values.yaml file in the chart | |
If this is a subchart, the values.yaml file of a parent chart | |
A values file is passed into helm install or helm upgrade with the -f flag (helm install -f myvals.yaml ./mychart) | |
Individual parameters passed with --set (such as helm install --set foo=bar ./mychart) | |
Chart: The contents of the Chart.yaml file. Any data in Chart.yaml will be accessible here. | |
Template: Contains information about the current template that is being executed | |
Name: A namespaced filepath to the current template (e.g. mychart/templates/mytemplate.yaml) | |
BasePath: The namespaced path to the templates directory of the current chart (e.g. mychart/templates). | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>helm init --client-only --skip-refresh | |
if you do not want to connect your helm to tiller | |
if you do not have internet connection from your local till https://kubernetes-charts.storage.googleapis.com | |
without "helm init" there is no garantee that other helm command might work | |
e.g helm package | |
after upgrade helm from 2.16.3 to 3.1.2 | |
old repo are gone, so need to helm add repo again | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment