Pod Watcher is a simple program to monitor Kubernetes pods and log their events such as creation, deletion, and updates.
- Logs pod creation, deletion, and updates.
- Option to print detailed pod object information.
- Filters pods based on namespace and label selector.
- Go 1.22 or later
- Kubernetes cluster
- kubeconfig file for authentication (if running outside a cluster)
-
Clone the repository:
git clone https://github.com/OsmanTunahan/pod-watcher.git cd pod-watcher
-
Build the project:
go build -o pod-watcher
--kubeconfig
(string): Absolute path to the kubeconfig file (optional if running inside a cluster).--namespace
(string): Namespace to watch (default: all namespaces).--details
(bool): Print detailed pod object information (default: false).--selector
(string): Label selector to filter pods (default: "foo=bar,baz=quux").
-
Ensure you have access to your Kubernetes cluster either by running inside the cluster or by providing a valid
kubeconfig
file. -
Run the program:
./pod-watcher --kubeconfig=~/.kube/config --namespace=default --details=true --selector="app=testk8sapp"
To watch all pods in the default
namespace with detailed logging enabled:
./pod-watcher --namespace=default --details=true