0
1

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.

手元のKubernetesマニフェストと本番のマニフェストが乖離したとき(バージョン1.12以下の場合)

Posted at

昔困ったので記録しておく。

Kubernetes masterのバージョンが1.13以上であれば kubectl diff statefulset hogehoge とする(1.14時点でα版)。サーバーサイドアプライにより、現状と差分がわかる。

バージョンが1.12以下の場合、正確な情報を知ることが難しい。annotationだけが頼りになる。

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.0", GitCommit:"2bd9643cee5b3b3a5ecbd3af49d09018f0773c77", GitTreeState:"clean", BuildDate:"2019-09-19T13:57:45Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"12+", GitVersion:"v1.12.9-gke.15", GitCommit:"b48a8d693e191192e27c2f807daa51b54d0b0a61", GitTreeState:"clean", BuildDate:"2019-08-12T17:49:30Z", GoVersion:"go1.10.8b4", Compiler:"gc", Platform:"linux/amd64"}

Kubernetesは直近でapplyした結果を .metadata.annotations.kubectl.kubernetes.io/last-applied-configuration に保存している。このannotationを見て判断することができる。

$ kubectl apply view-last-applied statefulset hogehoge

あくまでも、直近でapplyした結果しか保存していないため、誰かが kubectl patch を実行していた場合、そのannotationはあてにならない。 kubectl get statefulset hogehoge -o yaml と突き合わせれば差分が手に入る。しかし、 applyしたときとは違う値が入っている場合がある。わかりやすい例だと、ServiceのType:LoadBalancerは、external ipがあとから付与されるため、apply時点では知ることができない。

Ref

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?