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
360
サクッと試す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
Custom Prometheus Exporterによる オブザーバビリティ拡張 / Extending observability with Custom Prometheus Exporter
kohbis
1
110
データベースで見る『家族アルバム みてね』の変遷 / The Evolution of Family Album Through the Lens of Databases
kohbis
5
1.2k
SREコミュニティイベントとわたし / Me and SRE community events
kohbis
1
180
悩ましきインシデント管理 みてねのケース / Incident management is a tough
kohbis
2
760
サービス成長と共に肥大化するモノレポ、長くなる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.1k
『家族アルバム みてね』の安定リリースを支えるEKS運用 / FamilyAlbum release-flow on EKS
kohbis
2
1.6k
『家族アルバム みてね』 AWSマルチリージョン構成における データベース運用 / FamilyAlbum Database in AWS multi-region
kohbis
5
3.1k
Featured
See All Featured
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
25
2.8k
VelocityConf: Rendering Performance Case Studies
addyosmani
329
24k
Code Reviewing Like a Champion
maltzj
523
40k
The Language of Interfaces
destraynor
158
25k
Music & Morning Musume
bryan
47
6.6k
Become a Pro
speakerdeck
PRO
28
5.4k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
We Have a Design System, Now What?
morganepeng
52
7.6k
BBQ
matthewcrist
88
9.7k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.9k
Optimising Largest Contentful Paint
csswizardry
37
3.3k
Rebuilding a faster, lazier Slack
samanthasiow
81
9k
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クラスター上にたくさんのアプリケーションがある、プラットフォームとして提供してい ると活躍しそう(?)
ありがとうございました 🙇