helm的安裝參考:
https://www.kubernetes.org.cn/4619.html
Helm由客戶端命helm令行工具和服務(wù)端tiller組成搪桂,Helm的安裝十分簡(jiǎn)單谅猾。 下載helm命令行工具到master節(jié)點(diǎn)node1的/usr/local/bin下悬荣,這里下載的2.9.1版本:
wget https://storage.googleapis.com/kubernetes-helm/helm-v2.11.0-linux-amd64.tar.gz
tar -zxvf helm-v2.11.0-linux-amd64.tar.gz
cd linux-amd64/
cp helm /usr/local/bin/
為了安裝服務(wù)端tiller,還需要在這臺(tái)機(jī)器上配置好kubectl工具和kubeconfig文件秉宿,確保kubectl工具可以在這臺(tái)機(jī)器上訪問apiserver且正常使用戒突。 這里的node1節(jié)點(diǎn)以及配置好了kubectl。
因?yàn)镵ubernetes APIServer開啟了RBAC訪問控制描睦,所以需要?jiǎng)?chuàng)建tiller使用的service account: tiller并分配合適的角色給它膊存。 詳細(xì)內(nèi)容可以查看helm文檔中的Role-based Access Control。 這里簡(jiǎn)單起見直接分配cluster-admin這個(gè)集群內(nèi)置的ClusterRole給它。創(chuàng)建rbac-config.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
kubectl create -f rbac-config.yaml
serviceaccount/tiller created
clusterrolebinding.rbac.authorization.k8s.io/tiller created
安裝tiller
helm init --service-account tiller --skip-refresh
問題
到這一步就出現(xiàn)問題了隔崎,跟之前參考的博主寫的不一樣了今艺。因?yàn)槲沂褂玫氖菄?guó)內(nèi)的docker源,所以gcr.io/kubernetes-helm/tiller這個(gè)鏡像訪問不到爵卒,所以查看pod的時(shí)候
kubectl get pods -n kube-system
顯示:
NAME READY STATUS RESTARTS AGE
tiller-deploy-6f6fd74b68-rkk5w 0/1 ImagePullBackOff 0 14h
pod的狀態(tài)不對(duì)啊虚缎。作為剛?cè)腴T的小白,開始摸索解決
解決思路
1钓株、查看pod的事件
kubectl describe pod tiller-deploy-6f6fd74b68-rkk5w -n kube-system
顯示
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning Failed 52m (x3472 over 14h) kubelet, test1 Error: ImagePullBackOff
Normal BackOff 2m6s (x3686 over 14h) kubelet, test1 Back-off pulling image "gcr.io/kubernetes-helm/tiller:v2.11.0"
顯然是獲取gcr.io/kubernetes-helm/tiller:v2.11.0鏡像失敗
2实牡、手動(dòng)拉取鏡像
docker search kubernetes-helm/tiller
cockpit/kubernetes This container provides a version of cockpit… 41 [OK]
fluent/fluentd-kubernetes-daemonset Fluentd Daemonset for Kubernetes 24 [OK]
lachlanevenson/k8s-helm Helm client (https://github.com/kubernetes/h… 17
dtzar/helm-kubectl helm and kubectl running on top of alpline w… 16 [OK]
jessestuart/tiller Nightly multi-architecture (amd64, arm64, ar… 4 [OK]
hypnoglow/kubernetes-helm Image providing kubernetes kubectl and helm … 3 [OK]
linkyard/docker-helm Docker image containing kubernetes helm and … 3 [OK]
jimmysong/kubernetes-helm-tiller 2
ibmcom/tiller Docker Image for IBM Cloud private-CE (Commu… 1
zhaosijun/kubernetes-helm-tiller mirror from gcr.io/kubernetes-helm/tiller:v2… 1 [OK]
zlabjp/kubernetes-resource A Concourse resource for controlling the Kub… 1
thebeefcake/concourse-helm-resource concourse resource for managing helm deploym… 1 [OK]
timotto/rpi-tiller k8s.io/tiller for Raspberry Pi 1
fishead/gcr.io.kubernetes-helm.tiller mirror of gcr.io/kubernetes-helm/tiller 1 [OK]
victoru/concourse-helm-resource concourse resource for managing helm deploym… 0 [OK]
bitnami/helm-crd-controller Kubernetes controller for HelmRelease CRD 0 [OK]
z772458549/kubernetes-helm-tiller kubernetes-helm-tiller 0 [OK]
mnsplatform/concourse-helm-resource Concourse resource for helm deployments 0
croesus/kubernetes-helm-tiller kubernetes-helm-tiller 0 [OK]
這么多鏡像,看描述轴合,我看中了
fishead/gcr.io.kubernetes-helm.tiller mirror of gcr.io/kubernetes-helm/tiller 1 [OK]
意思是fishead/gcr.io.kubernetes-helm.tiller 這個(gè)鏡像是 根據(jù)
mirror of gcr.io/kubernetes-helm/tiller Build而成
接下來去dockerhub上確認(rèn)下
果然是我們需要的鏡像创坞,然后查看版本:
下載鏡像:
docker pull fishead/gcr.io.kubernetes-helm.tiller:v2.11.0
改tag
docker tag fishead/gcr.io.kubernetes-helm.tiller:v2.11.0 gcr.io/kubernetes-helm/tiller:v2.11.0
查看本地鏡像
3、重新部署
萌新這步折騰了很久受葛,參考網(wǎng)上方法题涨,有試過
刪除tiller
helm reset -f
初始化,重新部署tiller
helm init --service-account tiller --tiller-image gcr.io/kubernetes-helm/tiller:v2.11.0 --skip-refresh
查看pod总滩,還是錯(cuò)誤的狀態(tài)
kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
tiller-deploy-6f6fd74b68-qvlzx 0/1 ImagePullBackOff 0 8m43s
啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊纲堵,崩潰了。為什么還是顯示拉取鏡像失敗呢闰渔。(席函;′⌒`)
冷靜下來想想,是不是配置文件中寫了總是獲取倉(cāng)庫(kù)鏡像呢
編輯下配置文件
kubectl edit deployment tiller-deploy -n kube-system
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "2"
creationTimestamp: 2018-11-16T08:03:53Z
generation: 2
labels:
app: helm
name: tiller
name: tiller-deploy
namespace: kube-system
resourceVersion: "133136"
selfLink: /apis/extensions/v1beta1/namespaces/kube-system/deployments/tiller-deploy
uid: 291c2a71-e976-11e8-b6eb-8cec4b591b6a
spec:
progressDeadlineSeconds: 2147483647
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: helm
name: tiller
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
app: helm
name: tiller
spec:
automountServiceAccountToken: true
containers:
- env:
- name: TILLER_NAMESPACE
value: kube-system
- name: TILLER_HISTORY_MAX
value: "0"
image: gcr.io/kubernetes-helm/tiller:v2.11.0
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 3
httpGet:
path: /liveness
port: 44135
scheme: HTTP
initialDelaySeconds: 1
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
name: tiller
ports:
- containerPort: 44134
name: tiller
protocol: TCP
- containerPort: 44135
果然找到了鏡像拉取策略:
imagePullPolicy: IfNotPresent
看看官網(wǎng)怎么說的
https://kubernetes.io/docs/concepts/containers/images/
By default, the kubelet will try to pull each image from the specified registry. However, if the imagePullPolicy property of the container is set to IfNotPresent or Never, then a local image is used (preferentially or exclusively, respectively).
#默認(rèn)情況是會(huì)根據(jù)配置文件中的鏡像地址去拉取鏡像澜建,如果設(shè)置為IfNotPresent 和Never就會(huì)使用本地鏡像。
IfNotPresent :如果本地存在鏡像就優(yōu)先使用本地鏡像蝌以。
Never:直接不再去拉取鏡像了炕舵,使用本地的;如果本地不存在就報(bào)異常了
按道理來說跟畅,我這個(gè)配置沒問題啊咽筋,為什么不先檢索本地的鏡像呢,難道是我后來下載的原因徊件。不管了奸攻,我先改成never
imagePullPolicy:Never
保存下,查看pod狀態(tài)
tiller-deploy-f844bd879-p6m8x 1/1 Running 0 62s
終于好了虱痕,開心
(????)??