This is a simple tool to check if the user defined in a given kube config can connect to the given cluster. The results are stored in a simple text file in the operating system's temporary directory for fast retrieval.
This is a Zig port of the original Python implementation, providing better performance and no runtime dependencies.
Clone the repository and build with Zig:
git clone <repository-url>
cd cluster_ping
zig buildThe binary will be available at zig-out/bin/cluster_ping.
You can install the binary to your system PATH:
zig build --prefix ~/.local # Install to ~/.local/bin
# Or copy manually:
cp zig-out/bin/cluster_ping ~/.local/bin/The tool requires the following external commands to be available:
kubectl- for testing cluster connectivityyq- for parsing YAML kubeconfig files
cluster_ping --helpThis will display the help information.
To test connectivity to a cluster and store the result:
cluster_ping check <path/to/kube/config> <context-name>To check if there's recent connectivity data (within 300 seconds by default):
cluster_ping validate <path/to/kube/config> <context-name>You can specify a custom timeout in seconds:
cluster_ping validate <path/to/kube/config> <context-name> 600See examples/current_cluster.fish for an example of how to integrate this into a Fish shell prompt. The script:
- Runs connectivity checks in the background
- Provides colored output based on connection status
- Shows cluster information in shell prompts
For detailed usage instructions and additional examples, see the examples directory.
Build the project:
zig buildRun the unit tests:
zig build testRun the application directly:
zig build run -- check ~/.kube/config my-clusterThe change log is managed by towncrier.
The project uses standard Zig formatting. Format code with:
zig fmt src/-
Check Command:
- Prevents duplicate processes from running
- Parses the kubeconfig file (YAML → JSON via
yq) - Validates the user configuration
- Tests connectivity using
kubectl version - Stores results with timestamps in
/tmp/cluster_ping
-
Validate Command:
- Reads stored connectivity data
- Checks if the data is recent (within specified delay)
- Returns connection status and data freshness
The tool stores connectivity results in a simple format in /tmp/cluster_ping, allowing for fast retrieval without repeated kubectl calls.
The validate command outputs:
connected=<true|false> recent=<true|false>
This format is designed for easy parsing in shell scripts and prompt integrations.