目次
「kubeadm を使用して Kubernetes 1.15 をインストールする」原文
問題 2: ポッドのステータス: ImagePullBackOff
「kubeadm を使用して Kubernetes 1.15 をインストールする」原文
ヘルムの取り付け
Helm は、クライアント側の Helm コマンド ライン ツールとサーバー側の Tiller で構成されており、Helm のインストールは非常に簡単です。Helm コマンドライン ツールをマスター ノード node1 の /usr/local/bin にダウンロードします。バージョン 2.14.1 はここからダウンロードします。
curl -O https://get.helm.sh/helm-v2.14.1-linux-amd64.tar.gz
tar -zxvf helm-v2.14.1-linux-amd64.tar.gz
cd linux-amd64/
cp helm /usr/local/bin/
サーバーティラーをインストールするには、kubectl ツールと kubeconfig ファイルをこのマシンに設定して、kubectl ツールがこのマシン上の apiserver にアクセスして通常に使用できるようにする必要もあります。ここのnode1ノードはkubectlで構成されています。
Kubernetes APIServer では RBAC アクセス制御が有効になっているため、tiler:tiler で使用されるサービス アカウントを作成し、それに適切なロールを割り当てる必要があります。詳細については、 helm ドキュメントの「ロールベースのアクセス制御」を参照してください。簡単にするために、cluster-admin の組み込み ClusterRole を直接割り当てます。Helm-rbac.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 helm-rbac.yaml
serviceaccount/tiller created
clusterrolebinding.rbac.authorization.k8s.io/tiller created
次に、helm を使用してティラーをデプロイします。
helm init --service-account tiller --skip-refresh
Creating /root/.helm
Creating /root/.helm/repository
Creating /root/.helm/repository/cache
Creating /root/.helm/repository/local
Creating /root/.helm/plugins
Creating /root/.helm/starters
Creating /root/.helm/cache/archive
Creating /root/.helm/repository/repositories.yaml
Adding stable repo with URL: https://kubernetes-charts.storage.googleapis.com
Adding local repo with URL: http://127.0.0.1:8879/charts
$HELM_HOME has been configured at /root/.helm.
Tiller (the Helm server-side component) has been installed into your Kubernetes Cluster.
Please note: by default, Tiller is deployed with an insecure 'allow unauthenticated users' policy.
To prevent this, run `helm init` with the --tiller-tls-verify flag.
For more information on securing your installation see: https://docs.helm.sh/using_helm/#securing-your-helm-installation
Happy Helming!
问题1:要求されたリソースが見つかりません
# helm init --service-accounttiler --skip-refresh
エラー:
エラー: インストール中にエラーが発生しました: サーバーは要求されたリソースを見つけることができませんでした
----サーバーは要求されたリソースを見つけることができません
一連の記事を検索した結果、最終的に次の解決策を提供する「Kubernetes ガイド」を見つけました。
Error: error installing: the server could not find the requested resource
Kubernetes v1.16.0 より上のバージョンでは、エラーが発生する可能性があります 。extensions/v1beta1
これは置き換えられる ためです apps/v1
。回避策は次のとおりです。
kubectl create serviceaccount --namespace kube-system tiller
kubectl create clusterrolebinding tiller --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
helm init --service-account tiller --override spec.selector.matchLabels.'name'='tiller',spec.selector.matchLabels.'app'='helm' --output yaml | sed 's@apiVersion: extensions/v1beta1@apiVersion: apps/v1@' | kubectl apply -f -
チャートのリストを更新します。
helm repo update
結果はOKです:
問題 2: ポッドの ステータス: ImagePullBackOff
見つかったステータスの表示 STATUS: ImagePullBackOff
# tiller默认被部署在k8s集群中的 kube-system 这个namespace下
# kubectl get pods -n kube-system
ポッドイベントの表示
# kubectl 説明ポッド ティラーデプロイ-cf88b7d9-zlb7s -n kube-system
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 11m default-scheduler Successfully assigned kube-system/tiller-deploy-cf88b7d9-zlbe2
Normal Pulling 8m44s (x4 over 11m) kubelet, node2 Pulling image "gcr.io/kubernetes-helm/tiller:v2.14.1"
Warning Failed 8m29s (x4 over 10m) kubelet, node2 Failed to pull image "gcr.io/kubernetes-helm/tiller:v2.14.1"or: code = Unknown desc = Error response from daemon: Get https://gcr.io/v2/: net/http: request canceled while waiting foron (Client.Timeout exceeded while awaiting headers)
Warning Failed 8m29s (x4 over 10m) kubelet, node2 Error: ErrImagePull
Normal BackOff 8m15s (x6 over 10m) kubelet, node2 Back-off pulling image "gcr.io/kubernetes-helm/tiller:v2.14.
Warning Failed 54s (x35 over 10m) kubelet, node2 Error: ImagePullBackOff
明らかに、 gcr.io/kubernetes- helm/tiller:v2.14 イメージの取得に失敗しました。
手動でイメージを取得する必要がある
1. 利用可能な画像を表示する
[root@node1 linux-amd64]# docker search tiller
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
jessestuart/tiller Nightly multi-architecture (amd64, arm64, ar… 19 [OK]
sapcc/tiller Mirror of https://gcr.io/kubernetes-helm/til… 9
ist0ne/tiller https://gcr.io/kubernetes-helm/tiller 3 [OK]
rancher/tiller 2
jmgao1983/tiller from gcr.io/kubernetes-helm/tiller 2 [OK]
ibmcom/tiller Docker Image for IBM Cloud private-CE (Commu… 1
luxas/tiller 1
itinerisltd/tiller [Deprecated] Use https://circleci.com/orbs/r… 1
ansibleplaybookbundle/tiller-apb An APB that deploys tiller for use with helm. 1 [OK]
cfplatformeng/tiller-ubuntu 0
私が選択したのは、sapcc/tiller https://gcr.io/kubernetes-helm/til… のミラーです。
2. dockerhub に移動して確認します。
3. 画像をダウンロードします。
docker pull sapcc/tiller:v2.16.3
ローカルミラーを表示する
[root@node1 linux-amd64]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
sapcc/tiller v2.16.3 6a79bebf87f5 7 days ago 91.2MB
...
4. 設定ファイルを編集する
# kubectl edit deployment tiller-deploy -n kube-system
...
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:改成手动下载的镜像的 NAME:TAG
image: sapcc/tiller:v2.16.3
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 3
httpGet:
path: /liveness
port: 44135
scheme: HTTP
initialDelaySeconds: 1
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
name: tiller
...
別の方法は
イメージ プル戦略を見つけて、次の変更を加えます。
imagePullPolicy:
Never
IfNotPresent :如果本地存在镜像就优先使用本地镜像。 Never:直接不再去拉取镜像了,使用本地的;如果本地不存在就报异常了
5. 次に、チャートリストを更新します。
helm repo update
7. ポッドのステータスを確認します。実行中です。
[root@node1 linux-amd64]# kubectl get pod -n kube-system -l app=helm
NAME READY STATUS RESTARTS AGE
tiller-deploy-655f8745d9-zgkwc 1/1 Running 0 98m
参考:
https://feisky.gitbooks.io/kubernetes/content/apps/helm.html