Helm命令
Helm命令
目录
[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
查找chart:search命令
bash
[root@master ~]#helm search --helpUsage:helmsearch[command]AvailableCommands:hubsearchforchartsintheArtifactHuboryourownhubinstancereposearchrepositoriesforakeywordincharts#说明:helmsearchhub从artifacthub中搜索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.
软件包:
如果 CM 开启了验证,需要指定用户名和密码,
$ helm cm-push mychart-0.3.2.tgz chartmuseum -u username -p passwordPushing mychart-0.3.2.tgz to chartmuseum...Done.
更多参数可以使用 help 命令查看,
$ helm cm-push --helpHelm plugin to push chart package to ChartMuseumExamples:$ helm cm-push mychart-0.1.0.tgz chartmuseum # push .tgz from "helm package"$ helm cm-push . chartmuseum # package and push chart directory$ helm cm-push . --version="1.2.3"chartmuseum # override version in Chart.yaml$ helm cm-push . https:...
参考文档:
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
命令可以从多个源进行安装
- chart 仓库(类似于上面我们提到的)
- 本地 chart 压缩包(helm install foo-0.1.1.tgz)
- 本地解压缩的 chart 目录(helm install foo path/to/foo)
- 在线的 URL(helm install fool https:WARNING:ThischartisdeprecatedNAME:mysql-1649031212LASTDEPLOYED:MonApr408:13:372022NAMESPACE:defaultSTATUS:deployedREVISION:1NOTES:MySQLcanbeaccessedviaport3306onthefollowingDNSnamefromwithinyourcluster:mysql-1649031212.default.svc.cluster.localTogetyourrootpasswordrun:MYSQL_ROOT_PASSWORD=$(kubectlgetsecret--namespacedefaultmysql-1649031212-ojsonpath="{.data.mysql-root-password}"|base64--decode;echo)Toconnecttoyourdatabase:1.RunanUbuntupodthatyoucanuseasaclient:kubectlrun-i--ttyubuntu--image=ubuntu:16.04--restart=Never--bash-il2.Installthemysqlclient:$apt-getupdate&&apt-getinstallmysql-client-y3.Connectusingthemysqlcli,thenprovideyourpassword:$mysql-hmysql-1649031212-pToconnecttoyourdatabasedirectlyfromoutsidetheK8scluster:MYSQL_HOST=127.0.0.1MYSQL_PORT=3306# Execute the following command to route the connection:kubectlport-forwardsvc/mysql-16490312123306mysql-h${MYSQL_HOST} -P${MYSQL_PORT}-uroot-p${MYSQL_ROOT_PASSWORD}