How to add an APM Insight Node.js agent in Kubernetes via InitContainers?
To integrate the APM Insight Node.js agent into your Kubernetes applications using InitContainers, follow the steps given below:
Step 1:
Create an empty volume that will be used to copy the agent files during the initContainers process.
Example:
- volumes:
- - name: app-volume
Step 2:
Include the following initContainers command in your helm chart/deployment YAML file.
- initContainers:
- - name: init-npm
- image: site24x7/apminsight-nodejsagent:latest
- imagePullPolicy: IfNotPresent
- command: ['cp', '-r', '/opt/site24x7/.', '/apm']
- volumeMounts:
- - name: app-volume
- mountPath: /apm
Step 3:
Mount the volume created in step 2 into your application container.
Example:
- containers:
- env:
- - name: NODE_OPTIONS
- value: "--require /apm/node_modules/apminsight"
- - name: APMINSIGHT_LICENSE_KEY
- value: "<license-key>"
- - name: APMINSIGHT_APP_NAME
- value: "<application-name>"
- - name: APMINSIGHT_APP_PORT
- value: "<application-port>"
- - name: APMINSIGHT_APM_HOST
- value: "<manageengine-applications-manager-server-host>"
- - name: APMINSIGHT_APM_PORT
- value: "<manageengine-applications-manager-server-port>"
- volumeMounts:
- - mountPath: /apm
- name: app-volume
Example YAML deployment file for your reference:
- apiVersion: apps/v1
- kind: Deployment
- metadata:
- name: sample-deployment
- spec:
- replicas: 1
- selector:
- matchLabels:
- app: sample-app
- template:
- metadata:
- labels:
- app: sample-app
- spec:
- initContainers:
- - name: init-npm
- image: site24x7/apminsight-nodejsagent:latest
- imagePullPolicy: IfNotPresent
- command: ['cp', '-r', '/opt/site24x7/.', '/apm']
- volumeMounts:
- - name: app-volume
- mountPath: /apm
- containers:
- - name: main-container
- image: myrepository/sample-nodejs-app:latest
- env:
- - name: NODE_OPTIONS
- value: "--require /apm/node_modules/apminsight"
- - name: APMINSIGHT_LICENSE_KEY
- value: "<license-key>"
- - name: APMINSIGHT_APP_NAME
- value: "<application-name>"
- - name: APMINSIGHT_APP_PORT
- value: "<application-port>"
- - name: APMINSIGHT_APM_HOST
- value: "<manageengine-applications-manager-server-host>"
- - name: APMINSIGHT_APM_PORT
- value: "<manageengine-applications-manager-server-port>"
- volumeMounts:
- - mountPath: /apm
- name: app-volume
- volumes:
- - name: app-volume
- emptyDir: {}
New to ADSelfService Plus?
Related Articles
How to add an APM Insight Java agent in Kubernetes via InitContainers?
Step 1. Create a secret to access the APM Insight license key in your application namespace: kubectl create secret generic app-secret --from-literal=s247licensekey='your_APMInsight_license_key' -n petclinic The license key can be obtained from the ...
Adding APM Insight Java agent in a Kubernetes environment
There are three methods for installing the APM Insight Java agent in a Kubernetes environment: Using Dockerfile Using InitContainers Using Persistent Volumes Prerequisites Download the latest APM Insight Java agent ZIP file. Extract the ZIP file and ...
Uninstrumented Block of Code - APM Insight
In the traces tab --> Slowest Method Calls and Count we show if you find Un-instrumented block of code the reason is as follows: Basically, What is un-instrumented block of code in APM Insight? By default, APM Insight agent monitors known frameworks ...
Unable to Add Kubernetes Monitor
If you are having trouble adding a Kubernetes monitor in Applications Manager, ensure that the the prerequisites have been met: Verify whether you can establish an SSH connection to the Kubernetes server from the APM installed machine. Use the ...
APM Insight Java agent setup in K8s via Persistent Volumes
Prerequisites 1. A persistent volume (with a capacity of 100mb). 2. The persistent volume mounted on all deployment pods (via persistent volume claim). 3. The Applications Manager APM Insight Java agent zip file was downloaded, moved, and extracted ...