Master Helm: A Complete Guide to Kubernetes Package Management and Deployment
This comprehensive tutorial explains Helm, the Kubernetes package manager, covering core concepts, workflow, differences between Helm 3 and Helm 2, installation steps, repository handling, chart structure, custom chart creation, deployment, upgrade, rollback, and integration with Harbor, providing practical commands and examples.
Concepts
Helm is the package manager for Kubernetes. It uses Charts (collections of YAML files) to define, package, and deploy applications. A Release is an instance of a Chart deployed in a cluster.
Helm's official website provides installation guides, documentation, chart repositories, and community contributions.
Helm Core Concepts
Chart : a package of Kubernetes resources.
Repository : a storage location for Charts.
Release : a deployed instance of a Chart.
Helm Workflow
Find Chart : search in repositories.
Install Chart : helm install to deploy.
Manage Release : helm upgrade, helm rollback, helm uninstall.
Maintain Repository : add, update, remove repos.
Helm 3 vs Helm 2
Helm 2 uses a server component called Tiller; Helm 3 removes Tiller and communicates directly with the Kubernetes API, simplifying architecture and improving security.
Helm Deployment
Install Helm
Download Helm client
Visit the Helm GitHub releases page and download the appropriate binary for your OS.
tar -zxvf helm-v3.6.0-linux-amd64.tar.gz
mv linux-amd64/helm /usr/local/bin/helmVerify installation
# helm version
helm versionEnable command completion
# echo "source <(helm completion bash)" >> ~/.bashrcUse Helm to install a Chart
Add repositories
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo add stable http://mirror.azure.cn/kubernetes/charts
helm repo add aliyun https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
helm repo add incubator https://charts.helm.sh/incubatorUpdate repositories
helm repo updateList repositories
helm repo listSearch Chart information
helm show chart stable/mysql
helm show all stable/mysqlInstall Chart
helm install my-redis bitnami/redis
helm install bitnami/redis --generate-nameList releases
helm ls
helm listCheck release status
helm status my-redisDelete release
helm uninstall my-redisHelm Chart Custom Templates
Inspect Chart files
Charts consist of Chart.yaml, values.yaml, and a templates directory containing resource definitions such as Deployments, Services, Ingress, ConfigMaps, Secrets, etc.
Chart structure example
mychart/
├── Chart.yaml
├── README.md
├── templates/
│ ├── deployment.yaml
│ ├── service.yaml
│ └── ...
└── values.yamlCreate a custom Chart
helm create nginx
tree nginxEdit Chart.yaml to set metadata (name, version, description) and modify values.yaml to configure parameters such as image repository, tag, service type, ingress settings, resources, etc.
Package and deploy custom Chart
helm lint nginx
helm package nginx
helm install nginx ./nginx --dry-run --debug
helm install nginx ./nginx -n defaultDeploy Ingress Nginx
wget https://gitee.com/mirrors/ingress-nginx/raw/nginx-0.30.0/deploy/static/mandatory.yaml
wget https://gitee.com/mirrors/ingress-nginx/raw/nginx-0.30.0/deploy/static/provider/baremetal/service-nodeport.yaml
kubectl apply -f mandatory.yaml
kubectl apply -f service-nodeport.yamlUpgrade Chart (NodePort example)
# modify values.yaml: set service.type to NodePort and define nodePort
helm upgrade nginx nginxRollback
Rollback a Release
helm history nginx
helm rollback nginx 1
helm history nginxMaintain Chart.yaml and values.yaml for updates. Use the --set flag to override values without editing values.yaml:
helm upgrade nginx nginx --set image.tag='1.15'Helm Repository with Harbor
Install Harbor
# download and extract harbor-offline-installer
# edit harbor.yml (hostname, admin password, data volume, enable chartmuseum)
./install.sh --with-clair --with-chartmuseumInstall Helm Push plugin
helm plugin install https://github.com/chartmuseum/helm-pushConfigure Helm repository
helm repo add harbor http://192.168.241.24/chartrepo/chart_repo --username=admin --password=Harbor12345Push Chart to Harbor
helm push nginx harborHelm Command Summary
Key Helm commands
completion : enable command completion.
create : create a new chart.
dependency : manage chart dependencies.
env : show Helm environment information.
get : retrieve extended information about a release.
help : display help for commands.
history : view release revision history.
install : deploy a chart as a release.
lint : validate chart syntax.
list (or ls ): list installed releases.
package : package a chart into a tgz archive.
plugin : manage Helm plugins (install, list, uninstall).
pull : download a chart from a repository.
repo : add, list, remove, update chart repositories.
rollback : revert a release to a previous revision.
search : search for charts in repositories.
show : display detailed chart information.
status : show the status of a release.
template : render chart templates locally.
test : run tests for a release.
uninstall : delete a release.
upgrade : upgrade an existing release.
verify : verify chart signatures.
version : display Helm client version.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Raymond Ops
Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
