Skip to content

Helm命令

Helm命令

img

目录

[toc]

helm相关

查看helm版本

bash
[root@master1 ~]#helm versionversion.BuildInfo{Version:"v3.7.2",GitCommit:"663a896f4a815053445eec4153677ddc24a0a361",GitTreeState:"clean",GoVersion:"go1.16.10"}

helm帮助命令

bash
[root@master1 ~]#helmTheKubernetespackagemanagerCommonactionsforHelm:-helmsearch:searchforcharts-helmpull:downloadacharttoyourlocaldirectorytoview-helminstall:uploadthecharttoKubernetes-helmlist:listreleasesofchartsEnvironmentvariables:|Name|Description||------------------------------------|-----------------------------------------------------------------------------------||$HELM_CACHE_HOME |setanalternativelocationforstoringcachedfiles.||$HELM_CONFIG_HOME |setanalternativelocationforstoringHelmconfiguration.||$HELM_DATA_HOME |setanalternativelocationforstoringHelmdata.||$HELM_DEBUG |indicatewhetherornotHelmisrunninginDebugmode||$HELM_DRIVER |setthebackendstoragedriver.Valuesare:configmap,secret,memory,sql.||$HELM_DRIVER_SQL_CONNECTION_STRING |settheconnectionstringtheSQLstoragedrivershoulduse.||$HELM_MAX_HISTORY |setthemaximumnumberofhelmreleasehistory.||$HELM_NAMESPACE |setthenamespaceusedforthehelmoperations.||$HELM_NO_PLUGINS |disableplugins.SetHELM_NO_PLUGINS=1todisableplugins.||$HELM_PLUGINS |setthepathtothepluginsdirectory||$HELM_REGISTRY_CONFIG |setthepathtotheregistryconfigfile.||$HELM_REPOSITORY_CACHE |setthepathtotherepositorycachedirectory||$HELM_REPOSITORY_CONFIG |setthepathtotherepositoriesfile.||$KUBECONFIG |setanalternativeKubernetesconfigurationfile(default "~/.kube/config") ||$HELM_KUBEAPISERVER |settheKubernetesAPIServerEndpointforauthentication||$HELM_KUBECAFILE |settheKubernetescertificateauthorityfile.||$HELM_KUBEASGROUPS |settheGroupstouseforimpersonationusingacomma-separatedlist.||$HELM_KUBEASUSER |settheUsernametoimpersonatefortheoperation.||$HELM_KUBECONTEXT |setthenameofthekubeconfigcontext.||$HELM_KUBETOKEN |settheBearerKubeTokenusedforauthentication.|Helmstorescache,configuration,anddatabasedonthefollowingconfigurationorder:-IfaHELM_*_HOMEenvironmentvariableisset,itwillbeused-Otherwise,onsystemssupportingtheXDGbasedirectoryspecification,theXDGvariableswillbeused-WhennootherlocationissetadefaultlocationwillbeusedbasedontheoperatingsystemBydefault,thedefaultdirectoriesdependontheOperatingSystem.Thedefaultsarelistedbelow:|OperatingSystem|CachePath|ConfigurationPath|DataPath||------------------|---------------------------|--------------------------------|-------------------------||Linux|$HOME/.cache/helm|$HOME/.config/helm|$HOME/.local/share/helm||macOS|$HOME/Library/Caches/helm|$HOME/Library/Preferences/helm|$HOME/Library/helm||Windows|%TEMP%\helm|%APPDATA%\helm|%APPDATA%\helm|Usage:helm[command]AvailableCommands:completiongenerateautocompletionscriptsforthespecifiedshellcreatecreateanewchartwiththegivennamedependencymanageachart's dependenciesenv helm client environment informationget download extended information of a named releasehelp Help about any commandhistory fetch release historyinstall install a chartlint examine a chart for possible issueslist list releasespackage package a chart directory into a chart archiveplugin install,list,or uninstall Helm pluginspull download a chart from a repository and (optionally) unpack it in local directoryrepo add,list,remove,update,and index chart repositoriesrollback roll back a release to a previous revisionsearch search for a keyword in chartsshow show information of a chartstatus display the status of the named releasetemplate locally render templatestest run tests for a releaseuninstall uninstall a releaseupgrade upgrade a releaseverify verify that a chart at the given path has been signed and is validversion print the client version informationFlags:--debug enable verbose output-h,--help help for helm--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.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") Use "helm [command] --help"for more information about a command.[root@master1 ~]#

