This directory contains example integrations and usage patterns for cluster_ping.
This Fish shell function demonstrates how to integrate cluster_ping into your shell prompt to display real-time Kubernetes cluster connectivity status.
- Detects active kubeconfig: Uses the
$KUBECONFIGenvironment variable or defaults to~/.kube/config - Gets current context: Extracts the current context and cluster name from the kubeconfig
- Runs background connectivity check: Executes
cluster_ping checkin the background to test connectivity - Validates recent results: Uses
cluster_ping validateto check if recent connectivity data exists - Provides colored output: Returns color-coded cluster information for shell prompts
- 🟢 Magenta: Connected and recent data (active connection)
- ⚫ Black: Not connected but recent check (inactive connection)
- 🟡 Yellow: Stale or no recent data (unknown status)
Source this function in your Fish config:
# In ~/.config/fish/config.fish
source /path/to/examples/current_cluster.fish
# Then use in your prompt function
function fish_prompt
# Your existing prompt...
echo (current_cluster)
# Rest of your prompt...
end- Delay: Default 300 seconds (5 minutes) for data freshness
- File prefix: Shows config file path when using custom
$KUBECONFIG - Error handling: Returns non-zero exit code if kubeconfig file doesn't exist
cluster_pingbinary in PATHyqfor YAML parsing- Fish shell 3.0+
This integration allows you to see your current Kubernetes cluster status directly in your shell prompt, with efficient caching to avoid repeated kubectl calls.