一、首先,我是看尚硅谷視頻跟着操作出現了問題,視頻鏈接:https://www.bilibili.com/video/av66617940/?p=58
再說下大概的部署流程
Helm 部署
Helm 包含兩個組件:Helm 客戶端和 Tiller 服務器,如下圖所示
Helm 客戶端負責 chart 和 release 的創建和管理以及和 Tiller 的交互。Tiller 服務器運行在 Kubernetes 集群中,它會處理 Helm 客戶端的請求,與 Kubernetes API Server 交互
流程
1、客戶端(Helm Client)和服務器端(Tiller)通過gRPC協議進行調用
2、我們在客戶端(Helm Client)傳遞對應的指令,服務器端(Tiller)接收到數據后會把數據理解成對應的命令,然后和KubeAPI進行交互
3、KubeAPI接收到指令會生成對應的數據或資源
4、這些生成的數據或資源會被寫入到etcd,kubernetes接受后進行創建
所以helm部署會分為兩個部分部署:
1、客戶端(Helm Client)部署
2、服務器端(Tiller)的部署
服務器端(Tiller)如圖是部署到K8S集群的,所以以下就是服務器端(Tiller)的部署安裝
二、安裝步驟,這些聰明的你肯定一看就懂,不多贅述了
wget https://storage.googleapis.com/kubernetes-helm/helm-v2.13.1-linux-amd64.tar.gz tar -zxvf helm-v2.13.1-linux-amd64.tar.gz cd linux-amd64/ cp helm /usr/local/bin/
為了安裝服務端 tiller,還需要在這台機器上配置好 kubectl 工具和 kubeconfig 文件,確保 kubectl 工具可以在這台機器上訪問 apiserver 且正常使用。這里的 node1 節點以及配置好了 kubectl
因為 Kubernetes APIServer 開啟了 RBAC 訪問控制,所以需要創建 tiller 使用的
service account(SA): tiller 並分配合適的角色給它。詳細內容可以查看helm文檔中的Role-based Access Control(https://helm.sh/docs/using_helm/#role-based-access-control)。這里簡單起見直接分配cluster- admin 這個集群內置的 ClusterRole 給它。創建 rbac-config.yaml 文件:
#創建SA 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
#創建rbac.yaml
kubectl create -f rbac-config.yaml
#tiller的k8s集群的部署
helm init --service-account tiller --skip-refresh
視頻里邊的成功Running了,我的就炸了。所以,正文開始!!!
三、自己安裝時出現的問題
kubectl get pods -n kube-system
查看詳細信息
kubectl describe pods tiller-deploy-58565b5464-jcv8w -n kube-system
出現了這些問題
Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 91s default-scheduler Successfully assigned kube-system/tiller-deploy-58565b5464-jcv8w to liu-node01 Normal Pulling 51s (x2 over 84s) kubelet, liu-node01 Pulling image "gcr.io/kubernetes-helm/tiller:v2.13.1" Warning Failed 21s (x2 over 64s) kubelet, liu-node01 Failed to pull image "gcr.io/kubernetes-helm/tiller:v2.13.1": rpc error: code = Unknown desc = Error response from daemon: Get https://gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers) Warning Failed 21s (x2 over 64s) kubelet, liu-node01 Error: ErrImagePull Normal BackOff 6s (x2 over 63s) kubelet, liu-node01 Back-off pulling image "gcr.io/kubernetes-helm/tiller:v2.13.1" Warning Failed 6s (x2 over 63s) kubelet, liu-node01 Error: ImagePullBackOff
根據問題描述,我先修改了自己的apiVersion,修改到自己環境對應的版本
利用kubectl explain ClusterRoleBinding查看
修改后還是有問題,不過問題變了,不是拉取錯誤,是拉取失敗
再次查看:kubectl describe pods tiller-deploy-58565b5464-jcv8w -n kube-system,可以發現是鏡像出現了問題
Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 5m44s default-scheduler Successfully assigned kube-system/tiller-deploy-58565b5464-jcv8w to liu-node01 Normal Pulling 2m57s (x4 over 5m37s) kubelet, liu-node01 Pulling image "gcr.io/kubernetes-helm/tiller:v2.13.1" Warning Failed 2m37s (x4 over 5m17s) kubelet, liu-node01 Failed to pull image "gcr.io/kubernetes-helm/tiller:v2.13.1": rpc error: code = Unknown desc = Error response from daemon: Get https://gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers) Warning Failed 2m37s (x4 over 5m17s) kubelet, liu-node01 Error: ErrImagePull Warning Failed 2m10s (x7 over 5m16s) kubelet, liu-node01 Error: ImagePullBackOff Normal BackOff 31s (x13 over 5m16s) kubelet, liu-node01 Back-off pulling image "gcr.io/kubernetes-helm/tiller:v2.13.1"
既然說我拉取的鏡像有問題,所以我先去docker.hub上查了下,發現沒有找到對應的鏡像,所以要自己修改鏡像,先直接搜索,看有那些鏡像可以使用
然后去docker.hub官網找
拉取過程中,最新版本我沒拉取成功,嘗試了幾個其他的才成功。拉取成功后,更改tag
docker tag sapcc/tiller:v2.15.2 gcr.io/kubernetes-helm/tiller:v2.13.1
再查看,發現還是沒Running,說明鏡像沒有被使用,編輯配置文件,查看拉取策略
kubectl edit deployment tiller-deploy -n kube-system
最后查看,已經Running
部署完成了,然后再后邊看也看到類似的解決辦法,文章鏈接:
https://www.jianshu.com/p/d0cdbb49569b
早看到他的也不用自己折騰半天了哈哈!!