kubernetesを触ってみた
DESCRIPTION
Kuberenetesを触ってみたので、こんな感じでしたよとレポートしますTRANSCRIPT
Kubernetesを触ってみた第20回 PaaS勉強会 @jacopen
@jacopen Kazuto KusamaNTT Communications !Cloudn PaaSの開発・運用をやっています
Cloud
Cloud
IaaS
PaaS
SaaS
Cloud
IaaS
PaaS
SaaS
Cloud
IaaS
PaaS
SaaS
Cloud
IaaS
PaaS
SaaS
Cloud = VM?
Cloud = VM?
うちのサービス、全部コンテナで動いてるで
うちもや。VMとか使ってへんで
Docker
なんか呼んだ
か?
コンテナという選択肢• コンテナ技術そのものは昔からある • LinuxでもLXCがあった
• 商用UNIXの世界ではン十年前からある
Dockerのすごいところどや
• コンテナ技術のもつメリットに加えて・・
• 差分ディスクイメージを作ってシェアできる • Dockerfileでインフラのコード化ができる
コンテナ技術がグッと身近に。 コミュニティが進化すればするほど使いやすく。
運用に課題• どうやって数あるホストにコンテナを配置する?
• どうやって今稼働しているコンテナを管理する?
• 死活監視は?
Dockerだけでは運用できない
Kubernetes
KubernetesとはGoogleが公開した、コンテナ管理ツール
!
Kubernetes (koo-ber-nay'-tace) is Greek for “helmsman” of a ship. 船の舵を取る人 という意味らしい
Design Overview
Kubernetes is a system for managing containerized applications across multiple hosts, providing basic mechanisms for deployment, maintenance, and scaling of applications
https://github.com/GoogleCloudPlatform/kubernetes/blob/master/DESIGN.md
まずは触ってみよう
DEMO
今回のKubernetes環境
Master
Node (Minion)
Node (Minion)
Node (Minion)
Node (Minion)
Demoで構築したもの
redis-masterredisslave redisslave
frontend frontend frontend
Frontend Replication Controller
Redis Slave Replication Controller
Redis Slave service Redis master service
Kubernetesの仕組み• Pod • Label • Replication Controller • Service
Pod• コンテナの集まり • 今回のデモだと1Pod 1Container
• Pod内のコンテナは、必ず同一ホストになる
• ストレージとか、IPアドレスを共有しなければいけないコンテナをまとめられる
Label
• Podに「ラベル」を自由に付けられる
• 環境を示すラベル(Production,
Development, Staging) • 役割を示すラベル(Frontend, Backend,
Worker, Logger) • 1つのPodに複数のラベルが付けられる
redis-masterredisslave redisslave
frontend frontend frontend
Pod
Label
Replication Controllers
• Podテンプレートから、指定された数のReplicaを作成する仕組み
• Podの監視をしていて、指定された数より多ければ減らし、少なければ減らす
redis-masterredisslave redisslave
frontend frontend frontend
Frontend Replication Controller
Redis Slave Replication Controller replicas:2
replicas:3
Service
• L3のプロキシみたいなもの
• 設定したPodにラウンドロビンでアクセスを分配する
redis-masterredisslave redisslave
frontend frontend frontend
Frontend Replication Controller
Redis Slave Replication Controller
Redis Slave service Redis master servicePort:10000 Port:10001
Port:6379Port:6379Port:6379
redis-masterredisslave redisslave
frontend frontend frontend
Frontend Replication Controller
Redis Slave Replication Controller
Redis Slave service Redis master servicePort:10000 Port:10001
Port:6379Port:6379Port:6379
Frontend service
自分でKubernetesを試してみる今だといろんな環境で試せる • Google Compute Engine • Vagrant • CoreOS • Microsoft Azure • Digital Ocean • OpenStack
環境によって構築方法は異なる • Kubernetesリポジトリの、Getting Started
Guidesを参照。
• GCEで構築はめちゃくちゃ楽
• gcloud cliが使える状態なら、構築はコマンド一発
• 対応表に入っていないIaaSでも、その上にCoreOSクラスタ構築すれば使えるんじゃないかな?
Kubernetes=PaaS?
今後調べたいこと• OpenShift+Kubernetes • Corekube(CoreOS+Kuberenetes
+OpenStack) • Network周り