Monitoring Go applications in Kubernetes environment
Before you monitor Go applications in Kubernetes environment, you must connect the data collector to the server by creating a secret. Then, you update your application deployment to monitor the Go applications.
Before you begin
- Check whether your service account has access to Kubernetes resources. For more information, see Authorizing the data collector to access Kubernetes resources.
- Ensure that you downloaded the configuration package to obtain the server information. For more information, see Obtaining the server configuration information.
- Check whether you downloaded the Go data collector package from Passport Advantage. For more information, see Downloading the Go data collector.
About this task
To enable the Go data collector, you need to update the application code to import the Go data collector package, rebuild the application with the vendor files of the Go data collector, and create the secret based on the configuration package.
Procedure
-
Update the Go application by importing the Go data collector module in the application main file.
import ( _ "github.ibm.com/APM/godc" )
-
Rebuild the Go application with vendor files of the Go data collector.
-
Extract the Go data collector package file
go_datacollector.tgz
:tar xzf go_datacollector.tgz
-
Merge the vendor files with the vendor files of the application.
-
Build the application with new vendor files.
go build -mod=vendor
-
Create the Kubernetes secret based on the configuration package. Go to the
ibm-cloud-apm-dc-configpack
directory where you extract the configuration package in Obtaining the server configuration information, and run the following command to create a secret to connect to the server, for example, name it asicam-server-secret
.kubectl -n my_namespace create secret generic icam-server-secret \ --from-file=ibm-cloud-apm-dc-configpack/keyfiles/keyfile.jks \ --from-file=ibm-cloud-apm-dc-configpack/keyfiles/keyfile.p12 \ --from-file=ibm-cloud-apm-dc-configpack/keyfiles/keyfile.kdb \ --from-file=ibm-cloud-apm-dc-configpack/keyfiles/ca.pem \ --from-file=ibm-cloud-apm-dc-configpack/keyfiles/cert.pem \ --from-file=ibm-cloud-apm-dc-configpack/keyfiles/key.pem \ --from-file=ibm-cloud-apm-dc-configpack/global.environment
-
-
Update the application yaml file to mount the secret. See the following example.
apiVersion: extensions/v1beta1 kind: Deployment metadata: name: MyGoApp labels: app: MyGoApp spec: selector: matchLabels: app: MyGoApp pod: MyGoApp replicas: 1 template: metadata: name: MyGoApp labels: app: MyGoApp pod: MyGoApp spec: containers: - name: MyGoApp image: mycluster.icp:8500/default/MyGoApp:v1 imagePullPolicy: Always ports: - containerPort: 3000 protocol: TCP env: - name: APPLICATION_NAME value: "MyGoApp" volumeMounts: - name: global-environment mountPath: /opt/ibm/apm/serverconfig volumes: - name: global-environment secret: secretName: icam-server-secret optional: true
- Redeploy the Go application.