LoginSignup
8
4

More than 3 years have passed since last update.

Rancher 運用 トラブルまとめ

Last updated at Posted at 2020-03-02

Rancherを本格的に使い始めることで遭遇したトラブルと対応まとめ
v2.3.5

[1] Failed to obtain metrics. The metrics service may not be available. undefined

小規模運用ではでなかったが、Node数、Pod数を拡張した際に、
Rancherサーバのモニタリング機能が使えなくなり、上記エラーが発生

Rancher Dashboardには下記エラーも出力

Monitoring API is not ready

Prometheusのモニタリング機能利用では、クラスタ規模に応じて
リソース割り当てを考慮する必要があるらしい

下記を参考に、Tools-Monitoringの設定で、CPU/Memoryの割り当てを拡張することで問題解消

[2] Can not find RKE state file

k8sクラスタ構築で「Can not find RKE state file」という謎のエラー。
hostname変更で解決(rancherバグ?)。

[3] Cluster must have at least one etcd plane host: failed to connect to XXX

クラスタ作成時に上記のエラー。
ホスト上で稼働中の「rancher/rancher-agent:v2.3.5」のログを確認すると下記エラーが。

Error esponse from daemon: client is newer than servier (client API version: 1.24, server API version: 1.22)

ホストのdockerのバージョンを更新したところ解消

[4] Path /var/lib/rancher is mounted on / but it is not a shared mount

クラスタ作成時に上記のエラー。
dockerのマウント設定に起因。
下記確認し、MountFlags=slave を MountFlags=shared に変更してdocker再起動すれば解消。

$ sudo systemctl cat docker.service
...
# /etc/systemd/system/docker.service.d/mount_flags.conf 
[Service] 
MountFlags=slave
...

参考)
https://success.docker.com/article/not-a-shared-mount-error

/etc/systemd/system/docker.service.d/mount_flags.conf

が見当たらないときは

/usr/lib/systemd/system/docker.service

にて編集

[5] Etcd Cluster is not healthy

クラスタ構築を何度か試したところ、以下のエラーが発生

[etcd] Failed to bring up Etcd Plane: [etcd] Etcd Cluster is not healthy

どうやらゴミをちゃんと掃除しないといけないらしい。
下記サイトの「Cleaning a Node Manually」の手順を実行し、再度クラスタ作成をしたところエラーは解消。

[6] kubelet failed to start

クラスタ構築時のWorkerノード追加で、kubelet Podがrestartを繰り返し、起動しない状態。
docker logsでコンテナのログを見ると、docker API versionが古いことが原因。

ホストサーバのdocker API versionが v1.26以上である必要があるらしく
docker 1.13 以上にアップデートすることで解消。

[7] Failed to update Node Allocatable Limits

一見クラスタは正常に構築できた風だが、Eventログで下記Warningが

Failed to update Node Allocatable Limits
["kubepods"] failed to set supported cgroup subsystems for cgroup [kubepods]
failed to find subsystem mount for required subsystem pids

k8s v1.14 から導入された Pid Limiting機能で、
cgrupsのpidsサブシステム(Process Number Controller)を利用するが、
それがないことが原因らしい

Pid Limitingとは
Pid リソースを Pod-Pod 間および Node-Pod 間で隔離することで
Pid リソースの枯渇を防ぐための機能。
k8s v1.13でアルファ提供、v1.14からベータでデフォルトenableになった機能。

pidがあるかは cat /proc/cgroups でsubsys_name一覧で確認できる。

さらに、pidsはカーネル4.3から導入されたとのこと。
カーネルバージョンは uname -rで確認できる

対処法

①カーネルバージョンを4.3以上にUPして、cgroups pidsサポート環境にする

もしそれができない状況なら
②Kubernetesのfeature-gatesで下記機能をOFFにする

・SupportPodPidsLimit
・SupportNodePidsLimit

Rancherにおけるfeature-gatesの設定変更の方法が不明でしたが、
下記リンクを参考に実施したら、一応Warningは発生しなくなった

具体的には、Rancherコンソールで該当クラスタの設定「View in API」から
「Edit」で下部にある「RancherKubernetesEngineConf」のkubeletの設定を
以下のように更新してSend Requestする。

:
"kubelet": {
    "failSwapOn": false,
    "generateServingCertificate": false,
    "type": "/v3/schemas/kubeletService",
    "extraArgs": { "feature-gates": "SupportPodPidsLimit=false,  
                    SuppotNodePidsLimit=false" 
                  }
}
:

200OKレスポンス後にクラスタがアップデートされ
Eventsにて
NodeAllocatableEnforced:Updated Node Allocatable limit across pods
という感じで表示され、Warningが消えた。

参考)

https://github.com/grugrut/til/blob/master/draft/blog.org
https://gihyo.jp/admin/serial/01/linux_containers/0030

8
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
4