$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
サクッと試すNew Relic Kubernetes APM auto-attach / Ne...
Search
kohbis
December 20, 2024
0
480
サクッと試すNew Relic Kubernetes APM auto-attach / New Relic Kubernetes APM auto-attach
New Relic User Group Vol.12 3周年&アドカレLT祭り
https://nrug.connpass.com/event/334268/
kohbis
December 20, 2024
Tweet
Share
More Decks by kohbis
See All by kohbis
『家族アルバム みてね』におけるAmazon EKSコストとの向き合い方 / Optimizing Amazon EKS Costs: The FamilyAlbum Case
kohbis
3
1.1k
潜在的課題探索活動の近況報告 / Exploration of latent challenges
kohbis
2
100
いま、あらためて考えてみるアカウント管理 with IaC / Account management with IaC
kohbis
3
920
〜『世界中の家族のこころのインフラ』を目指して”次の10年”へ〜 SREが導いたグローバルサービスの信頼性向上戦略とその舞台裏 / Towards the Next Decade: Enhancing Global Service Reliability
kohbis
4
4.2k
Grafana MCP serverでなんかし隊 / Try Grafana MCP server
kohbis
0
810
Custom Prometheus Exporterによる オブザーバビリティ拡張 / Extending observability with Custom Prometheus Exporter
kohbis
1
200
データベースで見る『家族アルバム みてね』の変遷 / The Evolution of Family Album Through the Lens of Databases
kohbis
5
1.4k
SREコミュニティイベントとわたし / Me and SRE community events
kohbis
2
270
悩ましきインシデント管理 みてねのケース / Incident management is a tough
kohbis
2
820
Featured
See All Featured
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
29
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
130
Code Reviewing Like a Champion
maltzj
527
40k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
Rails Girls Zürich Keynote
gr2m
95
14k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.3k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.3k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Context Engineering - Making Every Token Count
addyosmani
9
540
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.6k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
0
130
Transcript
サクッと試す Kubernetes APM auto-attach @kohbis New Relic User Group Vol.12
3周年&アドカレLT祭り 2024/12/20
About Me Kohei SUGIMOTO • toC向けサービスのSRE • mixi2/X: @kohbis (sushimoto)
2025年1月26日(日)に『 SRE Kaigi 2025』(オフラインカンファレンス)を開催! 参加チケット絶賛発売中!!!!!
Topic New Relic Advent Calendar 2024 シリーズ1の3日目を担当しました ✍ https://fushagoya.com/posts/2024/12/03/newrelic-kubernetes-apm-auto-attach/
New Relic Kubernetes APM auto-attachとは 🤔
New Relic Kubernetes APM auto-attachとは KubeCon North America (2024) で発表されたKubernetes向けのワンステップオブザーバビリティ
• Introducing one-step observability for Kubernetes to deliver automatic instrumentation and insights - The New Relic Blog • Kubernetesクラスター上にデプロイされたアプリケーションに対して New Relic APMの計装 (Instrumentation)を自動で行う ◦ 通常はエージェントライブラリのインストールなどコンテナやアプリケーションの実装が必要 ◦ 2024年12月現在のサポート対象 ▪ dotnet / java / nodejs / python / ruby / php
サクッと試してみる 🧪
事前準備 • New Relicアカウント の作成 • New Relicライセンスキー の発行 •
Ruby on Railsアプリケーション の準備 ◦ rails new train-rails --api --minimal ◦ コンテナイメージをビルドして任意のレジストリにpush ◦ Deploymentを作成(namespace: station, label: app=train)
環境とか • たまたまおうちにあったKubernetesクラスター ◦ ミニPC*1台 + Raspberry Pi 3*2台, 4*1台,
5*1台 ◦ Kubernetes 1.31 with Kubeadm • Ruby 3.3 & Rails 8.0 • New Relic 無料枠
ドキュメント Kubernetes APM auto-attach - New Relic Docsにしたがって進める • https://docs.newrelic.com/docs/kubernetes-pixie/kubernetes-integration/installation
/k8s-agent-operator/
インストール • nri-bundleの(一部として)インストール • スタンドアロンでインストール 👈 今回はこっち のいずれか
自動計装 カスタムリソースを作成 & Pod(Deployment)再起動 kubectl rollout restart deployment train -n
station するだけ
動作確認
簡単👏
もうちょっと見てみる 👀
前提:Kubernetes Operator • Kubernetes自体のコードを変更を必要とせずに機能拡張する仕組み ◦ https://kubernetes.io/ja/docs/concepts/extend-kubernetes/operator/ • カスタムリソース( CRD)とカスタムコントローラー によって、任意の運用を自動化できる
k8s-agent-operatorによって (条件に一致する) Podが起動したら、 Instrumentaion(CRD)にしたがって New Relic Agent(APM)を計装する という作業が自動化されている(雑な説明)
計装の流れ(1/2) (Operatorインストール済み&Instrumentationカスタムリソース作成済み) 👇 KubernetesのMutating Admission Webhookを使用してPodの作成を検知 https://github.com/newrelic/k8s-agents-operator/blob/main/src/internal/webhookhandler/webhookhandler.go 👇 Instrumentationの定義に一致しているか確認 https://github.com/newrelic/k8s-agents-operator/blob/main/src/instrumentation/podmutator.go
👇 各言語に対応したInject(注入) https://github.com/newrelic/k8s-agents-operator/tree/main/src/apm
計装の流れ(2/2) 👇 Rubyの場合 Rubyエージェントイメージ(newrelic_rpm gemがインストールされている)を PodのinitContainerとして起動 https://github.com/newrelic/newrelic-ruby-agent 👇 initContainerからメインのアプリケーションコンテナ( Rails)にエージェントファイル群をコピー
&環境変数などの設定を 注入 https://github.com/newrelic/k8s-agents-operator/blob/main/src/apm/ruby.go 👇 環境変数RUBYOPTS=-r /newrelic-instrumentation/lib/boot/strapによってRailsアプリケーションが起動するときに New Relic Agentが自動的にロードされる 🚀アプリケーションにまったく手を加えずに New Relic APMが導入される🚀
所感 📝
所感 New Relic Kubernetes APM auto-attachを導入するメリットとして考えられるもの • アプリケーションのコードを変更する必要がない • アプリケーションごとにエージェントをインストールする手間が省ける
• アプリケーションごとにエージェントのバージョンや設定を管理する必要がない • クラスター全体で一括管理できるため、 網羅的にAPMを導入できる Kubernetesクラスター上にたくさんのアプリケーションがある、プラットフォームとして提供してい ると活躍しそう(?)
ありがとうございました 🙇