# 主要的坑就是下载不了gcr.io/kubernetes-helm/tiller:v2.14.1,解决思路:生成初始化文件yaml,修改image名称
# 可以到docker hub上搜索对应版本的,比如heleicool/tiller:v2.14.1,搜索时用heleicool/tiller
# 下载镜像
docker pull heleicool/tiller:v2.14.1
# 安装helm
wget https://get.helm.sh/helm-v2.14.1-linux-amd64.tar.gz
tar -zxvf helm-v2.14.1-linux-amd64.tar.gz
cp linux-amd64/helm /usr/local/bin/helm
# 创建RBAC访问控制文件
cat > helm-rbac.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 create -f helm-rbac.yaml
# 初始化到文件,修改镜像文件,修改apiVersion
helm init --output yaml > tiller.yaml
sed -i 's/gcr.io\/kubernetes-helm\/tiller:v2.14.1/heleicool\/tiller:v2.14.1/' tiller.yaml
sed -i 's@apiVersion: extensions/v1beta1@apiVersion: apps/v1@' tiller.yaml
# 给Deployment增加selector段和serviceAccount
vim tiller.yaml
---
tiller-deploy的Deployment增加内容:
spec:
selector:
matchLabels:
app: helm
name: tiller
template:
spec:
serviceAccount: tiller
----------------------------------------
# 安装和部署
helm init
kubectl apply -f tiller.yaml
kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
# 检查app是否正常运行
kubectl get pod -n kube-system -l app=helm
kubectl get pods -n kube-system
kubectl get pods -n kube-system -o wide
kubectl describe pod tiller-deploy-54c745c98f-45b5c -n kube-system
# 更换仓库
# 先移除原先的仓库
helm repo remove stable
# 添加新的仓库地址
helm repo add stable http://mirror.azure.cn/kubernetes/charts/
# 更新仓库
helm repo update
# 查看仓库源
helm repo list
# 查询仓库
helm search
--------------------------------------其他工具命令--------------------------------
# 编辑配置文件
kubectl edit deployment tiller-deploy -n kube-system
# 拉取镜像
docker pull heleicool/tiller:v2.14.1
docker tag heleicool/tiller:v2.14.1 gcr.io/kubernetes-helm/tiller:v2.14.1
docker rmi heleicool/tiller:v2.14.1
# 删除失败的pod
kubectl delete deployment tiller-deploy -n kube-system
# 检查app是否正常运行
kubectl get pods -n kube-system