Add Node.js agent in Kubernetes via InitContainers (using prebuilt agent image)
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:4.8.0
- 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>"
- volumeMounts:
- - mountPath: /apm
- name: app-volume
For applications using the PM2 process manager instead of Kubernetes, enable PM2 support by adding the following in the env section of your deployment YAML:
- - name: APMINSIGHT_PROCESS_MANAGER
- value: "true"
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:4.8.0
- 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>"
- volumeMounts:
- - mountPath: /apm
- name: app-volume
- volumes:
- - name: app-volume
- emptyDir: {}
Related Articles
Monitor and validate DNS IP changes using regex
DNS administrators often monitor their DNS servers to detect changes in domain resolution and ensure IP mappings remain secure and accurate. Problem When your organization adds or modifies an IP address for your domain name, it’s critical to: Be ...
Accessing products via Site24x7
You can seamlessly access ManageEngine CloudSpend and Site24x7’s sub-products, like Digital Risk Analyzer, StatusIQ, and Toolset, from within your Site24x7 web client. The product switcher , available at the top-right corner of the interface, lets ...
How do I check if URL redirection works correctly using the Website Monitor?
A webpage can be made available from more than a single web address using URL redirection. Most redirects are automated and it becomes difficult to track if the redirection works in a specific way. This can be verified using website monitoring in ...
Validating sender email using DKIM authentication
What is DKIM? DomainKeys Identified Mail (DKIM) is an advanced authentication method used widely by email service providers to verify the email from the point of its origin by validating the email sender. It allows the email senders to authenticate ...
Compare our various methodologies for Website Monitoring
Get to know Site24x7 monitors better and choose the one that best fits your monitoring needs. Compare the functionality of the following monitors: Website Monitoring Webpage Speed (Browser) Web Transaction Monitoring Web Transaction (Browser) SSL/TLS ...