Skip to content

Instantly share code, notes, and snippets.

@jmarhee
Created September 18, 2025 19:10
Show Gist options
  • Save jmarhee/5a485607631e8b94d1f87a34bb3196d0 to your computer and use it in GitHub Desktop.
Save jmarhee/5a485607631e8b94d1f87a34bb3196d0 to your computer and use it in GitHub Desktop.
#!/bin/bash
KUBECONFIG_DIR=$HOME/.kube
mkdir -p "$KUBECONFIG_DIR"
clusters=$(rancher clusters ls --format '{{.Cluster.Name}}')
for cluster in $clusters; do
echo "Downloading kubeconfig for cluster: $cluster"
rancher clusters kubeconfig "$cluster" > "$KUBECONFIG_DIR/$cluster-kubeconfig.yaml"
echo "Kubeconfig for $cluster saved to $KUBECONFIG_DIR/$cluster-kubeconfig.yaml"
done
echo "All kubeconfigs have been downloaded."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment