在腾讯云 TKE 上使用 Helm 的几个小坑

首先,大家都懂,gcr.io 是连不上的,需要使用阿里云镜像或别的镜像

helm init --upgrade -i registry.cn-hangzhou.aliyuncs.com/google_containers/tiller:v2.13.0 --stable-repo-url https://kubernetes.oss-cn-hangzhou.aliyuncs.com/chart --service-account tiller

如果没注意已经部署了,可以先删除:

kubectl delete deployment tiller-deploy --namespace=kube-system

然后,helm install 可能会报没有权限:

Error: release xxx failed: namespaces "default" is forbidden: User "system:serviceaccount:kube-system:default" cannot get namespaces in the namespace "default"

这时候需要新建账户处理权限问题

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"}}}}'

注意这里给的权限比较高,高级玩家可以用 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

然后来说说 Volumes 挂载

这个地方在控制台是没有直接入口的,需要通过修订 YAML 实现。有两种方式,一是通过控制台直接编辑 YAML,二是用 kubectl 自行 patch。注意这里修改的是 deployment 的 YAML

我这里使用 NFS 的方式,需要添加的段是:

spec:
  template:
    spec:
      volumes:
      - name: data
        nfs:
          path: /
          server: 10.0.x.x

最后关于访问方式,在 Service 面板,腾讯云提供了更新访问操作的入口,从这里直接修改就可以。

参考文章:

http://lizhe.name/node/357

https://www.jianshu.com/p/53bbf1f86b8a

https://ezmo.me/2017/09/24/helm-quick-toturial/

CC BY-NC-SA 4.0 在腾讯云 TKE 上使用 Helm 的几个小坑 by 桔子小窝 is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

发表回复

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据