Helm3 安装与使用
下载地址:https://github.com/helm/helm/releasestar xvf helm-v3.3.4-linux-amd64.tar.gzmv linux-amd64/helm /usr/local/bin/helm help#查看helm版本[root@k8s-master ~]# helm versionversion.BuildInfo{Version:"v3.3.4"
下载地址:https://github.com/helm/helm/releases
tar xvf helm-v3.3.4-linux-amd64.tar.gz
mv linux-amd64/helm /usr/local/bin/
helm help
#查看helm版本
[root@k8s-master ~]# helm version
version.BuildInfo{Version:"v3.3.4", GitCommit:"a61ce5633af99708171414353ed49547cf05013d", GitTreeState:"clean", GoVersion:"go1.14.9"}
helm completion
#helm 命令补全
yum install -y bash-completion
source /usr/share/bash-completion/bash_completion
source <(helm completion bash)
# 顺便补全kubectl。
source <(kubectl completion bash)
helm env
[root@k8s-master ~]# helm env
HELM_BIN="helm"
HELM_CACHE_HOME="/root/.cache/helm"
HELM_CONFIG_HOME="/root/.config/helm"
HELM_DATA_HOME="/root/.local/share/helm"
HELM_DEBUG="false"
HELM_KUBEAPISERVER=""
HELM_KUBECONTEXT=""
HELM_KUBETOKEN=""
HELM_NAMESPACE="default"
HELM_PLUGINS="/root/.local/share/helm/plugins"
HELM_REGISTRY_CONFIG="/root/.config/helm/registry.json"
HELM_REPOSITORY_CACHE="/root/.cache/helm/repository"
HELM_REPOSITORY_CONFIG="/root/.config/helm/repositories.yaml"
helm repo
Helm仓库管理
helm repo add #增加仓库
#添加helm官方stable仓库
helm repo add stable https://kubernetes-charts.storage.googleapis.com
[root@k8s-master ~]# helm repo list #查看仓库
NAME URL
stable https://kubernetes-charts.storage.googleapis.com
#以下是几个常用仓库添加命令:
helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo add aliyuncs https://apphub.aliyuncs.com
helm repo add kong https://charts.konghq.com
helm repo remove #删除本地仓库
helm repo update #更新本地仓库
Helm v3本地增加的仓库列表存放在/root/.config/helm/repositories.yaml
仓库的Chart清单应该是存储在Kubernetes的etcd中,但在/root/.cache/helm/repository存储了备份
helm search
查询chart包,查询命令分为helm search hub和helm search repo。
helm search hub,只从Helm Hub中查找Chart,这些Chart来自于注册到Helm Hub中的各个仓库。
helm search repo,从所有加到本地的仓库中查找应用,这些仓库加到本地时Chart清单文件已被存放到Kubernetes中,所以查找应用时无需联网。
[root@k8s-master ~]# helm search hub jenkins
URL CHART VERSION APP VERSION DESCRIPTION
https://hub.helm.sh/charts/jenkinsci/jenkins 2.17.0 lts Open source continuous integration server. It s...
https://hub.helm.sh/charts/bitnami/jenkins 5.0.28 2.249.3 The leading open source automation server
https://hub.helm.sh/charts/cloudposse/jenkins 0.1.2 A Jenkins Helm chart for Kubernetes
https://hub.helm.sh/charts/educations/jenkins 2.7.1 lts Open source continuous integration server. It s...
https://hub.helm.sh/charts/codecentric/jenkins 1.7.0 2.222.3 The leading open source automation server
https://hub.helm.sh/charts/choerodon/jenkins 0.1.0 2.60.3-alpine A Helm chart for Kubernetes
https://hub.helm.sh/charts/jenkins/jenkins-oper... 0.3.4 0.4.0 Kubernetes native operator which fully manages ...
https://hub.helm.sh/charts/cloudbees/cloudbees-... 2.235.203 2.235.2.3 CloudBees Jenkins Distribution provides develop...
https://hub.helm.sh/charts/odavid/my-bloody-jen... 0.1.138 2.249.3-232 A Helm chart for my-bloody-jenkins - a self con...
https://hub.helm.sh/charts/cloudbees/cloudbees-... 3.23.0+bbe45db86fa4 2.249.3.1 Enterprise Continuous Integration with Jenkins
https://hub.helm.sh/charts/webhookrelay-operato... 0.3.1 0.5.1 Webhook Relay Operator provides an easy way to ...
[root@k8s-master ~]# helm search repo jenkins
NAME CHART VERSION APP VERSION DESCRIPTION
aliyuncs/jenkins 4.1.5 2.204.2 The leading open source automation server
aliyuncs/jenkins-operator 0.3.0 0.3.0 A Helm chart for Kubernetes Jenkins Operator
stable/jenkins 2.5.4 lts DEPRECATED - Open source continuous integration...
#查询所有chart版本
helm search repo nginx --versions
#查询某个范围的chart版本,3.3.0以上版本的jenkins
[root@k8s-master ~]# helm search repo jenkins --version '>=3.3.0' --versions
NAME CHART VERSION APP VERSION DESCRIPTION
aliyuncs/jenkins 4.1.5 2.204.2 The leading open source automation server
aliyuncs/jenkins 4.1.4 2.204.2 The leading open source automation server
aliyuncs/jenkins 4.1.1 2.204.1 The leading open source automation server
aliyuncs/jenkins 4.0.3 2.190.2 The leading open source automation server
aliyuncs/jenkins 3.4.9 2.190.2 The leading open source automation server
aliyuncs/jenkins 3.4.5 2.190.1 The leading open source automation server
aliyuncs/jenkins 3.4.4 2.190.1 The leading open source automation server
aliyuncs/jenkins 3.4.3 2.190.1 The leading open source automation server
aliyuncs/jenkins 3.4.1 2.176.3 The leading open source automation server
aliyuncs/jenkins 3.4.0 2.176.3 The leading open source automation server
aliyuncs/jenkins 3.3.4 2.176.3 The leading open source automation server
aliyuncs/jenkins 3.3.3 2.176.3 The leading open source automation server
aliyuncs/jenkins 3.3.1 2.176.2 The leading open source automation server
helm pull
将Chart包下载到本地,缺省下载的是最新的Chart版本,并且是tgz包。
[root@k8s-master ~]# helm search repo nginx
NAME CHART VERSION APP VERSION DESCRIPTION
aliyuncs/nginx 5.1.5 1.16.1 Chart for the nginx server
aliyuncs/nginx-ingress 1.30.3 0.28.0 An nginx Ingress controller that uses ConfigMap...
aliyuncs/nginx-ingress-controller 5.3.4 0.29.0 Chart for the nginx Ingress controller
aliyuncs/nginx-lego 0.3.1 Chart for nginx-ingress-controller and kube-lego
aliyuncs/nginx-php 1.0.0 nginx-1.10.3_php-7.0 Chart for the nginx php server
bitnami/nginx 7.1.6 1.19.4 Chart for the nginx server
#下载nginx chart
helm pull aliyuncs/nginx
#下载指定版本
helm pull bitnami/tomcat --version 2.2.2
#下载chart后直接解压
helm pull bitnami/tomcat --untar
#下载到指定路径
helm pull stable/kong -d /root/helm/
helm install
安装chart实例,缺省安装最新Chart版本。
#其中myweb为Release名称,–set配置会覆盖Chart的values
helm install myweb nginx \
--set service.type=NodePort
[root@k8s-master ~]# helm list
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
myweb default 1 2020-11-10 01:53:25.7086594 -0500 EST deployed nginx-5.1.5 1.16.1
#安装特定版本的chart
helm install myweb bitnami/tomcat --version 6.0.0
#将chart安装到指定namespace下:
helm install myweb bitnami/tomcat -n web-ns
#–dry-run模拟安装应用,会输出每个模板生成的yaml内容,可查看将要部署的渲染后的yaml,检视这些输出,判断是否与预期相符
helm install cat tomcat --dry-run
其他常用命令
helm rollback //回滚
helm get //显示Release的各种信息。注意helm show命令是针对Chart的,helm get是针对Release的。
helm get values myweb //显示release的用户提供的values
helm get values myweb -a //显示所有的values
helm get manifest myweb //显示Release的所有的Kubernetes资源清单,注释标明了该资源生成于那个模板yaml文件
helm get notes myweb //显示Release的说明文件NOTES.txt
helm get all myweb //显示Release的所有信息,包括基本信息、说明信息、hooks,values和Kubernetes资源清单
helm create //创建一个模板Chart,会根据给定的Chart名称生成一个目录以及该Chart的一些样例文件
helm show chart
显示Chart.yaml信息,该文件描述了Chart的版本,描述,开发者等信息
[root@k8s-master ~]# helm show chart nginx
apiVersion: v1
appVersion: 1.16.1
description: Chart for the nginx server
home: http://www.nginx.org
icon: https://bitnami.com/assets/stacks/nginx/img/nginx-stack-220x234.png
keywords:
- nginx
- http
- web
- www
- reverse proxy
maintainers:
- email: containers@bitnami.com
name: Bitnami
name: nginx
sources:
- https://github.com/bitnami/bitnami-docker-nginx
version: 5.1.5
#显示values.yaml信息,该文件描述了Chart模板中各个可以覆盖的参数,这些参数都可以在安装Chart时被命令行参数覆盖。
helm show values nginx
helm show all nginx //通过一个命令显示Chart的所有信息,包括Chart.yaml, values.yaml和README.md
helm template
渲染Chart模板并打印输出,并不实际安装。和helm get manifest类似
helm template cat tomcat
helm dependency update
更新Chart申明的所有依赖符合要求的最新版本,更新的依赖的tgz包文件会放到charts路径下。更新之前会先更新所有的仓库。
helm lint
Helm运行一系列测试以验证Chart格式是否正确。如果遇到会导致Chart安装失败的事件,将发出[ERROR]消息。如果遇到违反约定或推荐的问题,将发出[WARNING]消息。
[root@k8s-master ~]# helm lint tomcat
==> Linting tomcat
1 chart(s) linted, 0 chart(s) failed
更多推荐
所有评论(0)