Helm安裝和使用

一、 Helm簡(jiǎn)介

Helm是Kubernetes首選的包管理工具,在K8S中一個(gè)應(yīng)用可能多個(gè)YAML清單文件,當(dāng)應(yīng)用很多時(shí)這些清單文件就會(huì)顯得很亂。Helm便能很好解決這種問題,Helm charts可以為K8S YAML清單文件提供模板語法,而且可以實(shí)現(xiàn)應(yīng)用的一鍵部署、更新、回滾、刪除等等。
Helm只是客戶端,服務(wù)端是Tiller,具體架構(gòu)如下:
Helm安裝和使用
相關(guān)術(shù)語:

成都創(chuàng)新互聯(lián)公司堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:網(wǎng)站設(shè)計(jì)制作、成都做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的虎林網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!

Helm 命令行客戶端。
Tiller 服務(wù)端,部署在K8S集群中,負(fù)責(zé)監(jiān)聽Helm的請(qǐng)求、與K8S apiserver交互,實(shí)現(xiàn)應(yīng)用的應(yīng)用部署、更新等一系列操作。
Repository  chart倉庫,是一個(gè)http/https服務(wù)器。
Chart 安裝包,由一系列的清單文件組成。
Release chart部署到K8S后的實(shí)例。

二、 軟件環(huán)境

OS版本:Centos7.5
K8S版本:v1.14.0
Docker版本:18.09.5-ce
Helm版本:v2.13.1

三、 安裝配置Helm

1. 二進(jìn)制方式部署

倉庫地址:
https://github.com/helm/helm/releases
#根據(jù)需要下載對(duì)應(yīng)版本
wget https://storage.googleapis.com/kubernetes-helm/helm-v2.13.1-linux-amd64.tar.gz
tar zxf helm-v2.13.1-linux-amd64.tar.gz
mv linux-amd64/helm /usr/local/bin/
#helm使用方法
helm help

2. 為Tiller配置授權(quán)帳號(hào)

#當(dāng)前Kubernetes集群?jiǎn)⒂昧薘BAC,為tiller配置指定授權(quán)帳號(hào):

cat <<EOF> tiller.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  name: tiller
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
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

apply后查看創(chuàng)建結(jié)果

[root@k8s-master03]# kubectl get serviceaccount tiller -n kube-system -o wide
NAME     SECRETS   AGE
tiller   1         100s
[root@k8s-master03]# kubectl get clusterrolebinding tiller -o wide
NAME     AGE   ROLE                        USERS   GROUPS   SERVICEACCOUNTS
tiller   37s   ClusterRole/cluster-admin                    kube-system/tiller

3. 安裝服務(wù)端Tiller

#helm init

[root@k8s-master03]# helm init --service-account tiller -i registry.aliyuncs.com/google_containers/tiller:v2.13.1 --skip-refresh
Creating /root/.helm 
Creating /root/.helm/repository 
Creating /root/.helm/repository/cache 
Creating /root/.helm/repository/local 
Creating /root/.helm/plugins 
Creating /root/.helm/starters 
Creating /root/.helm/cache/archive 
Creating /root/.helm/repository/repositories.yaml 
Adding stable repo with URL: https://kubernetes-charts.storage.googleapis.com 
Adding local repo with URL: http://127.0.0.1:8879/charts 
$HELM_HOME has been configured at /root/.helm.

Tiller (the Helm server-side component) has been installed into your Kubernetes Cluster.

helm初始化默認(rèn)使用gcr.io源,由于國內(nèi)正常無法訪問,所以這里使了用阿里源。
注意tiller版本要和helm版本相同。
#helm init參數(shù)說明

--service-account 指定授權(quán)帳號(hào)
-i 指定倉庫鏡像
--skip-refresh 禁止Tiller更新索引,一般用于離線安裝
--node-selectors 選擇節(jié)點(diǎn)標(biāo)簽,將Tiller pod部署在指定節(jié)點(diǎn)上
--override 更改Tiller deployment屬性值
--output 跳過安裝,并輸出到j(luò)son或yaml格式的清單文件中,可以用于kubectl手工安裝,該選項(xiàng)類似于kubectl的—dry-run

#查看創(chuàng)建pod

[root@k8s-master03 ~]# kubectl get pods -n kube-system -l name=tiller                    
NAME                            READY   STATUS    RESTARTS   AGE
tiller-deploy-96f5d9ff4-ctswl   1/1     Running   0          45m

四、 使用Helm

#創(chuàng)建本地chart,會(huì)在本地生成一個(gè)文件夾,里面包含chart所需的所有文件
helm create chart名稱 選項(xiàng) 
#helm倉庫增刪改查
helm repo add
helm repo list
helm repo lremove
helm repo update
#從倉庫中查找可用的chart,如果不指定將列出所有的chart
helm search
helm search MySQL
#查看chart的詳細(xì)信息
helm inspect chart名稱
#將倉庫中的chart下載到本地保存為tar包
helm fetch chart名稱
#從chart安裝應(yīng)用
helm install chart名稱 選項(xiàng)
#查看當(dāng)前集群中部署的release
helm list
#查看release的狀態(tài)
helm status release名稱
#查看release歷史版本
helm history release名稱
#升級(jí)release
helm upgrade release名稱 chart名稱 選項(xiàng)
#回滾release
helm rollback release名稱 版本號(hào) 選項(xiàng)
#刪除release
helm delete release名稱 選項(xiàng)

參考:
helm安裝
https://helm.sh/docs/using_helm/#installing-helm
https://www.cnrancher.com/docs/rancher/v2.x/cn/installation/ha-install/helm-rancher/tcp-l4/helm-install/
helm命令詳解
https://helm.sh/docs/helm/

本文名稱:Helm安裝和使用
當(dāng)前URL:http://bm7419.com/article32/giggsc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供域名注冊(cè)服務(wù)器托管、電子商務(wù)商城網(wǎng)站、網(wǎng)站策劃、搜索引擎優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)公司