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
0
530
サクッと試す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
Kubernetes環境周りの責任範囲をいい機会なので考える / Taking the Opportunity to Clarify Kubernetes Responsibilities
kohbis
2
320
『家族アルバム みてね』におけるAmazon EKSコストとの向き合い方 / Optimizing Amazon EKS Costs: The FamilyAlbum Case
kohbis
3
1.5k
潜在的課題探索活動の近況報告 / Exploration of latent challenges
kohbis
2
130
いま、あらためて考えてみるアカウント管理 with IaC / Account management with IaC
kohbis
3
990
〜『世界中の家族のこころのインフラ』を目指して”次の10年”へ〜 SREが導いたグローバルサービスの信頼性向上戦略とその舞台裏 / Towards the Next Decade: Enhancing Global Service Reliability
kohbis
4
5.6k
Grafana MCP serverでなんかし隊 / Try Grafana MCP server
kohbis
0
910
Custom Prometheus Exporterによる オブザーバビリティ拡張 / Extending observability with Custom Prometheus Exporter
kohbis
1
240
データベースで見る『家族アルバム みてね』の変遷 / The Evolution of Family Album Through the Lens of Databases
kohbis
5
1.5k
SREコミュニティイベントとわたし / Me and SRE community events
kohbis
2
290
Featured
See All Featured
Accessibility Awareness
sabderemane
0
82
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
760
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.7k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
160
Facilitating Awesome Meetings
lara
57
6.8k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
ラッコキーワード サービス紹介資料
rakko
1
2.7M
Visualization
eitanlees
150
17k
The Limits of Empathy - UXLibs8
cassininazir
1
260
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
110k
GraphQLとの向き合い方2022年版
quramy
50
14k
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クラスター上にたくさんのアプリケーションがある、プラットフォームとして提供してい ると活躍しそう(?)
ありがとうございました 🙇