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
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
190
Platform Engineering from the CNCF Perspective
hhiroshell
0
62
Maximizing the Launch Reliability: Ensuring Stable Application Lift-off and Orbit on Kubernetes
hhiroshell
0
84
CNCFの視点で捉えるPlatform Engineering - 最新動向と展望 / Platform Engineering from the CNCF Perspective
hhiroshell
0
280
Cloud Native Scalability for Internal Developer Platforms
hhiroshell
5
810
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
290
Kubernetesでアプリの安定稼働と高頻度のアップデートを両立するためのプラクティス / Best Practices for Applications on Kubernetesto Achieve Both Frequent Updates and Stability
hhiroshell
11
4.7k
Other Decks in Technology
See All in Technology
Secure Boot 2026 - Aggiornamento dei certificati UEFI e piano di adozione in azienda
memiug
0
120
全自動で回せ!Claude Codeマーケットプレイス運用術
yukyu30
3
140
AIエンジニア Devin と歩む、自律型運用プロセスの構築
a2ito
0
350
俺の失敗を乗り越えろ!メーカーの開発現場での失敗談と乗り越え方 ~ゆるゆるチームリーダー編~
spiddle
0
400
2026年のAIエージェント構築はどうなる?
minorun365
12
2.9k
Data Hubグループ 紹介資料
sansan33
PRO
0
2.8k
トラブルの大半は「言ってない」x「言ってない」じゃねーか!!
ichimichi
0
210
Serverless Agent Architecture on Azure / serverless-agent-on-azure
miyake
1
110
AI Coding Agentの地殻変動 ~ ai-coding.info の定点観測 ~
kotauchisunsun
1
490
社内でAWS BuilderCards体験会を立ち上げ、得られた気づき / 20260225 Masaki Okuda
shift_evolve
PRO
1
150
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
1.1k
AI活用を"目的"にしたら、データの本質が見えてきた - Snowflake Intelligence実験記 / chasing-ai-finding-data
pei0804
0
820
Featured
See All Featured
The browser strikes back
jonoalderson
0
740
Prompt Engineering for Job Search
mfonobong
0
180
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
620
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
9.7k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
850
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
117
110k
First, design no harm
axbom
PRO
2
1.1k
Code Reviewing Like a Champion
maltzj
527
40k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
0
220
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
290
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
70
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
180
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