helm repo

查看当前helm chart仓库:list命令

bash
helmrepolist==helmrepols例子:[root@Devops6 ~]#helm repo listWARNING:Kubernetesconfigurationfileisgroup-readable.Thisisinsecure.Location:/root/.kube/configWARNING:Kubernetesconfigurationfileisworld-readable.Thisisinsecure.Location:/root/.kube/configNAMEURLstablehttp:devops6repohttp:helmrepoaddapisixhttps:helmrepoupdate

更新helm仓库:update命令

bash
helmrepoupdate

img

查找chart:search命令

bash
[root@master ~]#helm search --helpUsage:helmsearch[command]AvailableCommands:hubsearchforchartsintheArtifactHuboryourownhubinstancereposearchrepositoriesforakeywordincharts#说明:helmsearchhubartifacthub中搜索helmsearchrepo从本地的仓库搜索

案例:

用 search 命令来搜索可以安装的 chart 包

bash
[root@master ~]#helm search repo或者[root@master ~]#helm search repo stableNAMECHARTVERSIONAPPVERSIONDESCRIPTIONstable/acs-engine-autoscaler2.2.22.1.1DEPRECATEDScalesworkernodeswithinagentpoolsstable/aerospike0.3.1v4.5.0.5AHelmchartforAerospikeinKubernetesstable/airflow5.2.11.10.4Airflowisaplatformtoprogrammaticallyautho...stable/ambassador5.1.00.85.0AHelmchartforDatawireAmbassadorstable/anchore-engine1.3.70.5.2Anchorecontaineranalysisandpolicyevaluatio...stable/apm-server2.1.57.0.0TheserverreceivesdatafromtheElasticAPMa.........

用 search 命令来搜索可以安装的 mysql chart 包:

虽然这里是一个废弃的版本,但是用来做测试是没任何问题的。

bash
[root@master ~]#helm search repo mysqlNAMECHARTVERSIONAPPVERSIONDESCRIPTIONstable/mysql1.6.95.7.30DEPRECATED-Fast,reliable,scalable,andeasy...stable/mysqldump2.6.22.4.1DEPRECATED!-AHelmcharttohelpbackupMySQL...stable/prometheus-mysql-exporter0.7.1v0.11.0DEPRECATEDAHelmchartforprometheusmysqlex...stable/percona1.2.35.7.26DEPRECATED-free,fullycompatible,enhanced,...stable/percona-xtradb-cluster1.0.85.7.19DEPRECATED-free,fullycompatible,enhanced,...stable/phpmyadmin4.3.55.0.1DEPRECATEDphpMyAdminisanmysqladministratio...stable/gcloud-sqlproxy0.6.11.11DEPRECATEDGoogleCloudSQLProxystable/mariadb7.3.1410.3.22DEPRECATEDFast,reliable,scalable,andeasyt...[root@master ~]#

推送包到helm chart仓库

本文由 简悦 SimpRead转码, 原文地址 blog.csdn.net

helm默认是不带 push 功能的,因此无法直接将本地的 chart 文件直接上传到 ChartMuseum 中。

1、安装插件

$ helm plugin install https:Downloading and installing helm-push v0.10.1 ...https:Installed plugin:cm-push
  • 直接安装二进制包
bash
mvhelm-cm-push/usr/bin/[root@Devops6 devops6-npm-service_HELMCI]#helm-cm-push devops6-npm-service-1.1.1.tgz devops6repoPushingdevops6-npm-service-1.1.1.tgztodevops6repo...Done.

image-20230708223118001

image-20230708223127871

软件包:

