NAME

kube_watch - Watch Kubernetes resources for changes

VERSION

version 1.001

SYNOPSIS

# Watch all pods in a namespace
kube_watch Pod -n default

# Watch only deletions
kube_watch Pod -n kube-system -T DELETED

# Watch deployments with a label selector
kube_watch Deployment -n production -l app=web

# Filter by name regex
kube_watch Pod -n default -N 'nginx.*'

# JSON output for piping
kube_watch Pod -o json | jq '.object.metadata.name'

# Watch cluster-scoped resources
kube_watch Node
kube_watch Namespace

DESCRIPTION

kube_watch connects to a Kubernetes cluster and watches for changes to resources of a given type. Events are printed as they arrive in real-time. The watch automatically restarts when the server-side timeout expires, and handles 410 Gone errors by re-listing.

NAME

kube_watch - Watch Kubernetes resources for changes

OPTIONS

-n, --namespace=NAME

Watch resources in this namespace. Omit for cluster-scoped resources.

-l, --label=SELECTOR

Label selector to filter resources (e.g., app=web,env=prod).

-f, --field=SELECTOR

Field selector to filter resources (e.g., status.phase=Running).

-T, --event_type=TYPES

Comma-separated list of event types to show. Valid types: ADDED, MODIFIED, DELETED, BOOKMARK, ERROR. By default all types are shown.

-N, --names=REGEX

Perl regex to filter by resource name. Only events for resources whose name matches will be printed.

-t, --timeout=SECONDS

Server-side timeout per watch cycle in seconds. Default: 300. The watch automatically restarts after each cycle.

-o, --output=FORMAT

Output format: text (default), json, or yaml.

text prints a human-readable line per event. json prints one JSON object per line (NDJSON), useful for piping to jq.

-F, --timestamp_format=FORMAT

Timestamp format for text output. Options:

datetime  2025-02-12 14:23:01  (default)
date      2025-02-12
time      14:23:01
epoch     1707745381
iso       2025-02-12T14:23:01+0100
-c, --context=NAME

Kubernetes context to use from the kubeconfig.

--kubeconfig=PATH

Path to kubeconfig file. Defaults to ~/.kube/config.

TEXT OUTPUT FORMAT

TIMESTAMP            TYPE        NAME                                                STATUS
2025-02-12 14:23:01  ADDED       default/nginx-abc123                                Running
2025-02-12 14:23:01  MODIFIED    default/nginx-abc123                                Succeeded
2025-02-12 14:23:05  DELETED     default/nginx-abc123

SEE ALSO

Kubernetes::REST, "watch" in Kubernetes::REST, Kubernetes::REST::CLI::Watch, kube_client

SUPPORT

Issues

Please report bugs and feature requests on GitHub at https://github.com/pplu/kubernetes-rest/issues.

IRC

Join #kubernetes on irc.perl.org or message Getty directly.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHORS

  • Torsten Raudssus <torsten@raudssus.de>

  • Jose Luis Martinez Torres <jlmartin@cpan.org> (JLMARTIN, original author, inactive)

COPYRIGHT AND LICENSE

This software is Copyright (c) 2019 by Jose Luis Martinez.

This is free software, licensed under:

The Apache License, Version 2.0, January 2004