注意
helm 使用需要 kubectl, 点击了解安装和配置.
Helm 是 Kubernetes 首选的包管理工具. Helmcharts 为 Kubernetes YAML 清单文档提供模板语法. 使用 Helm, 我们可以创建可配置的部署, 而不仅仅是使用静态文件. 有关创建自己的 charts 的更多信息, 请查看 https://helm.sh/ https://helm.sh/ 文档. Helm 有两个部分: Helm 客户端 (helm) 和 Helm 服务端(Tiller).
1. 配置 Helm 客户端访问权限
Helm 在集群上安装 tiller 服务以管理 charts. 由于 RKE 默认启用 RBAC, 因此我们需要使用 kubectl 来创建一个 serviceaccount,clusterrolebinding 才能让 tiller 具有部署到集群的权限.
在 kube-system 命名空间中创建 ServiceAccount;
创建 ClusterRoleBinding 以授予 tiller 帐户对集群的访问权限
helm 初始化 tiller 服务
- kubectl -n kube-system create serviceaccount tiller
- kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller
2. 安装 Helm 客户端
采用二进制安装
可以在 helm 官网上下载 Helm https://github.com/helm/helm/releases , 如果速度不理想可以使用 rancher 自带加速下载 Helm
- wget https://www.cnrancher.com/download/helm/helm-v2.14.1-linux-amd64.tar.gz
- tar xf helm-v2.14.1-Linux-amd64.tar.gz
helm 在解压后的目录中找到二进制文件, 并将其移动到所需的位置
sudo mv Linux-amd64/helm /usr/local/bin/helm && chmod +x /usr/local/bin/helm
3. 安装 Helm Server(Tiller)
Helm 的服务器端部分 Tiller, 通常运行在 Kubernetes 集群内部. 但是对于开发, 它也可以在本地运行, 并配置为与远程 Kubernetes 集群通信.
安装 tiller 到集群中最简单的方法就是运行 helm init. 这将验证 helm 本地环境设置是否正确(并在必要时进行设置). 然后它会连接到 kubectl 默认连接的 K8S 集群(kubectl config view). 一旦连接, 它将安装 tiller 到 kube-system 命名空间中.
helm init 自定义参数:
--canary-image 参数安装金丝雀版本;
--tiller-image 安装特定的镜像(版本);
--kube-context 使用安装到特定集群;
--tiller-namespace 用一个特定的命名空间 (namespace) 安装;
注意:
1,RKE 默认启用 RBAC, 所以在安装 tiller 时需要指定 ServiceAccount.
2,helm init 在缺省配置下, 会去谷歌镜像仓库拉取 gcr.io/kubernetes-helm/tiller 镜像, 在 Kubernetes 集群上安装配置 Tiller; 由于在国内可能无法访问 gcr.io,storage.googleapis.com 等域名, 可以通过 --tiller-image 指定私有镜像仓库镜像.
3,helm init 在缺省配置下, 会利用 https://kubernetes-charts.storage.googleapis.com 作为缺省的 stable repository 地址, 并去更新相关索引文件. 在国内可能无法访问 storage.googleapis.com 地址, 可以通过 --stable-repo-url 指定 chart 国内加速镜像地址.
4, 如果您是离线安装 Tiller, 假如没有内部的 chart 仓库, 可通过添加 --skip-refresh 参数禁止 Tiller 更新索引.
在 rancher 中安装 Tiller
- [email protected]:~$ helm init --service-account tiller --skip-refresh> --tiller-image registry.cn-shanghai.aliyuncs.com/rancher/tiller:v2.14.1
- Creating /home/wangpeng/.helm
- Creating /home/wangpeng/.helm/repository
- Creating /home/wangpeng/.helm/repository/cache
- Creating /home/wangpeng/.helm/repository/local
- Creating /home/wangpeng/.helm/plugins
- Creating /home/wangpeng/.helm/starters
- Creating /home/wangpeng/.helm/cache/archive
- Creating /home/wangpeng/.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 /home/wangpeng/.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 情况
- [email protected]:~$ helm version
- Client: &version.Version{
- SemVer:"v2.14.1", GitCommit:"5270352a09c7e8b6e8c9593002a73535276507c0", GitTreeState:"clean"
- }
- Server: &version.Version{
- SemVer:"v2.14.1", GitCommit:"5270352a09c7e8b6e8c9593002a73535276507c0", GitTreeState:"clean"
- }
来源: http://www.bubuko.com/infodetail-3104229.html