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
Exadata Fleet Update
oracle4engineer
PRO
0
1.1k
Agent Skils
dip_tech
PRO
0
130
モダンUIでフルサーバーレスなAIエージェントをAmplifyとCDKでサクッとデプロイしよう
minorun365
4
220
30万人の同時アクセスに耐えたい!新サービスの盤石なリリースを支える負荷試験 / SRE Kaigi 2026
genda
4
1.4k
15 years with Rails and DDD (AI Edition)
andrzejkrzywda
0
200
小さく始めるBCP ― 多プロダクト環境で始める最初の一歩
kekke_n
1
550
プロポーザルに込める段取り八分
shoheimitani
1
620
【Ubie】AIを活用した広告アセット「爆速」生成事例 | AI_Ops_Community_Vol.2
yoshiki_0316
1
120
M&A 後の統合をどう進めるか ─ ナレッジワーク × Poetics が実践した組織とシステムの融合
kworkdev
PRO
1
490
ファインディの横断SREがTakumi byGMOと取り組む、セキュリティと開発スピードの両立
rvirus0817
1
1.6k
コスト削減から「セキュリティと利便性」を担うプラットフォームへ
sansantech
PRO
3
1.6k
Context Engineeringの取り組み
nutslove
0
380
Featured
See All Featured
Marketing to machines
jonoalderson
1
4.6k
[SF Ruby Conf 2025] Rails X
palkan
1
760
Faster Mobile Websites
deanohume
310
31k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.9k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
0
260
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
117
110k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.1k
Into the Great Unknown - MozCon
thekraken
40
2.3k
Chasing Engaging Ingredients in Design
codingconduct
0
110
Code Reviewing Like a Champion
maltzj
527
40k
Mobile First: as difficult as doing things right
swwweet
225
10k
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.2k
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