A tool to automatically update Kubernetes certificate data in your kubeconfig file by connecting to each cluster and fetching the latest credentials.
This tool helps maintain your Kubernetes configurations by:
- Scanning your
~/.kube/config
file for all contexts - Connecting to each Kubernetes cluster via SSH
- Fetching the latest certificate data from
/etc/kubernetes/admin.conf
- Updating your local kubeconfig with the new credentials
- Saving SSH usernames for future use
Install with uv tool install
:
uv tool install git+https://github.com/jcppkkk/update-kube-config.git
Simply run:
uvx --from git+https://github.com/jcppkkk/update-kube-config.git update-kube-config
or install the tool and run:
uv tool install git+https://github.com/jcppkkk/update-kube-config.git
update-kube-config
The tool will:
- Create a backup of your existing kubeconfig
- Process each context in your kubeconfig
- Connect to each cluster's server
- Update certificate data as needed
When connecting to a server for the first time, you'll be prompted for:
- SSH username for the server
- Sudo password (if required to read admin.conf)
The SSH username is saved in your kubeconfig for future use under the cluster's serveruser
field.
- Creates automatic backups of your kubeconfig before making changes
- Uses SSH for secure remote connections
- Handles sudo access securely when required
- Stores credentials only in your kubeconfig file
- Python 3.8 or higher
- SSH access to your Kubernetes clusters
- Sudo privileges on remote servers (if required)
- Read access to
/etc/kubernetes/admin.conf
on remote servers
- ✅ Automatic certificate updates
- ✅ Multi-context support
- ✅ SSH username persistence
- ✅ Automatic kubeconfig backups
- ✅ Sudo handling when required
- ✅ Non-interactive mode after initial setup
If you encounter issues:
- Check SSH access to your clusters
- Verify sudo privileges if required
- Ensure
/etc/kubernetes/admin.conf
exists on the remote servers - Check the backup file at
~/.kube/config.bak
if needed
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License