5
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【GKE】 kubectl top pod で Metrics not available のエラーが出た時の解決法

Posted at

はじめに

kubectl top pod でCPUリソースを確認することがあるかとは思います。
その時にエラーが起きたので、備忘録として残してます。

事象

下記のようにコマンドを打つとエラーが出ました。

$ kubectl top pod
W0130 09:00:54.156097    5615 top_pod.go:192]
Metrics not available for pod hoge, age: XXhXXmXX.XXs
error: Metrics not available for pod huga, age: XXhXXmXX.XXs

解決策

バージョンを確認すると

$ kubectl version -o json
{
  "clientVersion": {
    "major": "1",
    "minor": "9",
    "gitVersion": "v1.9.7",
    "gitCommit": "dd5e1a2978fd0b97d9b78e1564398aeea7e7fe92",
    "gitTreeState": "clean",
    "buildDate": "2018-04-19T00:05:56Z",
    "goVersion": "go1.9.3",
    "compiler": "gc",
    "platform": "darwin/amd64"
  },
  "serverVersion": {
    "major": "1",
    "minor": "12+",
    "gitVersion": "v1.12.10-gke.17",
    "gitCommit": "27b48e2b4c9535d185ec945c6a513537e4d116cf",
    "gitTreeState": "clean",
    "buildDate": "2019-10-21T20:10:26Z",
    "goVersion": "go1.12.11b4",
    "compiler": "gc",
    "platform": "linux/amd64"
  }
}

バージョンが異なっているので、エラーが起きていると思い、
バージョンを合わせてみました。

$ curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.12.10/bin/darwin/amd64/kubectl
$ chmod +x ./kubectl
$ sudo mv ./kubectl $(which kubectl)

これで、もう一度 kubectl top pod を打ってみます。

NAME                         CPU(cores)   MEMORY(bytes)
hoge1                        2m           755Mi
huga1                        0m           0Mi
hoge2                        1m           229Mi
huga2                        1m           28Mi
hoge3                        2m           1Mi

うまくいきました!

最後に

最後に、弊社の宣伝をさせていただければ、と思います!
現在弊社では、HRモンスターと呼ばれる
採用の新しいスタイルを提供するサービスをローンチいたしました。

ローンチ後のさらなる機能追加、改善などのPDCAサイクルを回すべく、
エンジニアを募集しております。
https://www.wantedly.com/projects/406086

Kubernetes、Vue.js(Javascript)、Django(Python)といったモダンな技術を使って、
開発しておりますので、もしご興味がある方はぜひ、ご応募お待ちしております。

5
0
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
5
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?