k8s/Kubernetes常用組件Helm的部署


Helm的安裝

1.Helm的基本概念
Helm是Kubernetes的一個包管理工具,用來簡化Kubernetes應用的部署和管理。可以把Helm比作CentOS的yum工具。 Helm有如下幾個基本概念:

Chart: 是Helm管理的安裝包,里面包含需要部署的安裝包資源。可以把Chart比作CentOS yum使用的rpm文件。每個Chart包含下面兩部分:
包的基本描述文件Chart.yaml
放在templates目錄中的一個或多個Kubernetes manifest文件模板
Release:是chart的部署實例,一個chart在一個Kubernetes集群上可以有多個release,即這個chart可以被安裝多次
Repository:chart的倉庫,用於發布和存儲chart
使用Helm可以完成以下事情:

管理Kubernetes manifest files
管理Helm安裝包charts
基於chart的Kubernetes應用分發

更詳細的介紹:
https://www.kubernetes.org.cn/3435.html

官方安裝文檔:https://helm.sh/docs/using_helm/#installing-helm
官方給的安裝腳本:https://raw.githubusercontent.com/helm/helm/master/scripts/get

安裝(我們手工使用二進制文件安裝)

先下載 helm 二進制文件
https://github.com/kubernetes/helm/releases
2.14版下載地址: https://storage.googleapis.com/kubernetes-helm/helm-v2.14.0-linux-amd64.tar.gz
解壓,可執行文件移動到/usr/local/bin/下

wget https://storage.googleapis.com/kubernetes-helm/helm-v2.14.0-linux-amd64.tar.gz
tar xvf helm-v2.14.0-linux-amd64.tar.gz
cd linux-amd64/
mv helm /usr/local/bin
cd ..
rm -rf  linux-amd64/

測試運行

[root@k8smaster centos]# helm  version
Client: &version.Version{SemVer:"v2.14.0", GitCommit:"05811b84a3f93603dd6c2fcfe57944dfa7ab7fd0", GitTreeState:"clean"}
Error: could not find tiller
#提示沒找到tiller

安裝tiller
為了安裝服務端tiller,還需要在這台機器上配置好kubectl工具和kubeconfig文件,確保kubectl工具可以在這台機器上訪問apiserver且正常使用。

因為Kubernetes APIServer開啟了RBAC訪問控制,所以需要創建tiller使用的service account: tiller並分配合適的角色給它。 詳細內容可以查看helm文檔中的Role-based Access Control。 這里簡單起見直接分配cluster-admin這個集群內置的ClusterRole給它。創建rbac-config.yaml文件:

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
[root@k8smaster ~]# kubectl create -f rbac-config.yaml 
serviceaccount/tiller created
clusterrolebinding.rbac.authorization.k8s.io/tiller created

helm部署tiller:

[root@k8smaster centos]# helm init --service-account tiller --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.

Please note: by default, Tiller is deployed with an insecure 'allow unauthenticated users' policy.
To prevent this, run `helm init` with the --tiller-tls-verify flag.
For more information on securing your installation see: https://docs.helm.sh/using_helm/#securing-your-helm-installation


如果鏡像拉取有問題,可以使用阿里雲的地址
helm init --upgrade -i registry.cn-hangzhou.aliyuncs.com/google_containers/tiller:v2.5.1 --stable-repo-url https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts

查看和驗證
tiller默認被部署在k8s集群中的kube-system這個namespace下:

[root@k8smaster ~]# kubectl get pod -n kube-system -l app=helm
NAME                             READY   STATUS    RESTARTS   AGE
tiller-deploy-598f58dd45-5q8pv   1/1     Running   0          4m23s
[root@k8smaster ~]# helm version
Client: &version.Version{SemVer:"v2.14.0", GitCommit:"05811b84a3f93603dd6c2fcfe57944dfa7ab7fd0", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.14.0", GitCommit:"05811b84a3f93603dd6c2fcfe57944dfa7ab7fd0", GitTreeState:"clean"}

關於使用:
參考官方 快速使用 https://helm.sh/docs/using_helm/#quickstart-guide

參考:
https://www.kubernetes.org.cn/3435.html
https://blog.frognew.com/2018/10/ingress-edge-node-ha-in-bare-metal-k8s-with-ipvs.html


免責聲明!

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



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