helm操作手册

helm安装

# 安装
wget https://get.helm.sh/helm-v3.8.1-linux-amd64.tar.gz
tar -zxvf helm-v3.8.1-linux-amd64.tar.gz 
ln -s /root/linux-amd64/helm /usr/bin/helm
# 查看版本
$ helm version
version.BuildInfo{Version:"v3.8.1", GitCommit:"5cb9af4b1b271d11d7a97a71df3ac337dd94ad37", GitTreeState:"clean", GoVersion:"go1.17.5"}

添加源

helm repo add stable https://charts.helm.sh/stable
helm repo add incubator https://charts.helm.sh/incubator
# 更新
helm repo update

使用

以安装kubefed为例:

$ helm repo add kubefed-charts https://raw.githubusercontent.com/kubernetes-sigs/kubefed/master/charts
$ helm repo update
$ helm search repo kubefed
NAME                    CHART VERSION   APP VERSION     DESCRIPTION
kubefed-charts/kubefed  0.6.1                           KubeFed helm chart

$ helm --namespace kube-federation-system upgrade -i kubefed kubefed-charts/kubefed --version=0.6.1 --create-namespace
Release "kubefed" does not exist. Installing it now.
NAME: kubefed
LAST DEPLOYED: Wed Aug  5 16:03:46 2020
NAMESPACE: kube-federation-system
STATUS: deployed
REVISION: 1
TEST SUITE: None

下载到本地

helm pull kubefed-charts/kubefed

常用命令

# 自定义chart
helm create helloworld

# 校验自定义chart helloworld配置文件是否正确
helm lint helloworld

# 发版测试
# “--dry-run”:模拟安装;“--debug” :检测输出
# 执行命令后,即可输出该目录模板的yaml文件内容
helm --kubeconfig /root/.kube/config --dry-run --debug -i --namespace=main --set replicaCount=1 helloworld /root/helloworld

# 发版
# --kubeconfig:指定证书路径, helloworld:chart名称, /root/helloworld:chart路径
helm --kubeconfig /root/.kube/config upgrade -i --namespace=main --set replicaCount=1 helloworld /root/helloworld

# 回滚
#1 -n:命名空间, history:展示历史版本
helm -n main history helloworld
#2 执行回滚第8个版本
helm --kubeconfig /root/.kube/config rollback helloworld 8 -n dev

# 卸载自定义chart
# -n:命名空间,helloworld:chart名称
helm -n dev uninstall helloworld

# 批量删除状态为DELETED的chart应用
helm list -a | grep DELETED | awk '{print $1}' |  xargs helm del --purge
posted @ 2022-03-15 20:26  MegaloBox  阅读(456)  评论(0编辑  收藏  举报