Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Cortexの話をKubeConで聞きたかったっていう話
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
uesyn
January 09, 2019
2.2k
4
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Cortexの話をKubeConで聞きたかったっていう話
uesyn
January 09, 2019
More Decks by uesyn
See All by uesyn
PodSecurityPolicyの安全な移行の道のり / On the safe migration of PodSecurityPolicy
uesyn
1
1.2k
PodSecurityPolicyの廃止に備えて、 一足先にPodSecurity Admissionを試してみよう! / from-psp-to-podsecurity
uesyn
4
1.9k
Kubernetes v1.19 変更点調査のまとめ / k8s-v119-updates
uesyn
1
310
そのクラスタ本当にアップグレードして大丈夫? Storage Version の更新も忘れずにしよう! / k8s-storage-version-migration
uesyn
2
4k
次世代のログ基盤 Grafana Lokiを始めよう! / prometheus-meetup-tokyo-3-lets-start-the-loki
uesyn
7
15k
kindでも"type LoadBalancer"を使いたい! / kubernetes-meetup-tokyo-24-kind-with-type-loadbalancer
uesyn
0
1.8k
Loki入門
uesyn
8
2.8k
kubernetesでGPUを 管理するために スケジューラをいじってみた
uesyn
2
3k
Featured
See All Featured
Agile that works and the tools we love
rasmusluckow
331
22k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
420
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
330
Making the Leap to Tech Lead
cromwellryan
135
10k
Visualization
eitanlees
152
17k
Mobile First: as difficult as doing things right
swwweet
225
10k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.8k
Designing Experiences People Love
moore
143
24k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
440
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
530
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
500
Transcript
Cortexの話を KubeConで 聞きたかったっていう話 上村 真也(@uesyn)
本発表は私自身の見解であり、 所属する企業や組織の立場、戦略、意見を 代表するものではありませんし、 私にはそんな権限ありません。
自己紹介 • 名前:上村 真也(@uesyn) • 所属:K◦◦I、現在クリエーションラインへ50%出向中 • 趣味:PCゲーム(特にFPS) • 好きな技術:kubernetes,
OpenStack
Cortexに関するセッション • https://sched.co/GrXL • https://www.youtube.com/watch?v=iyN40FsRQEo
Prometheusのローカルストレージ • Long-term Storageではない ◦ レプリケーションの機能がない ◦ クラスター化されていない • 長期間保存が必要な場合
◦ Remote Storageを活用 ◦ Prometheusのremote read/write ▪ https://prometheus.io/docs/prometheus/latest/configuration/configuration/#remote_write ▪ https://prometheus.io/docs/prometheus/latest/configuration/configuration/#remote_read https://prometheus.io/docs/prometheus/latest/storage/#remote-storage-integrations
Cortexとは? Prometheusのメトリクスのための • 水平スケーラブル可能で • High-availabilityで • マルチテナント対応な • 長期間ストレージ
https://github.com/cortexproject/cortex/blob/master/imgs/logo.png
簡単な歴史 2016/06/16 Project start at Weaveworks 2016/10/25 Renamed to Cortex
2018/02/19 Weaveworks initiate community model 2018/09/20 Acceptance of Cortex into the CNCF Sandbox
Cortexのアーキテクチャ
Cortexのアーキテクチャ https://github.com/cortexproject/cortex/blob/master/docs/architecture.png
Cortexのアーキテクチャ https://github.com/cortexproject/cortex/blob/master/docs/architecture.png ユーザテナント remote write
Cortexのアーキテクチャ https://github.com/cortexproject/cortex/blob/master/docs/architecture.png
Frontend • Cortexに含まれていないため自分で実装する必要がある • ユーザ側Prometheusからリクエストを受けとる
Cortexのアーキテクチャ https://github.com/cortexproject/cortex/blob/master/docs/architecture.png
Distributor • Prometheusから送信された時系列データを処理する • 複数のIngesterに並列でサンプルを送信する ◦ どのIngesterへ送信するかは分散ハッシュテーブルを活用 ◦ コンシステントハッシュリングは Consulに保存
• ステートレスな設計 https://schd.ws/hosted_files/kccna18/9b/Cortex%20CloudNativeCon%202018.pdf
Cortexのアーキテクチャ https://github.com/cortexproject/cortex/blob/master/docs/architecture.png
Ingester • 時系列データを長期ストレージバックエンドへ書き込む ◦ 数時間分のデータを圧縮しチャンクとして ▪ 圧縮にはGorillaを利用 ◦ バックエンドの長期ストレージへの書き込み頻度を下げる •
過去12時間のデータを保持しておく ◦ 直近のデータの読み込みを高速化するため ◦ 上記のためセミステイトフル https://schd.ws/hosted_files/kccna18/9b/Cortex%20CloudNativeCon%202018.pdf
Cortexのアーキテクチャ https://github.com/cortexproject/cortex/blob/master/docs/architecture.png
Chunk store • 2種類のデータストア 1. chunkとしてまとめられた時系列データを保存 2. chunkのための転置インデックスを保存 chunkを保存(オプション) インデックスを保存
*chunkも保存可能*
Cortexのアーキテクチャ https://github.com/cortexproject/cortex/blob/master/docs/architecture.png
Query Frontend • テナントからのReadリクエストをいい感じにQuerierに流してくれる ◦ Readのリクエストをテナント ID毎にキューイング ◦ テナント間のリクエストを公平にスケジューリング ◦
エラー時のリトライ ◦ 複数の日をまたぐリクエストの分割による分散処理 ◦ クエリ結果のキャッシュ • オプションのサービスなので省略可能
Cortexのアーキテクチャ https://github.com/cortexproject/cortex/blob/master/docs/architecture.png
Querier • クライアントからのPromQLクエリを処理 • 取得する時系列データへのアクセスの抽象化 ◦ 直近のデータはIngesterから取得 ◦ 上記以外はchunk storeから取得
https://schd.ws/hosted_files/kccna18/9b/Cortex%20CloudNativeCon%202018.pdf
Cortexのアーキテクチャ https://github.com/cortexproject/cortex/blob/master/docs/architecture.png
Ruler • Alertingのためのルールを実行してアラートを、Alertmanagerに送信 • CortexのインストールにはAlertmanagerも含まれる
マルチテナント対応について
マルチテナント対応について https://github.com/cortexproject/cortex
マルチテナント対応について https://github.com/cortexproject/cortex/blob/master/docs/architecture.md
マルチテナント対応について • リクエストに含まれるヘッダ内のIDでテナントを判断 • テナントID毎にPrometheusのメトリクスを分割して保存可能 • Cortex自体に認証・認可の機能は含まれず、実装が必要
headerに埋め込むテナントID https://github.com/cortexproject/cortex/blob/master/cmd/distributor/main.go#L106 • distributor内のコードを確認
headerに埋め込むテナントID https://github.com/weaveworks/common/blob/master/middleware/http_auth.go#L12
headerに埋め込むテナントID • X-Scope-OrgIDで識別 • ユーザ実装のFrontendで埋め込もう?
Cortexをkubernetes上で動かそう!
Cortexをkubernetes上で動かそう! • 動かそうと思った矢先
Cortexをkubernetes上で動かそう!
Cortexをkubernetes上で動かそう! • 公式の入門ドキュメントは現状ない(1/7時点) • For Developersに記載された通りに動かしても動かない • そもそも動かしてもFrontendを実装しないとマルチテナントは使えない ◦ nginxで固定でheaderをつけるようにしてクライアント毎にフロントエンドを分けるのが一番楽
とりあえず動いた手順 1. make a. コンテナイメージができるので動かしたい k8sからアクセスできるregisotryへpush i. 公式で用意されているコンテナイメージはたぶん存在してない ii. makeの前にMakefileのIMAGE_PREFIXを編集しておく
2. k8sディレクトリ内のマニフェストのimageを上記へ置換 3. 一部マニフェスト内のargumentが間違っている部分を修正 対象:ingester-dep.yaml, querier-dep.yaml, ruler-dep.yaml, table-manager-dep.yaml 変更:--dynamodb.periodic-table.start → --dynamodb.periodic-table.from 4. kubectl create -f ./k8s
とりあえず動いた手順
とりあえず動作確認 5. kubectl port-forward svc/nginx 9999:80 6. curl http://127.0.0.1:9999/api/prom/api/v1/query?query=up ◦
{"status":"success","data":{"resultType":"vector","result":[]}}が多分返ってくる
Cortexへデータを書き込もう! • remote_writeのURLはdistributorへhttpで/api/prom/pushに対して ◦ もちろんheaderにはテナントIDを入れて https://github.com/cortexproject/cortex/blob/master/cmd/distributor/main.go#L102
Cortexからデータを読み込もう! • Grafanaなどからquery-frontendへhttpで/api/prom/.*に対して ◦ もちろんheaderにはテナントIDを入れて https://github.com/cortexproject/cortex/blob/master/cmd/query-frontend/main.go#L55
まとめと今後 • まとめ ◦ cortexの歴史と概要を紹介 ◦ とりあえず動かす手順を紹介 • 今後 ◦
本物のDynamoDB, S3への接続 ◦ 負荷テストとか? ◦ Ruler, table-manager, schemaの調査 ◦ 似たような設計のLokiの調査