Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Kubernetesの構成を理解する
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
hhiroshell
February 28, 2018
Technology
13
4k
Kubernetesの構成を理解する
Kubernetesクラスターの中身をざっくりと解説
hhiroshell
February 28, 2018
Tweet
Share
More Decks by hhiroshell
See All by hhiroshell
Kubernetes Multi-tenancy: Principles and Practices for Large Scale Internal Platforms
hhiroshell
0
180
Platform Engineering from the CNCF Perspective
hhiroshell
0
53
Maximizing the Launch Reliability: Ensuring Stable Application Lift-off and Orbit on Kubernetes
hhiroshell
0
75
CNCFの視点で捉えるPlatform Engineering - 最新動向と展望 / Platform Engineering from the CNCF Perspective
hhiroshell
0
270
Cloud Native Scalability for Internal Developer Platforms
hhiroshell
5
790
LINEヤフーにおける超大規模プラットフォーム実現への挑戦と学び / Challenges and Lessons in Building an Ultra-Large-Scale Platform at LY Corporation
hhiroshell
3
1.8k
Architecting Kubernetes-Based Internal Developer Platforms: Essential Patterns and Practices
hhiroshell
0
280
Discover Your Tailored Platform Strategy with Real-World Practice
hhiroshell
1
280
Kubernetesでアプリの安定稼働と高頻度のアップデートを両立するためのプラクティス / Best Practices for Applications on Kubernetesto Achieve Both Frequent Updates and Stability
hhiroshell
11
4.6k
Other Decks in Technology
See All in Technology
Context Engineeringが企業で不可欠になる理由
hirosatogamo
PRO
3
660
Exadata Fleet Update
oracle4engineer
PRO
0
1.1k
Oracle AI Database移行・アップグレード勉強会 - RAT活用編
oracle4engineer
PRO
0
110
Frontier Agents (Kiro autonomous agent / AWS Security Agent / AWS DevOps Agent) の紹介
msysh
3
180
データの整合性を保ちたいだけなんだ
shoheimitani
8
3.2k
Amazon S3 Vectorsを使って資格勉強用AIエージェントを構築してみた
usanchuu
4
460
Context Engineeringの取り組み
nutslove
0
380
Kiro IDEのドキュメントを全部読んだので地味だけどちょっと嬉しい機能を紹介する
khmoryz
0
210
AIエージェントを開発しよう!-AgentCore活用の勘所-
yukiogawa
0
180
Tebiki Engineering Team Deck
tebiki
0
24k
1,000 にも届く AWS Organizations 組織のポリシー運用をちゃんとしたい、という話
kazzpapa3
0
120
Greatest Disaster Hits in Web Performance
guaca
0
280
Featured
See All Featured
Evolving SEO for Evolving Search Engines
ryanjones
0
130
Practical Orchestrator
shlominoach
191
11k
Deep Space Network (abreviated)
tonyrice
0
64
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
1
130
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
130
Java REST API Framework Comparison - PWX 2021
mraible
34
9.1k
Designing Experiences People Love
moore
144
24k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
14k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
0
1.1k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
0
2.4k
Building an army of robots
kneath
306
46k
Transcript
Cloud Native Developers JP Kubernetesの構成を理解する @hhiroshell 1
Cloud Native Developers JP お品書き • Kubernetesの全体像を理解する • Kubernetesクラスター大解剖 2
Cloud Native Developers JP Kubernetesの全体像を理解する 3
Cloud Native Developers JP Kubernetesの全体像 k8sクラスター >_ kubectl (CLI) マシンとネットワーク
4
Cloud Native Developers JP kubectl • Kubernetesクラスターの管理操作を行うためのコマンドラインイン ターフェース • Kubernetesクラスターを操作するときの最も基本的な手段
• コマンドをapiserver(後述)が提供するREST API呼び出しに変換 している (REST APIを直接呼び出すことも可) 5
Cloud Native Developers JP Kubernetesクラスター • クラスター本体です(あたりまえ) • 次章で詳しく解説 6
Cloud Native Developers JP Kubernetesクラスター大解剖 7
Cloud Native Developers JP Kubernetesクラスターの構成 Kubernetesクラスター Kubernetes Objects ✓ Kubernetesの機能の構成要素
✓ アプリケーションエンジニア が意識する範囲 Kubernetes Components ✓ Kubernetes Objectsを実現する実装 ✓ 管理やトラブルシュートをする 上で理解している必要がある ✓ インフラエンジニア/SREが 意識する範囲 8
Cloud Native Developers JP ✓ Kubernetes Objectsを実現する実装 ✓ 管理やトラブルシュートをする 上で理解している必要がある
✓ インフラエンジニア/SREが 意識する範囲 Kubernetesクラスターの構成 Kubernetes Components 9 Kubernetesクラスター Kubernetes Objects ✓ Kubernetesの機能の構成要素 ✓ アプリケーションエンジニア が意識する範囲
Cloud Native Developers JP Kubernetes Objects • Node • ワークロード
– Pod – Deployment/ReplicaSet – StatefulSet • ネットワーク – Service • ストレージ – Volume – PersistentVolume /PersistentVolumeClaim – StorageClass – ConfigMap – Secret • Objectを分類整理する仕組み – Namespace – Label/Label Selector 10 他にもありますが、まずはこのくら い抑えると良さそう
Cloud Native Developers JP Kubernetes Objects • Node • ワークロード
– Pod – Deployment/ReplicaSet – StatefulSet • ネットワーク – Service • ストレージ – Volume – PersistentVolume /PersistentVolumeClaim – StorageClass – ConfigMap – Secret • Objectを分類整理する仕組み – Namespace – Label/Label Selector 11
Cloud Native Developers JP Node • クラスターに属するマシンを表 すオブジェクト • クラスターの管理を担当する
Master Nodeと、コンテナ群の 実行環境となるWorker Nodeが ある Worker Node Master Node
Cloud Native Developers JP Pod • 複数のコンテナを束ねる単位 • コンテナの生成/破棄等はPod 単位で行われる
→1つのPodに入るコンテナ群は 共通のライフサイクルを持つ • 1つのPodに1つのクラスター内 IP • 内包する複数のコンテナは、必 ず同じNode上で稼働 Pod Container 13
Cloud Native Developers JP DeploymentとReplicaSet • Deployment: – ReplicaSetに対して、Podのレプ リカ数の調整の指示を行う
– Podの更新の際、新たな ReplicaSetを作成した上で、新旧 のReplicaSetを制御してローリン グアップデートを行う • Replicaset: – Deploymentからの指示を元にPod の上げ下げを行い、レプリカ数を 調整する Pod 14 D RS ReplicaSet Deployment
Cloud Native Developers JP StatefulSet • ステートフルなアプリケーションを含むPodを動かしたいときに利 用するKubernetes Object •
Deployment同様Podのスケーリングをサポートするが、各々のPod は固有の状態を保持する。ここでの状態とは以下 – クラスター内のFQDN – マウントする永続化領域 • Podが再起動した場合、同じ名前のPodは、同じFQDN、同じ永続化 領域をマウントしていることが保証される • Podをスケールすると連番を付与して名前が管理される(Deployment ではランダムな名前がつく) – e.g) mysql-0, mysql-1... 15
Cloud Native Developers JP Kubernetes Objects • Node • ワークロード
– Pod – Deployment/ReplicaSet – StatefulSet • ネットワーク – Service • ストレージ – Volume – PersistentVolume /PersistentVolumeClaim – StorageClass – ConfigMap – Secret • Objectを分類整理する仕組み – Namespace – Label/Label Selector 16
Cloud Native Developers JP Service • クラスター内外からのリクエスト をPodにルーティングするオブ ジェクト •
TCP/UDPをサポート • 複数のPodに対するロードバラン シングの役割も行う • 用途に応じて複数タイプがある – クラスター内に対してのみPodを公 開 – クラスター外を含めてPodを公開 …etc Service クラスター内外か らのリクエスト 17
Cloud Native Developers JP Kubernetes Objects • Node • ワークロード
– Pod – Deployment/ReplicaSet – StatefulSet • ネットワーク – Service • ストレージ – Volume – PersistentVolume /PersistentVolumeClaim – StorageClass – ConfigMap – Secret • Objectを分類整理する仕組み – Namespace – Label/Label Selector 18
Cloud Native Developers JP Volume • コンテナにマウント可能なボリュームを定義する情報 • 永続データの保存領域の実態をポイントする Volume(たとえばNodeのローカルディスクを指定(hostPath))
保存領域の実態 マウント 19
Cloud Native Developers JP PersistentVolume(PV)/PersistentVolumeClaim(PVC) • PVで永続データの保存領域の実態をポイントする • PVCで必要なディスクの要件(容量/書き込み権限の有無など)を 指定しておき、それをVolumeからポイントする
• PVCの要件を満たすPVが自動的に選択され、使われる Volume PersistentVolume Claim Persistent Volume 20
Cloud Native Developers JP Volumeの種類(抜粋) • Kubernetesでは様々なディスクボリュームをサポートしている • 秘匿情報を安全に保持するなど、単なるデータの永続化だけの用途 以外でもVolumeが使われる
• いわゆるストレージ – nfs – iscsi – gcePersistentDisk • テンポラリな保存領域として – hostPath – emptyDir • 設定情報等の受け渡し用 – secrets – downwardAPI – configMap • 他 – flocker – gitRepo 21
Cloud Native Developers JP StorageClassを使ったPVCの動的プロビジョニング • PVCでPVの代わりにStorageClassを指定 • 上記PVCをKubernetes内に作ると、StorageClassで設定された Provisionerがストレージをプロビジョニングし、それが利用される
• StorageClassでは、ディスク速度やサービスレベルも指定できる Volume PVC StorageClass Provisioner GCEPersistentDisk(例) 22
Cloud Native Developers JP ConfigMap • Containerに設定情報を渡すために使う • ConfigMap内にKey/Valueを記述しておき、そのConfigMapを Volumeとしてコンテナにマウントする。コンテナからは所定の設定
情報が記述されたファイルとして認識される • コンテナの環境変数として値を渡すこともできる マウント Volume ConfigMap(Key/Valueを記述) 23
Cloud Native Developers JP Secret • 機密度の高いデータを保持する際に使うVolume – DBなどの接続情報 –
クララスター内/外のサービスのアクセストークン – SSL/TLSの証明書 …etc • コンテナでSecretのデータを読み込むと、必ずメモリ内に保持され、 不要になったら削除される(tmpfsが使われている) • データの実態はマスターノード(etcd)に保持される 24
Cloud Native Developers JP Kubernetes Objects • Node • ワークロード
– Pod – Deployment/ReplicaSet – StatefulSet • ネットワーク – Service • ストレージ – Volume – PersistentVolume /PersistentVolumeClaim – StorageClass – ConfigMap – Secret • Objectを分類整理する仕組み – Namespace – Label/Label Selector 25
Cloud Native Developers JP Label/Label Selector • Kubernetes Objectをタグのよう な属性を設定して、グループ分け
する仕組み • Label: – Kubernetes Objectにアタッチする key/valueペアのセット • Label Selector: – Labelの設定値の条件を指定する情報。 条件に該当するものをグループとして 識別する partition = customerA Label Selector "tier" : “web", "partition" : "customerA" "tier" : “app", "partition" : "customerA" "tier" : “web", "partition" : "customerB" Label 26
Cloud Native Developers JP Label/Label Selectorの用途の例 • Serviceがルーティング対象のPodを識別するために利用される サービス partition
= customerA クラスター外から のリクエスト 27
Cloud Native Developers JP Label/Label Selectorの用途の例 • Serviceがルーティング対象のPodを識別するために利用される サービス クラスター外から
のリクエスト partition = customerA 28
Cloud Native Developers JP Namespace • 1つのクラスターを領域を分けて利用する仕組み • 複数のユーザーが同じクラスターで作業することを想定した機能 (1ユーザーごとに1つのNamespace)
• Kubernetes Objectの名前はNamespace内でユニークであればよい • Namespace毎にリソースの利用上限を設定可能 29
Cloud Native Developers JP Kubernetesクラスターの構成 30 Kubernetesクラスター Kubernetes Objects ✓
Kubernetesの機能の構成要素 ✓ アプリケーションエンジニア が意識する範囲 Kubernetes Components ✓ Kubernetes Objectsを実現する実装 ✓ 管理やトラブルシュートをする 上で理解している必要がある ✓ インフラエンジニア/SREが 意識する範囲
Cloud Native Developers JP Kubernetes Components • Kubernetesクラスターの制御を担うMaster Componentと、Podの 稼働や実行環境を実現するNode
Componentに分けられる REST API呼び出し API Server kube-proxy cotrollers kube-controller-manager kubelet Master Components Node Components Docker 支持された 状態の伝搬 Master Node Worker Node 31
Cloud Native Developers JP Node Components • kubelet – メンバーノードとしての基本機能を
実現する – Podの生成/更新/破棄などのコント ロール – 各種ステータスのレポート • kube-proxy – ネットワーク周りのルールを制御 • Docker – いわずもがなのコンテナ本体 kube-proxy kubelet Docker 32
Cloud Native Developers JP Master Components • kube-apiserver – Kubernetesクラスターのフロントエンド。
APIを提供 • kube-controller-manager – クラスターの制御を行う各種controllerを 動作させる • controllers – Node Controller – Replication Controller – Endpoints Controller – Service Account & Token Controllers API Server cotrollers kube-controller-manager 33
Cloud Native Developers JP 34 ここで休憩です…
Cloud Native Developers JP 35 Fin