k8s之helm管理工具


1.簡介

helm是k8s中的一個包管理工具,通過charts(一組yaml文件),來安裝,升級,k8s中的程序。類似於Centos中的yum包管理工具

2.三大概念

2.1 charts

charts是一個helm的包,包含k8s集群中運行的應用程序,工具,或者服務所需的所有資源定義

2.2 Repository

存放charts的倉庫,類似於Centos中的yum源,不過這個是適用於k8s的軟件包

2.3 release

在k8s集群中運行的chart的實例被稱為release。

同一個Chart可以安裝成多個Release,但是對同一個Release也有可能需要進行多次更新,這是就可以使用到RELEASE NUMBER(也被稱為RELEASE VERSION)的概念了。無論是更新還是回滾,每次Release的變化都會導致RELEASE NUMBER的遞增。

操作 Release Number
install release 1
upgrade release 2
upgrade release 3
rollback 1 release 4 (雖然是release 4,但是運行的配置和release 1等同)

3. 組成

helm由兩個部分組成

3.1 helm client

命令行工具

3.1.1 作用

  • 本地chart的開發
  • 倉庫管理
  • 與 Tiller sever 交互
  • 部署、升級、卸載 release

3.2 Tiller server

部署在集群中的一個服務,與helm client 和api-server交互

3.2.1作用

  • 接收helm client 請求
  • 安裝chart到集群

4 安裝helm

4.1 下載helm client 並解壓

下載release版本

wget https://get.helm.sh/helm-v2.16.9-linux-amd64.tar.gz
tar -zxvf helm-v2.16.9-linux-amd64.tar.gz
mv linux-amd64/helm /usr/local/bin/helm

4.2 創建tiller,並授權

cat > helm-rabc.yaml <<EOF
apiVersion: v1
kind: ServiceAccount
metadata:
  name: tiller
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: tiller
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
  - kind: ServiceAccount
    name: tiller
    namespace: kube-system
EOF
kubectl apply -f  helm-rabc.yaml

4.3 安裝helm server

helm init --service-account tiller   --tiller-image registry.cn-hangzhou.aliyuncs.com/google_containers/tiller:v2.16.6 --stable-repo-url https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts

4.4 檢查是否安裝成功

4.4.1報錯信息
helm version
Client: &version.Version{SemVer:"v2.16.9", GitCommit:"8ad7037828e5a0fca1009dabe290130da6368e39", GitTreeState:"clean"}
E0701 09:36:25.975087   24523 portforward.go:400] an error occurred forwarding 37857 -> 44134: error forwarding port 44134 to pod 2ebd3e540d81a8fca8e8a5693c42b9c8d5e974b00b7dd663b1339269975a68c1, uid : unable to do port forwarding: socat not found
E0701 09:36:26.977954   24523 portforward.go:400] an error occurred forwarding 37857 -> 44134: error forwarding port 44134 to pod 2ebd3e540d81a8fca8e8a5693c42b9c8d5e974b00b7dd663b1339269975a68c1, uid : unable to do port forwarding: socat not found
E0701 09:36:28.456773   24523 portforward.go:400] an error occurred forwarding 37857 -> 44134: error forwarding port 44134 to pod 2ebd3e540d81a8fca8e8a5693c42b9c8d5e974b00b7dd663b1339269975a68c1, uid : unable to do port forwarding: socat not found
E0701 09:37:01.165354   24523 portforward.go:340] error creating error stream for port 37857 -> 44134: Timeout occured
E0701 09:37:24.867441   24523 portforward.go:362] error creating forwarding stream for port 37857 -> 44134: Timeout occured
E0701 09:37:51.981064   24523 portforward.go:362] error creating forwarding stream for port 37857 -> 44134: Timeout occured

E0701 09:38:24.446395   24523 portforward.go:340] error creating error stream for port 37857 -> 44134: Timeout occured

4.4.2解決

在所有node節點安裝socat

yum  -y install socat

helm version
Client: &version.Version{SemVer:"v2.16.9", GitCommit:"8ad7037828e5a0fca1009dabe290130da6368e39", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.16.6", GitCommit:"dd2e5695da88625b190e6b22e9542550ab503a47", GitTreeState:"clean"}

5 參考文獻

https://helm.sh/docs/
https://blog.csdn.net/kozazyh/article/details/79537996


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM