To monitor PHP applications deployed in Kubernetes using Applications Manager, both the APM Insight PHP Agent and the Applications Manager Data Exporter must be configured inside your pods. This can be accomplished by using init containers to copy the necessary agent files before the main application starts.
Create a shared volume that will be used by the init container to extract the agent files and make them accessible to the main application container.
volumes:
- name: apminsight-volume Use an init container to extract the APM Insight PHP Agent into the shared volume.
initContainers:
- name: init-apminsight
image: site24x7/apminsight-phpagent:latest
imagePullPolicy: Always
command: ["unzip", "/opt/apminsight.zip", "-d", "/opt"]
volumeMounts:
- name: apminsight-volume
mountPath: /opt/apminsight Mount the volume in your PHP application container, set environment variables, and run the installation script during the container’s lifecycle using the postStart hook.
containers:
- name: php-app
image: my-php-app:8.2-alpine3.18-apache
lifecycle:
postStart:
exec:
command: ["/bin/sh", "-c", "chmod +x /apm/DockerInstallAgentPHP.sh && /apm/DockerInstallAgentPHP.sh && kill -USR1 1"]
env:
- name: APPMANAGER_LICENSE_KEY
value: "your-license-key"
- name: ZPA_APPLICATION_NAME
value: "name-for-your-application"
- name: APM_HOST
value: "https:<apm_host>/<apm_port>"
ports:
- containerPort: 80
volumeMounts:
- mountPath: /apm
name: apminsight-volume The following is an example YAML configuration for deploying a PHP application integrated with the APM Insight PHP Agent and Applications Manager Data Exporter.
apiVersion: apps/v1
kind: Deployment
metadata:
name: php-app
spec:
selector:
matchLabels:
app: php-app
template:
metadata:
labels:
app: php-app
spec:
volumes:
- name: apminsight-volume
initContainers:
- name: init-apminsight
image: site24x7/apminsight-phpagent:latest
imagePullPolicy: Always
command: ["unzip", "/opt/apminsight.zip", "-d", "/opt"]
volumeMounts:
- name: apminsight-volume
mountPath: /opt/apminsight
containers:
- name: php-app
image: my-php-app:8.2-alpine3.18-apache
lifecycle:
postStart:
exec:
command: ["/bin/sh", "-c", "chmod +x /apm/DockerInstallAgentPHP.sh && /apm/DockerInstallAgentPHP.sh && kill -USR1 1"]
env:
- name: APPMANAGER_LICENSE_KEY
value: "your-license-key"
- name: ZPA_APPLICATION_NAME
value: "name-for-your-application"
- name: APM_HOST
value: "https:<apm_host>/<apm_port>"
ports:
- containerPort: 80
volumeMounts:
- mountPath: /apm
name: apminsight-volume apiVersion: v1
kind: Service
metadata:
name: php-app-service
spec:
type: NodePort
selector:
app: php-app
ports:
- port: 8080
targetPort: 80
nodePort: 31000
Thank you for your feedback!