helm安装和使用

Helm是一个kubernetes应用的包管理工具,用来管理charts——预先配置好的安装包资源,有点类似于Ubuntu的APT和CentOS中的yum。

安装依赖

1
yum -y install socat

所有节点都安装

下载所需文件

  • 下载helm包
1
wget https://storage.googleapis.com/kubernetes-helm/helm-v2.13.1-linux-amd64.tar.gz

如果你没有科学上网可能无法下载,可通过下面的方法下载

1
2
3
wget https://source-82722.oss-cn-beijing.aliyuncs.com/helm/helm-v2.13.1-linux-amd64.tar.gz
tar zxf helm-v2.13.1-linux-amd64.tar.gz
mv linux-amd64 /usr/local/bin/helm
  • 下载tiller镜像

如果你使用了科学上网可忽略该步骤,一位大牛提供了针对国外镜像的下载,有兴趣的可以看下https://github.com/zhangguanzhang/gcr.io

1
2
3
4
5
6
7
8
curl -s https://zhangguanzhang.github.io/bash/pull.sh | bash -s -- gcr.io/kubernetes-helm/tiller:v2.13.1
v2.13.1: Pulling from zhangguanzhang/gcr.io.kubernetes-helm.tiller
5d20c808ce19: Pull complete
43339c468bb6: Pull complete
d6d696e230df: Pull complete
9cf2c942cf64: Pull complete
Digest: sha256:d52b34a9f9aeec1cf74155ca51fcbb5d872a705914565c782be4531790a4ee0e
`

初始化helm

1
helm init

验证

tiller运行正常

1
2
3
kubectl -n kube-system get pod -l app=helm
NAME READY STATUS RESTARTS AGE
tiller-deploy-c48485567-shwp5 1/1 Running 0 50m
1
2
3
helm version
Client: &version.Version{SemVer:"v2.13.1", GitCommit:"618447cbf203d147601b4b9bd7f8c37a5d39fbb4", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.13.1", GitCommit:"618447cbf203d147601b4b9bd7f8c37a5d39fbb4", GitTreeState:"clean"}

修改repo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
$ helm repo list
NAME URL
stable https://kubernetes-charts.storage.googleapis.com
local http://127.0.0.1:8879/charts
$ helm repo remove stable
"stable" has been removed from your repositories
$ helm repo add stable https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
"stable" has been added to your repositories
$ helm repo update
Hang tight while we grab the latest from your chart repositories...
...Skip local chart repository
...Successfully got an update from the "stable" chart repository
Update Complete. ⎈ Happy Helming!⎈
$ helm repo list
NAME URL
local http://127.0.0.1:8879/charts
stable https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts

创建rabc

1
2
3
4
5
kubectl create serviceaccount --namespace=kube-system tiller
kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
kubectl patch deploy --namespace=kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}'

部署mysql

1
2
3
4
helm install stable/mysql
kubectl get pod
NAME READY STATUS RESTARTS AGE
dull-snail-mysql-5d4b968dff-w57l5 1/1 Running 0 96s

当前网速较慢或者你使用的浏览器不支持博客特定功能,请尝试刷新或换用Chrome、Firefox等现代浏览器