LoginSignup
0
0

More than 1 year has passed since last update.

New Relic Installation (Kubernetes integration)

Last updated at Posted at 2021-09-10

ゴール

  • Kubernetes向けのNew Relic Agentを導入する
  • 取れる情報を見る。

環境

  • Code Ready Container (OpenShift version 4.8.4) on RHEL 8.4
  • CPU 4, Memory 32GB, Disk 160GB(最近、もっとCPUがほしい。)

サンプルのアプリを浮かべる

どこまでの情報が拾えるかわからないので、Javaのサンプルアプリを浮かべておく。
まず、odoをインストールする。

$ curl -L https://mirror.openshift.com/pub/openshift-v4/clients/odo/latest/odo-linux-amd64 -o /usr/local/bin/odo
$ chmod +x /usr/local/bin/odo

Springのpetclinicアプリを用意する。

$ sudo yum -y install git
$ sudo yum -y install maven
$ git clone https://github.com/spring-projects/spring-petclinic.git
$ cd spring-petclinic/
$ mvn package

odoを使って浮かべる。

$ odo create java petclinic --s2i --binary target/*.jar
$ odo push

newrelicのサービスアカウントを特権モードに

oc adm policy add-scc-to-user privileged \
system:serviceaccount:newrelic:nri-bundle-newrelic-infrastructure

New Relicをインストール

ウィザードに従ってすすめる。まず、Kubernetesから、Deploy the integrationを押下。

image.png

Cluster namenamespaceを入力

  • Cluster name
    • crc
  • namespace
    • newrelic

かき集めたいデータを選択する。とりあえずデフォルトで。

  • Select the data you want to gather
    • Kube state metrics
    • Prometheus metrics
    • Kubernetes events
    • Log data
    • Set up for unprivileged mode
    • Instant service-level insights, full-body requests, and application profiles through Pixie
    • Pixie is already running in this cluster

Pixieとは、eBPFでデータかっさらってくる実装の模様。すごヨ。また調べよう。

Pixie uses eBPF to automatically detect any HTTP-based services in this cluster and gather data.
For even deeper insights, you can add language agents to individual services.

実行可能なコマンドリストがもらえる。やったー。

kubectl apply -f https://raw.githubusercontent.com/pixie-labs/pixie/main/k8s/operator/crd/base/px.dev_viziers.yaml && \
kubectl apply -f https://raw.githubusercontent.com/pixie-labs/pixie/main/k8s/operator/helm/crds/olm_crd.yaml && \
kubectl create namespace newrelic ; kubectl apply -f <PATH_TO_DOWNLOADED_FILE>

上述の<PATH_TO_DOWNLOADED_FILE>に埋める、Manifestももらえる。やったー。

$ head ~/newrelic-manifest.yaml 
---
# Source: nri-bundle/charts/newrelic-infrastructure/templates/clusterrolebinding.yaml

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  labels:     
    app: newrelic-infrastructure
    chart: newrelic-infrastructure-2.6.2
    release: nri-bundle

kubectlocに読み替えながら実行する。
invalidなエラーがでる。

$ oc apply -f https://raw.githubusercontent.com/pixie-labs/pixie/main/k8s/operator/crd/base/px.dev_viziers.yaml
customresourcedefinition.apiextensions.k8s.io/viziers.px.dev created
$ oc apply -f https://raw.githubusercontent.com/pixie-labs/pixie/main/k8s/operator/helm/crds/olm_crd.yaml
...snip...
The CustomResourceDefinition "operatorconditions.operators.coreos.com" is invalid: status.storedVersions[0]: Invalid value: "v2": must appear in spec.versions

エラー内容に則って、書き換える。

$ diff olm_crd.yaml.org olm_crd.yaml.mod 
5294c5294
<     - name: v1
---
>     - name: v2

流し直す。クリア。

$ oc apply -f ./olm_crd.yaml

仕上げのManifestもapplyする。エラーがでる。

$ oc create namespace newrelic ; oc apply -f newrelic-manifest.yaml 
...snip...
operatorgroup.operators.coreos.com/global-operators created
Error from server (NotFound): error when creating "newrelic-manifest.yaml": namespaces "px-operator" not found
Error from server (NotFound): error when creating "newrelic-manifest.yaml": namespaces "px-operator" not found

エラーの内容に則って、コマンドを実行する。クリア。

$ oc create namespace px-operator ; oc create namespace newrelic ; oc apply -f newrelic-manifest.yaml
...snip...

以上でインストール完了の模様。Pixieでこんなことできるよ!的なことが書いてある。
APM入れなくてもできるってこと?結構すごくね?

Pixie: get ready for next-gen K8s observability!

  • Measure application performance without agents
    • Auto-telemetry with Pixie provides deep, baseline visibility into your system. No code changes or redeployments required.
  • Get code-level insights
    • Flame graphs help you understand where and why your code is slow.
  • Debug faster
    • Drill down into your services with raw requests and service maps to debug production issues without modifying source code.

マシンが非力な所為か、少し時間がかかってそうなので、放置。
うまくいってたら、明日データを覗いてみる。

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0