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
400
サクッと試す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
〜『世界中の家族のこころのインフラ』を目指して”次の10年”へ〜 SREが導いたグローバルサービスの信頼性向上戦略とその舞台裏 / Towards the Next Decade: Enhancing Global Service Reliability
kohbis
3
2.1k
Grafana MCP serverでなんかし隊 / Try Grafana MCP server
kohbis
0
540
Custom Prometheus Exporterによる オブザーバビリティ拡張 / Extending observability with Custom Prometheus Exporter
kohbis
1
140
データベースで見る『家族アルバム みてね』の変遷 / The Evolution of Family Album Through the Lens of Databases
kohbis
5
1.3k
SREコミュニティイベントとわたし / Me and SRE community events
kohbis
2
240
悩ましきインシデント管理 みてねのケース / Incident management is a tough
kohbis
2
800
サービス成長と共に肥大化するモノレポ、長くなるCI時間 / As services grow, monorepos get bigger and CI time gets longer
kohbis
5
3.2k
そこまで大規模じゃない EKS環境を(あまり)頑張らずに 最新化し続けたい / FamilyAlbum EKS Continuous Improvement
kohbis
2
1.8k
1,800万人が利用する『家族アルバム みてね』におけるK8s基盤のアップグレード戦略と継続的改善 / FamilyAlbum's upgrade strategy and continuous improvement for K8s infrastructure
kohbis
5
4.3k
Featured
See All Featured
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
47
9.6k
It's Worth the Effort
3n
185
28k
Product Roadmaps are Hard
iamctodd
PRO
54
11k
A Tale of Four Properties
chriscoyier
160
23k
How to train your dragon (web standard)
notwaldorf
96
6.2k
Building a Modern Day E-commerce SEO Strategy
aleyda
43
7.4k
Typedesign – Prime Four
hannesfritz
42
2.7k
Making the Leap to Tech Lead
cromwellryan
134
9.5k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Being A Developer After 40
akosma
90
590k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
161
15k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
22
1.4k
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クラスター上にたくさんのアプリケーションがある、プラットフォームとして提供してい ると活躍しそう(?)
ありがとうございました 🙇