Skip to content

Monitoring pod activity in Kubernetes

paulalbert1 edited this page Apr 10, 2023 · 4 revisions

Monitoring pods in a Kubernetes environment can be tedious because new pods are routinely created and the names are unpredictable.

CloudWatch and the Kubernetes UI are always options, but they have certain drawbacks.

Here are some scripts for monitoring the activity of pods associated with a cron job and a deployment from the command line.

Prerequisites

Install kubectl and configure it to work with your Kubernetes instance.

Stream all active pods associated with a cron job

  1. Download this script.
  2. Update privileges: chmod +x streamLogsCronJob.sh.
  3. Update file with correct CRONJOB_NAME and NAMESPACE.
  4. Execute: ./streamLogsCronJob.sh

Stream all active pods associated with a deployment

  1. Download this script.
  2. Update privileges: chmod +x streamLogsDeployment.sh.
  3. Update file with correct DEPLOYMENT_NAME and NAMESPACE.
  4. Execute: ./streamLogsDeployment.sh