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

【Kubernetes特集 Day 3/6】第2章 アーキテクチャ:YAMLがコンテナになるまでの6ステップと「止まっている層」の切り分け

0
Posted at

Kubernetes特集の3日目です

Kubernetesで挫折した初級技術者向けに、10月19日から6日間、毎日1ページずつ公開している特集の第2章です。昨日の第1章では「Podを直接作ると誰も見張らない。Deploymentを付けると消しても戻る」を手で確かめました。今日は、その「見張り役」と裏側の部品を分解します。

Day 公開日 ページ
1 10/19(月) 特集トップ(全体像・用語の地図・環境準備)
2 10/20(火) 第1章 Kubernetesの基礎
3 10/21(水) 第2章 アーキテクチャ(今日)
4〜6 10/22〜24 ワークロード/ネットワークとストレージ/本番運用

第2章で扱うこと

  • API Server・etcd・Scheduler・Controller Manager・kubelet の5つの部品と、それぞれの仕事
  • kubectl apply からコンテナ起動までの6ステップ(図あり)
  • kubectl get events の1行ずつが「誰の仕事か」を読む
  • Deployment → ReplicaSet → Pod の親子関係を ownerReferences で確かめる
  • Control Planeが止まったとき、続くことと止まること

イベントに担当者の名前を付ける

Deploymentを1つ作って、イベントを古い順に並べます。

kubectl -n lab apply -f deploy.yaml
kubectl -n lab get events --sort-by=.lastTimestamp
REASON 誰の仕事か
ScalingReplicaSet Deployment Controller
SuccessfulCreate ReplicaSet Controller
Scheduled Scheduler
Pulling / Pulled / Created / Started kubelet

障害のときは、この表のどこで行が途切れているかを見ます。Scheduled がなければSchedulerの手前、Scheduled はあるのに Pulled がなければkubeletかレジストリです。

わざと壊す演習3つ

  1. requestsをcpu 64コアにする → Pending。FailedScheduling: Insufficient cpu。Schedulerの層で止まり、古いPodは残る
  2. 存在しないイメージタグに更新 → Scheduled は付くのに Failed。kubeletの層。rollout undo で戻す
  3. PodのラベルをselectorからずらすとPodが3個になる。書き換えたPodは ownerReferences が消え、誰の子でもなくなる

部品どうしは直接話さず、全員がAPI Serverの台帳を読んで差を埋めて書き戻す。この形が見えると、Pending と ImagePullBackOff が別の層の話だと一目でわかります。

明日(10/22)は第3章で、今日のDeploymentにService、ConfigMap/Secret、Probe、requests/limitsを足して、Webアプリを複数台で安定して動かします。新しい章へのリンクはすべて特集トップに追加されるので、トップをブックマークしておいてください。

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