Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Kubernetesによる インフラ共通基盤 - JapanTaxi Kubernetes Ecosystem (JKE)の紹介
Quentin Plessis
September 09, 2019
Technology
1
5.2k
Kubernetesによる インフラ共通基盤 - JapanTaxi Kubernetes Ecosystem (JKE)の紹介
Quentin Plessis
September 09, 2019
Tweet
Share
More Decks by Quentin Plessis
See All by Quentin Plessis
Kubernetes & EKSによるインフラ共通基盤の構築
quentinplessis
5
2.5k
Other Decks in Technology
See All in Technology
大声で伝えたい!定時に帰る方法
sbtechnight
0
240
ぼくらが選んだ次のMySQL 8.0 / MySQL80 Which We Choose
line_developers
PRO
7
3k
A3-1 IBM Championが本音で語る「IBM Cloud」
kolinz
0
310
Learning to Solve Hard Minimal Problems
takmin
1
500
テスト自動化を最速で軌道に乗せるために
nozomiito
0
140
ソフトウェアアーキテクチャの基礎: Software Architecture in a Nutshell
snoozer05
31
9k
VS Code Meetup #21 - もう一度知りたい基礎編 - ファイル操作、コーディングの基本編
74th
0
200
CloudWatchアラームによるサービス継続のための監視入門 / Introduction to Monitoring for Service Continuity with CloudWatch Alarms
inomasosan
1
440
ECS Exec を使った ECS の トラブルシューティング
dohara
0
160
Settlement simulation testing to ensure correct settlement processing
applepine1125
2
1.4k
hey BOOK
heyinc
26
290k
Backlog × RPAでいろいろ捗った話
z_tetsu
0
390
Featured
See All Featured
A better future with KSS
kneath
226
16k
Large-scale JavaScript Application Architecture
addyosmani
499
110k
From Idea to $5000 a Month in 5 Months
shpigford
373
44k
Robots, Beer and Maslow
schacon
152
7.1k
Product Roadmaps are Hard
iamctodd
35
6.9k
Six Lessons from altMBA
skipperchong
14
1.4k
Code Review Best Practice
trishagee
44
9.7k
A Philosophy of Restraint
colly
192
15k
Ruby is Unlike a Banana
tanoku
91
9.3k
Bootstrapping a Software Product
garrettdimon
296
110k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
6
580
Happy Clients
brianwarren
89
5.6k
Transcript
1 Proprietary and Confidential ©2019 JapanTaxi, Inc. All Rights Reserved
Kubernetesによる インフラ共通基盤 JapanTaxi Kubernetes Ecosystem (JKE)の紹介
2 Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved
Introduction Introduction Quentin Plessis (プレシ カンタン) Software Engineer (SREチーム) @ JapanTaxi株式会社 経験と興味 - 画像処理 - GPUを使ったコンピュータビジョンとAR - モバイル通信のデータ解析と統計モデリング - Web開発 - インフラ(環境構築と運用) - ...
3 Proprietary and Confidential ©2019 JapanTaxi, Inc. All Rights Reserved
目次 1) 背景 a) JapanTaxiのインフラ背景 b) なぜKubernetes? 2) Kubernetesでの運用 3) JapanTaxi Kubernetes Ecosystem (JKE)
4 Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved
JapanTaxiのインフラ背景 1) 1年半前からの状況 2) なぜKubernetes?
5 Proprietary and Confidential ©2019 JapanTaxi, Inc. All Rights Reserved
1年半前からの状況 Azure ホスト:Terraformで構築 プロビジョニング:Ansible 仮想化技術:Docker オーケストレーション:手動 スケール:手動 課題:ログ、デプロイ、監視 Azure AKS ホスト:AKS プロビジョニング:無 仮想化技術:Docker オーケストレーション:K8S スケール:K8S 統一:ログ、デプロイ、監視 Amazon EKS ホスト:Terraform プロビジョニング:無 仮想化技術:Docker オーケストレーション:K8S スケール:K8S 統一:ログ、デプロイ、監視 K8Sへ移行 AWSへ移行
6 Proprietary and Confidential ©2019 JapanTaxi, Inc. All Rights Reserved
なぜKubernetes? アプリケーションに集中したいですが、 ネットワーク (VPC, subnet…) オートスケール デプロイ、ロールバック 監視、アラート ログ送信、収集、閲覧 ... SSL 認証、認可 ... 回復力 再現性
7 Proprietary and Confidential ©2019 JapanTaxi, Inc. All Rights Reserved
なぜKubernetes? Kubernetesを利用すると、全てのアプリケーションが同様 に使える共通なインフラ基盤ができる (PaaS) マルチクラウド コミュニティドリブン 開発スピード プラグイン オンプレミス PaaSの実現方法 ...
8 Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved
Kubernetesでの運用 1) クラスタ構築 2) K8Sリソース管理 3) 運用して気づいたこと
9 Proprietary and Confidential ©2019 JapanTaxi, Inc. All Rights Reserved
クラスタ構築 - オンプレミス → 大変 - クラウドサービス - GUI → テストレベルまでOK、実際の運用には再現性が足りていない - 構築ツール (kops, eksctl ...) → 悪くないですが汎用性は足りていない - Terraform → 全クラウドサービスがサポートされている、K8S以外のリソース管理もできる
10 Proprietary and Confidential ©2019 JapanTaxi, Inc. All Rights Reserved
K8Sリソース管理 - YAML+ kubectl apply - (+) シンプル - (+) コード化可能 - (-) クラスタのコンテキスト切り替えに注意 - (-) テンプレート機能がない - (-) 複数のリソースを一つのパッケージとして管理するのも複雑 (依存関係...) - パッケージングツール (helm …) - (+) コード化可能 - (+) テンプレートエンジン - (+) パッケージング - (+) ビルドとデプロイを分ける - (-) クラスタのコンテキスト切り替えに注意 - (-) 学習コスト
11 Proprietary and Confidential ©2019 JapanTaxi, Inc. All Rights Reserved
運用して気づいたこと - PodDisruptionBudget(PDB)は大事 - ポッド数が決まったしきい値より少なくならないように (クラスタのローリングアップ デート時など) - ServiceのExternalTrafficPolicyは大事 - 冗長化可能なアプリケーションしか作らない方がいい - 同時に1つのポッドしか動かせないアプリケーションの運用は大変 - アプリケーションはホストに依存しないようにする - ログファイルなどはNG - データベースはマネージドサービスのほうがいい - データの保存、管理、移行などを避けるためStatefulSetは使わない - 全てのアプリケーションに設定すべきな共通なリソースがある - Deployment, Service, HorizontalPodAutoscaler, PDB, Secret, (Ingress) ...
12 Proprietary and Confidential ©2019 JapanTaxi, Inc. All Rights Reserved
運用して気づいたこと - KubernetesのServiceリソースは一番便利 - DNSレコードを追加しなくてもいい、dev/prod環境と関係なく同じエンドポイントなど - Kubernetesのコンテキスト切り替えは混乱する - 開発環境で操作しようと思ったら本番環境だった - 学習コストが高い - アプリケーションエンジニア全員に教えるのは難しい - (+) 柔軟性が高い - 「これをKubernetesで実現するのは難しい」と言ったこと(ほぼ)ない - (-) 柔軟性が高すぎる - コントロールしないとアプリケーションによる構成の差異が大きくなって管理が難しく なる
13 Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved
JapanTaxi Kubernetes Ecosystem (JKE) 1) JKEとは 2) JKE CLI で新しいアプリケーションを動かすには
14 Proprietary and Confidential ©2019 JapanTaxi, Inc. All Rights Reserved
JapanTaxi Kubernetes Ecosystem (JKE) Kubernetesで運用するために、 SREチームが考えた方針と その方針を簡単に適用するためのツール 記事:本番環境へのKubernetesの導入やk8s共通基盤JKEの開発により苦労のないサーバ運用を実現
15 Proprietary and Confidential ©2019 JapanTaxi, Inc. All Rights Reserved
JapanTaxi Kubernetes Ecosystem (JKE)
16 Proprietary and Confidential ©2019 JapanTaxi, Inc. All Rights Reserved
JKE - JKE クラスター - SREメンバーが管理している - インフラの共通機能が提供されている(ログ収集、監視、デプロイ …) - 新しい機能をどんどん追加していく - JKE CLI - SREチームがRubyで開発したCLI - アプリケーションエンジニアが使う - jkeさえインストールすれば、 - 新しいアプリケーションを簡単に作成できる - 統一されたやり方でアプリケーションを管理できる - jke以外のツールのインストールは不要
17 Proprietary and Confidential ©2019 JapanTaxi, Inc. All Rights Reserved
JKEで新しいアプリケーションを動かすには フォーカスはアプリケーションに → アプリケーションエンジニアの視点で新しいアプリケーションを追加してみましょう > cd my_application > docker build & docker push > jke init --port 80 > jke build > jke dev deploy > jke stg deploy > jke prod deploy 5分でビルド& デプロイ!
18 Proprietary and Confidential ©2019 JapanTaxi, Inc. All Rights Reserved
JKE init jke init:JKE設定の自動生成 ... containers: app: ports: - name: http containerPort: 80 protocol: TCP resources: limits: cpu: 1.0 memory: 2Gi requests: cpu: 1.0 memory: 2Gi replicaCount: 2 autoscale: enabled: true minReplicas: 2 maxReplicas: 10 targetCPUUtilizationPercentage: 70 terminationGracePeriod: 30 ... サーバを2台 用意 オートスケール で最大10台まで 拡張 アプリケーションポート 最低と最高CPUとメモリー
19 Proprietary and Confidential ©2019 JapanTaxi, Inc. All Rights Reserved
JKEで新しいアプリケーションを動かすには jke initコマンドだけでス ケーラブルなサーバ環境 を瞬時に構築!
20 Proprietary and Confidential ©2019 JapanTaxi, Inc. All Rights Reserved
JKE / アプリケーションデプロイフロー
21 Proprietary and Confidential ©2019 JapanTaxi, Inc. All Rights Reserved
JKEで使える便利な機能 jkeで使える便利な機能 ▶ jke dev connect Switched to context "arn:aws:eks:redacted:redacted:cluster/redacted". user@my-application-b8fd49798-98d6q:/app# ps ax PID TTY STAT TIME COMMAND 1 ? Ss 0:00 /bin/bash /docker-entrypoint.sh bundle exec puma 27 ? Sl 0:11 puma 3.12.1 (unix:////app/tmp/sockets/puma.so 121 ? Sl 0:16 puma: cluster worker 1: 27 [app] 165 ? Sl 0:13 puma: cluster worker 0: 27 [app] コンテナに接続 ▶ jke stg connect ... ▶ jke prod connect ... 環境の選択や認証などは jkeに任せる!
22 Proprietary and Confidential ©2019 JapanTaxi, Inc. All Rights Reserved
JKEで使える便利な機能 jkeで使える便利な機能 ▶ jke dev logs 10.100.xxx.xxx - - [02/Jul/2019:10:27:53 +0000] "GET / HTTP/1.1" 401 12 "-" "Mozilla/5.0 AppleWebKit/ Chrome/ Safari/" 10.100.xxx.xxx - - [02/Jul/2019:10:27:55 +0000] "GET /test HTTP/1.1" 401 12 "-" "Mozilla/5.0 AppleWebKit/ Chrome/ Safari/" 10.100.xxx.xxx - - [02/Jul/2019:10:28:01 +0000] "GET / HTTP/1.1" 200 15 "-" "kube-probe/1.12" ... ログを閲覧 ▶ jke stg logs ... ▶ jke prod logs ...
23 Proprietary and Confidential ©2019 JapanTaxi, Inc. All Rights Reserved
JKEで使える便利な機能 jkeを使ってアプリケーションを作ると、下記の機能が使えます - デプロイの仕組み (デプロイ、ロールバック、Slack通知、CloudWatch Logs) - アプリケーションログ:Amazon Athena/BigQueryで閲覧できる - 監視:NewRelicのダッシュボード、PagerDutyでの死活監視 ... - SSL証明書の自動生成 - オートスケール - … - これから追加される機能も
24 Proprietary and Confidential ©2019 JapanTaxi, Inc. All Rights Reserved
まとめ 1) 問題:アプリケーションに集中できない 解決方法: → Kubernetes (k8s) をベースに共通なインフラ基盤 2) 問題:K8Sの使い方がありすぎて混乱する、学習コストが高い 解決方法: → SREチームの方針を実現するJKE → jke initを使うことで5分で運用しやすくて安定的なアプリケーションが作れる → アプリケーションに集中できる
〒102-0094 東京都千代田区紀尾井町3-12 3-12 Kioicho Chiyoda-ku, Tokyo 102-0094 Japan TEL 03-6265-6265 FAX 03-3239-8115
www.japantaxi.co.jp 文章·画像等の内容の無断転載及び複製等の行為はご遠慮ください。 Proprietary and Confidential ©2019 JapanTaxi, Inc. All Rights Reserved