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
サクッと試すNew Relic Kubernetes APM auto-attach / Ne...
Search
kohbis
December 20, 2024
770
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
サクッと試す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
More Decks by kohbis
See All by kohbis
『家族アルバム みてね』における インシデント対応との向き合い方 / Approach incident response in Family Album
kohbis
2
360
Kubernetes環境周りの責任範囲をいい機会なので考える / Taking the Opportunity to Clarify Kubernetes Responsibilities
kohbis
2
420
『家族アルバム みてね』におけるAmazon EKSコストとの向き合い方 / Optimizing Amazon EKS Costs: The FamilyAlbum Case
kohbis
4
1.7k
潜在的課題探索活動の近況報告 / Exploration of latent challenges
kohbis
2
170
いま、あらためて考えてみるアカウント管理 with IaC / Account management with IaC
kohbis
3
1.1k
〜『世界中の家族のこころのインフラ』を目指して”次の10年”へ〜 SREが導いたグローバルサービスの信頼性向上戦略とその舞台裏 / Towards the Next Decade: Enhancing Global Service Reliability
kohbis
4
7k
Grafana MCP serverでなんかし隊 / Try Grafana MCP server
kohbis
0
1k
Custom Prometheus Exporterによる オブザーバビリティ拡張 / Extending observability with Custom Prometheus Exporter
kohbis
1
300
データベースで見る『家族アルバム みてね』の変遷 / The Evolution of Family Album Through the Lens of Databases
kohbis
5
1.6k
Featured
See All Featured
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
650
Rails Girls Zürich Keynote
gr2m
96
14k
We Have a Design System, Now What?
morganepeng
55
8.2k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
55k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
320
ラッコキーワード サービス紹介資料
rakko
1
3.9M
Faster Mobile Websites
deanohume
310
32k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.7k
The Curious Case for Waylosing
cassininazir
1
430
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クラスター上にたくさんのアプリケーションがある、プラットフォームとして提供してい ると活躍しそう(?)
ありがとうございました 🙇