In this cookbook a Java web app (Spring PetClinic) is containerized with the APM agentless for Java (the APM Java agent library for Linux), and deployed along with a PostgreSQL database on the Linux node pool of a Google Kubernetes Engine.
With this setup, the pods and nodes of the Kubernetes cluster can scaleout, the APM will collect every transaction.
-
a SaaS account for APM
-
a project in Google Cloud configured for billing and having Kubernetes setup (Linux node pool and Artifact registry)
-
Click on the button to open the cookbook in the Google Cloud Shell
In the APM webconsole, navigate to CONFIGURE > AGENTS > Install Agents and in the Agent Installation Steps section,
- Find your Customer Id, for example 12341234-12341234-13241234
- Find the SaaS Analysis Server Host and obtain the SaaS Psockets Server host replacing agents by psockets. For example if the analysis server host is agents.apm.my_environment.aternity.com then the SaaS Psockets Server host is psockets.apm.my_environment.aternity.com
- Download the package APM Agentless Instrumentation (Java) (also available on Riverbed support, for example aternity-apm-jida-linux-12.19.0_BL516
In the Google Cloud Console retrieve the details of the project and resources ready to use:
- Project id, for example: aternity-cookbooks
- Kubernetes Engine cluster name, for example: autopilot-cluster-1
- Region, for example: europe-west9
- Artifact Registry repository name, for example: apm
- Bucket name, for example: my_bucket
⚠️ The repository must be created with Docker format and preferably in the same region as the GKE cluster
In the Google Cloud Console, navigate to the Cloud Storage . then select the GCP project and the Bucket.
There, upload the .zip package of the APM Agentless Instrumentation (Java) and grab the gsutil URI for the next steps, for example gs://my_bucket/aternity-apm-jida-linux-12.19.0_BL516.zip
In the Cloud Shell terminal, run the commands to go to the cookbook folder, select the project (replacing {PROJECT_ID} with the actual value) and configure kubectl to control the cluster
cd 233-instrument-java-app-with-apm-agentless-on-gke
gcloud config set project {PROJECT_ID}
gcloud container clusters get-credentials {CLUSTER NAME} --region {REGION} --project {PROJECT_ID}
For example
cd 233-instrument-java-app-with-apm-agentless-on-gke
gcloud config set project aternity-cookbooks
gcloud container clusters get-credentials autopilot-cluster-1 --region europe-west9 --project aternity-cookbooks
Run the command to build the image, replacing the actual values in the substitutions parameter.
gcloud builds submit --config cloudbuild.yaml --substitutions _APM_PACKAGE_GSUTIL_URI={_APM_PACKAGE_GSUTIL_URI},_REGION={_REGION},_REPOSITORY={REPOSITORY}
Where:
- {_APM_PACKAGE_GSUTIL_URI}: the gsutil URI of the APM Java library package
- {_REGION}: the region of the Artifact Registry
- {_REPOSITORY}: the name of the Artifact Registry repository
For example
gcloud builds submit --config cloudbuild.yaml --substitutions _APM_PACKAGE_GSUTIL_URI=gs://my_bucket/aternity-apm-jida-linux-12.19.0_BL516.zip,_REGION=europe-west9,_REPOSITORY=apm
Based on the Dockerfile, it is building a Docker image that will contain the Java application and the APM Java agent library for Linux. When the build is done, the image will be stored in the Artifact Registry.
With the Cloud Shell Editor, edit the Kubernetes manifest app-k8s.yaml to configure the environment variables of your APM SaaS account and also the path of the image we just built:
- Customer Id in the variable RVBD_CUSTOMER_ID, for example 12341234-12341234-13241234
- SaaS Psockets Server host in the variable RVBD_ANALYSIS_SERVER, for example psockets.apm.my_environment.aternity.com
- Image Path in the deployment section replacing the token {cookbook-233 image}, for example: europe-west9-docker.pkg.dev/aternity-cookbooks/apm/cookbook-233:latest
In the Cloud Shell Terminal, execute the following command to deploy the application on Kubernetes.
kubectl apply -f app_k8s.yaml
After few minutes, execute the following command to get the external ip address of the load-balancer created for the app.
kubectl --namespace cookbook-233 get svc
In your web browser, open the http url using the external IP address, for example http://external-ip-address, and navigate in the app to generate some traffic and application transactions.
Go to the APM webconsole to observe the application, every instance and every transaction.
Run the command to delete the application
kubectl delete -f app_k8s.yaml
Copyright (c) 2022 Riverbed
The contents provided here are licensed under the terms and conditions of the MIT License accompanying the software ("License"). The scripts are distributed "AS IS" as set forth in the License. The script also include certain third party code. All such third party code is also distributed "AS IS" and is licensed by the respective copyright holders under the applicable terms and conditions (including, without limitation, warranty and liability disclaimers) identified in the license notices accompanying the software.