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
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
170
Platform Engineering from the CNCF Perspective
hhiroshell
0
47
Maximizing the Launch Reliability: Ensuring Stable Application Lift-off and Orbit on Kubernetes
hhiroshell
0
70
CNCFの視点で捉えるPlatform Engineering - 最新動向と展望 / Platform Engineering from the CNCF Perspective
hhiroshell
0
250
Cloud Native Scalability for Internal Developer Platforms
hhiroshell
5
770
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
270
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.5k
Other Decks in Technology
See All in Technology
【Agentforce Hackathon Tokyo 2025 発表資料】みらいシフト:あなた働き方を、みらいへシフト。
kuratani
0
120
国井さんにPurview の話を聞く会
sophiakunii
1
410
たかがボタン、されどボタン ~button要素から深ぼるボタンUIの定義について~ / BuriKaigi 2026
yamanoku
1
280
チームで安全にClaude Codeを利用するためのプラクティス / team-claude-code-practices
tomoki10
7
3.4k
Data Intelligence on Lakehouse Paradigm
scotthsieh825
0
160
田舎で20年スクラム(後編):一個人が企業で長期戦アジャイルに挑む意味
chinmo
1
1.6k
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.3k
純粋なイミュータブルモデルを設計してからイベントソーシングと組み合わせるDeciderの実践方法の紹介 /Introducing Decider Pattern with Event Sourcing
tomohisa
1
1.2k
手軽に作れる電卓を作って イベントソーシングに親しもう CQRS+ESカンファレンス2026
akinoriakatsuka
0
450
新米スクラムマスターの4ヶ月 -「スクラムイベントを回しているのに手応えがない」からの脱出 / Four Months as a New Scrum Master — When Scrum Events Were Running, but Nothing Felt Right
owata
0
170
RALGO : AIを組織に組み込む方法 -アルゴリズム中心組織設計- #RSGT2026 / RALGO: How to Integrate AI into an Organization – Algorithm-Centric Organizational Design
kyonmm
PRO
3
1.4k
サラリーマンソフトウェアエンジニアのキャリア
yuheinakasaka
41
19k
Featured
See All Featured
A Modern Web Designer's Workflow
chriscoyier
698
190k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.8k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
250
The Spectacular Lies of Maps
axbom
PRO
1
440
Joys of Absence: A Defence of Solitary Play
codingconduct
1
270
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
120
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Practical Orchestrator
shlominoach
190
11k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.3k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
The World Runs on Bad Software
bkeepers
PRO
72
12k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.7k
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