Technical architectural analysis, practical configuration manifests, and deployment instructions for Kubernetes Helm 3 Sheet: Release & Rollback.
Installation
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
Exec
completion
echo "source <(helm completion bash)" >> ~/.bashrc
source ~/.bashrc
search
# artifacthub.io์์ ์ฐจํธ ๊ฒ์
helm search hub {{ ๊ฒ์์ด }}
# repository๋ช
์ผ๋ก ์ฐจํธ ๊ฒ์
helm search repo {{ ๊ฒ์์ด }}
repository: chart repository like Docker HUB
artifacthub.io:
- helm search hub โ Search for charts in Helm Hub or Monocular instance
- helm search repo โ Search repository for keywords in chart
# ๋ฆฌํฌ์งํ ๋ฆฌ ์ถ๊ฐ
helm repo add [NAME] [URL] [flags]
# helm repo add bitnami https://charts.bitnami.com/bitnami
# values show
helm show values $repo/$chart
helm show readme $repo/$chart
helm show chart $repo/$chart
helm show crds $repo/$chart
helm template .
helm show values kiali/kiali-server --version=v1.82.0 > values.origin
# ์ธ์คํจ
helm install my-release bitnami/<chart>
# values.yaml ๊ฒฝ๋ก์์
helm install ${appname} . -n ${namespace}
# ์
๊ทธ๋ ์ด๋
# values.yaml ๊ฒฝ๋ก์์
helm upgrade ${appname} . -n ${namespace}
# ํจํค์ง ํ์ผ ์์ฑ
helm package .
# ํจํค์ง ํ์ผ helm repository์ push
helm push $package.tgz oci://$myrepository/$project
repo
#index.yaml ํ์ฌ ๊ฒฝ๋ก ๊ธฐ์ค์ผ๋ก ์์ฑ (helm repository index)
helm repo index .
#helm repository ๋ฑ๋ก
helm repo add $repository $repositoryURL
list
helm list attributes
helm list --help
This command lists all of the releases for a specified namespace (uses current namespace context if namespace not specified).
By default, it lists only releases that are deployed or failed. Flags like
'--uninstalled' and '--all' will alter this behavior. Such flags can be combined:
'--uninstalled --failed'.
By default, items are sorted alphabetically. Use the '-d' flag to sort by
release date.
If the --filter flag is provided, it will be treated as a filter. Filters are
regular expressions (Perl compatible) that are applied to the list of releases.
Only items that match the filter will be returned.
$ helm list --filter 'ara[a-z]+'
NAME UPDATED CHART
maudlin-arachnid 2020-06-18 14:17:46.125134977 +0000 UTC alpine-0.1.0
If no results are found, 'helm list' will exit 0, but with no output (or in
the case of no '-q' flag, only headers).
By default, up to 256 items may be returned. To limit this, use the '--max' flag.
Setting '--max' to 0 will not return all results. Rather, it will return the
server's default, which may be much higher than 256. Pairing the '--max'
flag with the '--offset' flag allows you to page through results.
Usage:
helm list [flags]
Aliases:
list, ls
Flags:
-a, --all show all releases without any filter applied
-A, --all-namespaces list releases across all namespaces
-d, --date sort by release date
--deployed show deployed releases. If no other is specified, this will be automatically enabled
--failed show failed releases
-f, --filter string a regular expression (Perl compatible). Any releases that match the expression will be included in the results
-h, --help help for list
-m, --max int maximum number of releases to fetch (default 256)
--offset int next release index in the list, used to offset from start value
-o, --output format prints the output in the specified format. Allowed values: table, json, yaml (default table)
--pending show pending releases
-r, --reverse reverse the sort order
-l, --selector string Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2). Works only for secret(default) and configmap storage backends.
-q, --short output short (quiet) listing format
--superseded show superseded releases
--time-format string format time using golang time formatter. Example: --time-format "2006-01-02 15:04:05Z0700"
--uninstalled show uninstalled releases (if 'helm uninstall --keep-history' was used)
--uninstalling show releases that are currently being uninstalled
Global Flags:
--debug enable verbose output
--kube-apiserver string the address and the port for the Kubernetes API server
--kube-as-group stringArray group to impersonate for the operation, this flag can be repeated to specify multiple groups.
--kube-as-user string username to impersonate for the operation
--kube-ca-file string the certificate authority file for the Kubernetes API server connection
--kube-context string name of the kubeconfig context to use
--kube-token string bearer token used for authentication
--kubeconfig string path to the kubeconfig file
-n, --namespace string namespace scope for this request
--registry-config string path to the registry config file (default "/root/.config/helm/registry/config.json")
--repository-cache string path to the file containing cached repository indexes (default "/root/.cache/helm/repository")
--repository-config string path to the file containing repository names and URLs (default "/root/.config/helm/repositories.yaml")
pull
# dir๋ก ๋ค์ด๋ก๋
helm pull ${repo}/${appname} --untar --version=${chart-version}
install
# values.yaml ๊ฒฝ๋ก ๋ด์์
helm install -n ${namespace} ${appname} .
helm install -n ${namespace} ${appname} . --create-namespace
# ๋ฆฌํฌ์์ ๊ฐ์ ธ์ค๊ธฐ
helm install -n ${namespace} ${appname} ${repo}/${appname} --set ${flags_for_overwrite}
# map value set
#cat values.yaml | yq -o props
--set foo.bar={ foo: bar }
update
# values.yaml ๊ฒฝ๋ก ๋ด์์
helm update -n ${namespace} ${appname} .
uninstall
helm uninstall -n ${namespace} ${appname}
status
# helm release์ ๋ณด, ์ค์น Description ํ์ธ
helm status -n ${namespace} ${appname}
get
# deploy๋ ๋ชจ๋ template metadata ํ์ธ ( k8s-manifests )
helm get all -n ${namespace} ${appname}
OCI-based registry
In fact, the helm registry provided by Harbor is an OCI-based registry. This registry has a slightly different personality from the general helm chart registry. First of all, OCI-based registry support is officially available starting with Helm version 3.8, and it is said that OCI worked differently in Helm in versions prior to 3.8. So, to use the OCI-based registry normally, you must check whether the helm version is 3.8 or higher.
helm registry login $registry
helm registry logout $registry
helm push $package.tgz oci://$registry
helm pull oci://$registry
helm show $target oci://$registry
helm template $target oci://$registry
helm install $releasename -n $ns oci://$registry
helm upgrade $releasename -n $ns oci://$registry
Create Helm Chart
helm create $chartname
Tips for writing values
Tips for finding necessary values when changing chart structure
# ๊ธฐ์กด values.yaml์ ๋ฐฑ์
ํ๊ณ , ๋น values.yaml์ ์์ฑํ๋ค
mv values.yaml values-backup.yaml
> values.yaml
# ํ
ํ๋ฆฟ์ ํ
์คํธํด๋ณธ๋ค.
helm template mychart .
Error: template: cmp-common-si/templates/spring-cloud-vault.yaml:4:18: executing "cmp-common-si/templates/spring-cloud-vault.yaml" at <.Values.global.config.namePrefix>: nil pointer evaluating interface {}.config
Use --debug flag to render out invalid YAML
# yq๋ฅผ ์ด์ฉํ์ฌ ๋ฐฑ์
์์ ๊ฐ์ ธ์ด
cat values-backup.yaml | yq -oprops | grep 'global.config.namePrefix' | yq -pprops >> values.yaml
bjw-s-labs Guideline
Currently the most widely used repository in the Kubernetes community (especially when building GitOps-based infrastructures) to eliminate code repetition.
- Overview: Typical web apps, API servers, backends, etc. have more than 90% of the same Deployment, Service, Ingress, and PVC structures. This repository was created with the philosophy, โInstead of creating a new chart every time, just inject different values.yaml into one universal chart.โ
- How it works: You do not write any Helm Chart templates (YAML files). After importing this
app-templaterepository, simply declare the container image, port, ingress, and volume structure invalues.yamland the Kubernetes resources will be automatically rendered. - Repository address:
https://bjw-s-labs.github.io/helm-charts
1. Create a new chart directory structure
First, create a folder for the new chart. (Example: my-custom-app)
helm create my-custom-app
cd my-custom-app
rm -rf templates/*
Caution: Unlike the typical Helm structure, we do not create a templates folder or write YAML such as Deployment, Service, etc. directly in it.
2. Write Chart.yaml (define dependencies)
The most important thing in Chart.yaml is to register the bjw-s-labs repository as dependencies and fully import that chart’s functionality into my chart.
apiVersion: v2
name: my-custom-app
description: # input this
type: application
version: 1.0.0
appVersion: "1.0.0"
dependencies:
- name: common
version: 5.0.1
repository: https://bjw-s-labs.github.io/helm-charts/
or Local Repository
dependencies:
- name: common
version: 5.0.1
repository: "file://./charts/common"
helm repo add bjw-s https://bjw-s-labs.github.io/helm-charts/
cd charts
helm pull bjw-s/common --untar
3. Write values.yaml (application specification)
controllers:
main:
strategy: Recreate
containers:
main:
image:
repository: vaultwarden/server
tag: 1.25.2
env:
DATA_FOLDER: "config"
service:
main:
controller: main
ports:
http:
port: 80
websocket:
enabled: true
port: 3012
ingress:
main:
hosts:
- host: vaultwarden.example.com
paths:
- path: /
pathType: Prefix
service:
identifier: main
port: http
persistence:
config:
type: persistentVolumeClaim
accessMode: ReadWriteOnce
size: 1Gi
globalMounts:
- path: /config
4. Build dependencies and verify locally (CLI workflow)
Once the chart structure has been created, proceed with verification in the terminal according to the guidelines below.
#Step 1: ์์กด์ฑ ์ฐจํธ ๋ค์ด๋ก๋
helm dependency update ./my-custom-app
#Step 2: ํ
ํ๋ฆฟ ์ ์ ๋ถ์ (Lint)
helm lint ./my-custom-app
#Step 3: ์ต์ข
์ฟ ๋ฒ๋คํฐ์ค YAML ๋ ๋๋ง ํ์ธ (Dry-run / Template)
helm template my-release ./my-custom-app
๐ก Official Guidelines Key Summary
- Prohibit creation of templates: Leave the
templates/directory empty. All resource types are determined solely by structural declarations invalues.yaml. - Controller-centric structure: Based on the
controllers.structure, multi-container (Sidecar, etc.) patterns can also be easily extended within.containers. values.yaml. - Be careful about updates: When major version updates (e.g. v1 -> v2 -> v3), the
values.yamlschema structure tends to change significantly, so when declaring dependencies, you must keep the version fixed (v3.x.x) to keep the infrastructure stable.
features
Bitnami Chart Download / Control
# repo ๋ฑ๋ก
helm repo add bitnami https://charts.bitnami.com/bitnami
# ์ฐจํธ ์ ์ฒด ๋ฆฌ์คํธ
helm search repo bitnami
# ์ฐจํธ ๋ฒ์ ๋ฆฌ์คํธ
helm search repo bitnami/grafana -l
# ์ฐจํธ ๋ค์ด๋ก๋
helm pull bitnami/grafana --untar --version=8.2.17 #Chart-version
chart push for my repository OCI
docker login $myrepository
helm push $(helm package . | grep -o '/.*') oci://$myrepository/$project
Deploy to helm repository (1 depth)
helm package */.
helm repo index .
Generate Default value
helm show values ${repo}/${chart} > values.origin.yaml
Get Overwritten Values
#helm repo list
#...
repo= #Set your repo `Name` -- ์ฌ์ฉ์๊ฐ ๋ฑ๋กํ repo Name์ ์ผ๋ฐํํ ์ ์์.
sdiff -s \
<(helm show values ${repo}/$(cat Chart.yaml | yq '.name') \
--version=$(cat Chart.yaml | yq '.version') | yq -oprops) \
<(cat ./values.yaml | yq -oprops)




Leave a Reply