$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Kubernetesの構成を理解する
Search
hhiroshell
February 28, 2018
Technology
13
3.9k
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
110
Platform Engineering from the CNCF Perspective
hhiroshell
0
38
Maximizing the Launch Reliability: Ensuring Stable Application Lift-off and Orbit on Kubernetes
hhiroshell
0
61
CNCFの視点で捉えるPlatform Engineering - 最新動向と展望 / Platform Engineering from the CNCF Perspective
hhiroshell
0
220
Cloud Native Scalability for Internal Developer Platforms
hhiroshell
5
760
LINEヤフーにおける超大規模プラットフォーム実現への挑戦と学び / Challenges and Lessons in Building an Ultra-Large-Scale Platform at LY Corporation
hhiroshell
3
1.7k
Architecting Kubernetes-Based Internal Developer Platforms: Essential Patterns and Practices
hhiroshell
0
260
Discover Your Tailored Platform Strategy with Real-World Practice
hhiroshell
1
270
Kubernetesでアプリの安定稼働と高頻度のアップデートを両立するためのプラクティス / Best Practices for Applications on Kubernetesto Achieve Both Frequent Updates and Stability
hhiroshell
11
4.4k
Other Decks in Technology
See All in Technology
モダンデータスタック (MDS) の話とデータ分析が起こすビジネス変革
sutotakeshi
0
400
Snowflakeでデータ基盤を もう一度作り直すなら / rebuilding-data-platform-with-snowflake
pei0804
2
320
会社紹介資料 / Sansan Company Profile
sansan33
PRO
11
390k
バグハンター視点によるサプライチェーンの脆弱性
scgajge12
3
970
re:Invent 2025 ふりかえり 生成AI版
takaakikakei
1
170
【AWS re:Invent 2025速報】AIビルダー向けアップデートをまとめて解説!
minorun365
4
460
エンジニアリングマネージャー はじめての目標設定と評価
halkt
0
250
新 Security HubがついにGA!仕組みや料金を深堀り #AWSreInvent #regrowth / AWS Security Hub Advanced GA
masahirokawahara
1
1.3k
法人支出管理領域におけるソフトウェアアーキテクチャに基づいたテスト戦略の実践
ogugu9
1
210
生成AI時代の自動E2Eテスト運用とPlaywright実践知_引持力哉
legalontechnologies
PRO
0
210
Challenging Hardware Contests with Zephyr and Lessons Learned
iotengineer22
0
120
AWS Bedrock AgentCoreで作る 1on1支援AIエージェント 〜Memory × Evaluationsによる実践開発〜
yusukeshimizu
6
360
Featured
See All Featured
Large-scale JavaScript Application Architecture
addyosmani
515
110k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.6k
Balancing Empowerment & Direction
lara
5
790
The Pragmatic Product Professional
lauravandoore
37
7.1k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.1k
Designing Experiences People Love
moore
143
24k
Rebuilding a faster, lazier Slack
samanthasiow
84
9.3k
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
9
1k
Raft: Consensus for Rubyists
vanstee
141
7.2k
Being A Developer After 40
akosma
91
590k
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