链接:https:Pushing mychart-0.3.2.tgz to chartmuseum...Done.

如果 CM 开启了验证,需要指定用户名和密码,

更多参数可以使用 help 命令查看,

参考文档:

  1. https:[root@master1 ~]#ll -h mysql-1.6.9.tgz -rw-r--r--1rootroot12KApr412:25mysql-1.6.9.tgz

helm install

部署helm实例:install命令

bash
## 安装charthelminstallRELEASE_NAMECHART_NAMEhelminstallhappy-pandabitnami/wordpress### 本地 chart 压缩包helminstallfoofoo-0.1.1.tgz### 解压后的 chart 目录helminstallfoopath/to/foo### 完整的 URLhelminstallfoohttps:Hangtightwhilewegrabthelatestfromyourchartrepositories......Successfullygotanupdatefromthe"stable"chartrepositoryUpdateComplete.HappyHelming!⎈

一条命令部署应用:

bash
案例1:[root@master1 ~]#helm upgrade --install longhorn longhorn/longhorn --create-namespace --namespace longhorn-system -f values.yaml#说明longhorn应用的名称longhorn/longhornchart包upgrade--install第一次是安装,后面就是更新了--create-namespace如果是本次需要用到的命名空间,可以加上这个参数案例2:[root@master1 ~]#helm upgrade --install traefik ./traefik -f ./traefik/ci/deployment-prod.yaml --create-namespace --namespace kube-systemRelease"traefik"hasbeenupgraded.HappyHelming!NAME:traefikLASTDEPLOYED:SunJan1611:55:132022NAMESPACE:kube-systemSTATUS:deployedREVISION:2TESTSUITE:None

helm install命令可以从多个源进行安装

helm升级:upgrade命令

helm rollback

rollback命令

bash
## 回滚helmhistory[RELEASE] 命令来查看一个特定 release 的修订版本号。helmrollbackhelmrollback[RELEASE] [REVISION]

例子:

bash
[root@master1 ~]#helm rollback mysql 1Rollbackwasasuccess!HappyHelming!

helm release

查看与卸载helm实例

bash
1.查看已经安装的release[root@master1 ~]#helm list -n apisix #helm lsNAMENAMESPACEREVISIONUPDATEDSTATUSCHARTAPPVERSIONapisixapisix12022-02-1407:30:08.608328227+0800CSTdeployedapisix-0.7.22.10.0或者:helmstatusmysql-1649031212#查看release的状态2.卸载helm实例[root@master1 ~]#helm uninstall apisix -n apisixrelease"apisix"uninstalled或者helmuninstallmysql-1575619811--keep-historyrelease"mysql-1575619811"uninstalled

也可以在删除的时候使用 --keep-history参数,则会保留 release 的历史记录,可以获取该 release 的状态就是 UNINSTALLED,而不是找不到 release了:

bash
helmuninstallmysql-1575619811--keep-historyrelease"mysql-1575619811"uninstalledhelmstatusmysql-1575619811helmstatusmysql-1575619811NAME:mysql-1575619811LASTDEPLOYED:FriDec616:47:142019NAMESPACE:defaultSTATUS:uninstalled...helmls-aNAMENAMESPACEREVISIONUPDATEDSTATUSCHARTAPPVERSIONmysql-1575619811default12019-12-0616:47:14.415214+0800CSTuninstalledmysql-1.5.05.7.27

因为 Helm 会在删除 release 后跟踪你的 release,所以你可以审查历史甚至取消删除 release(使用 helm rollback命令)。

⚠️ 注意:也可以使用helm delete来卸载release

bash
[root@master ~]#helm lsNAMENAMESPACEREVISIONUPDATEDSTATUSCHARTAPPVERSIONmysql-1711286279default12024-03-2421:18:00.924308284+0800CSTdeployedmysql-1.6.95.7.30[root@master ~]#helm delete mysql-1711286279release"mysql-1711286279"uninstalled[root@master ~]#helm lsNAMENAMESPACEREVISIONUPDATEDSTATUSCHARTAPPVERSION[root@master ~]#

