天天看點

[kubernetes]系列四:安裝并使用helmhelm本地安裝helm3本地安裝helm指令補全操作Chart詳解

[kubernetes]系列四:helm使用詳解

  • helm本地安裝
  • helm3本地安裝
  • helm指令補全
  • 操作
  • Chart詳解

helm本地安裝

  • 檢視helm最新版本

    curl https://storage.googleapis.com/kubernetes-helm/

  • 下載下傳安裝包

    wget https://storage.googleapis.com/kubernetes-helm/helm-v2.14.1-linux-amd64.tar.gz

  • 解壓安裝

    tar -xvf ./helm-v2.14.1-linux-amd64.tar.gz

    cp -rf linux-amd64/helm /usr/local/bin/

    helm help

  • 修改鏡像源

    helm init --upgrade -i registry.cn-hangzhou.aliyuncs.com/google_containers/tiller:v2.14.1 --stable-repo-url https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts

-i registry.cn-hangzhou.aliyuncs.com/google_containers/tiller:v2.14.1

為tiller鏡像tag

–stable-repo-url

為阿裡雲的helm倉庫位址

參考:https://www.jianshu.com/p/4bd853a8068b

由于 kubernetes 從1.6 版本開始加入了 RBAC 授權。目前的 Tiller 沒有定義用于授權的 ServiceAccount, 通路 API Server 時會被拒絕,需要給 Tiller 加入授權。

  • 建立 Kubernetes 的服務帳号和綁定角色

    kubectl create serviceaccount --n kube-system tiller

    kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller

  • 給 Tiller 的 deployments 添加剛才建立的 ServiceAccount

    kubectl patch deploy --n kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}'

  • 檢視 Tiller deployments 資源是否綁定 ServiceAccount

    kubectl get deploy -n kube-system tiller-deploy -o yaml | grep serviceAccount

  • 檢查Tiller 是否安裝成功

    helm version

helm3本地安裝

  • 檢視版本

    https://github.com/helm/helm/releases

  • 下載下傳并安裝最新版本

    wget https://get.helm.sh/helm-v3.1.1-linux-arm64.tar.gz

    tar xvf helm-v3.1.1-linux-arm64.tar.gz

    cp linux-amd64/helm /usr/local/bin

    helm version

helm指令補全

echo "source <(helm completion bash)" > ~/.bashrc

source ~/.bashrc

操作

helm search

查詢已有chart; stable為官方倉庫;local為本地倉庫

helm repo list

查詢已有倉庫

helm repo add newrepo...

添加更多倉庫

helm install stable/mysql

安裝

helm install [CHART_NAME] --dry-run --debug

試安裝chart

helm lint [DIR_PATH]

檢查chart文法

helm history

檢查release所有版本

helm upgrade

更新

helm rollback [RELEASE_VISION]

復原

Chart詳解

繼續閱讀