查看某个release通过-f或者--自定义的值

bash
[root@master ~]#helm get values mysqlUSER-SUPPLIEDVALUES:mysqlDatabase:user0dbmysqlPassword:user0pwdmysqlUser:user0persistence:enabled:false[root@master ~]#

追踪release的状态

bash
## 追踪release的状态helmstatushappy-panda

查看某个release的历史

bash
[root@master1 ~]#helm history mysql

查看release安装后对应的k8s资源状态

bash
[root@master1 ~]#kubectl get all -l release=mysql-1649031212NAMEREADYSTATUSRESTARTSAGEpod/mysql-1649031212-9df8c986b-8tj8z1/1Running02m3sNAMETYPECLUSTER-IPEXTERNAL-IPPORT(S) AGEservice/mysql-1649031212ClusterIP10.105.125.254<none>3306/TCP2m4sNAMEREADYUP-TO-DATEAVAILABLEAGEdeployment.apps/mysql-16490312121/1112m4sNAMEDESIREDCURRENTREADYAGEreplicaset.apps/mysql-1649031212-9df8c986b1112m3s

helm chart

查看一个 chart 包的所有可配置的参数选项

bash
helmshowvaluesstable/mysql## mysql image version## ref:https:##image:"mysql"imageTag:"5.7.30"strategy:type:Recreatebusybox:image:"busybox"tag:"1.32"testFramework:enabled:trueimage:"bats/bats"tag:"1.2.1"imagePullPolicy:IfNotPresentsecurityContext:{}## Specify password for root user#### Default:random 10 character string# mysqlRootPassword:testing## Create a database user### mysqlUser:## Default:random 10 character string# mysqlPassword:## Allow unauthenticated access,uncomment to enable### mysqlAllowEmptyPassword:true## Create a database### mysqlDatabase:## Specify an imagePullPolicy (Required)## It's recommended to change this to 'Always'if the image tag is 'latest'## ref:http:##imagePullPolicy:IfNotPresent......

查看chart包的特性

bash
[root@master1 ~]#helm show chart stable/mysqlapiVersion:v1appVersion:5.7.30deprecated:truedescription:DEPRECATED-Fast,reliable,scalable,andeasytouseopen-sourcerelationaldatabasesystem.home:https:icon:https:keywords:-mysql-database-sqlname:mysqlsources:-https:-https:version:1.6.9
  • 如果想要了解更多信息,可以用 helm show all命令:
bash
helmshowallstable/mysql#可以看一些定制特性!......

查看一个 chart 包的所有可配置的参数选项

bash
## 查看chart中的可配置选项helmshowvaluesCHART_NAMEhelminstall-fvalues.yamlbitnami/wordpress--generate-name数据传递:--values/-f指定yaml文件--set命令行方式对值进行覆盖

helm get values来查看新设置是否生效

bash
[root@master1 ~]#helm get values mysql

helm debug命令

bash
[root@master1 ~]#helm ls --debug

helm template命令只渲染,不部署

bash
语法:~helmtemplate-hUsage:helmtemplate[NAME] [CHART] [flags]Render(渲染) chart templates locally and display the output.……

不部署,但可以将最终yaml文件给渲染出来:

bash
例子:$helmtemplatemysqlstable/mysql>mysql.yaml$catmysql.yaml

img

关于我

我的博客主旨:

  • 排版美观,语言精炼;
  • 文档即手册,步骤明细,拒绝埋坑,提供源码;
  • 本人实战文档都是亲测成功的,各位小伙伴在实际操作过程中如有什么疑问,可随时联系本人帮您解决问题,让我们一起进步!

🍀 微信二维码 x2675263825 (舍得), qq:2675263825。

image-20230107215114763

🍀 微信公众号 《云原生架构师实战》

image-20230107215126971

🍀 语雀

https:

版权:此文章版权归 One 所有,如有转载,请注明出处!

链接:可点击右上角分享此页面复制文章链接

上次更新时间:

最近更新