{"id":29439280,"url":"https://github.com/patricktrainer/kubeconfig-manager","last_synced_at":"2025-07-13T09:30:28.513Z","repository":{"id":302144949,"uuid":"1011404698","full_name":"patricktrainer/kubeconfig-manager","owner":"patricktrainer","description":"A CLI tool for managing Kubernetes configurations","archived":false,"fork":false,"pushed_at":"2025-06-30T19:43:51.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-30T20:38:47.729Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/patricktrainer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-30T19:05:02.000Z","updated_at":"2025-06-30T19:43:56.000Z","dependencies_parsed_at":"2025-06-30T20:38:49.588Z","dependency_job_id":"25174887-5e3d-471a-b15e-db25765ac20f","html_url":"https://github.com/patricktrainer/kubeconfig-manager","commit_stats":null,"previous_names":["patricktrainer/kubeconfig-manager"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/patricktrainer/kubeconfig-manager","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patricktrainer%2Fkubeconfig-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patricktrainer%2Fkubeconfig-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patricktrainer%2Fkubeconfig-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patricktrainer%2Fkubeconfig-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/patricktrainer","download_url":"https://codeload.github.com/patricktrainer/kubeconfig-manager/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patricktrainer%2Fkubeconfig-manager/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265119826,"owners_count":23714413,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-13T09:30:25.045Z","updated_at":"2025-07-13T09:30:28.507Z","avatar_url":"https://github.com/patricktrainer.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kubeconfig Manager\n\n🚀 A powerful CLI tool for managing Kubernetes configurations with profile support, interactive modes, and advanced safety features.\n\n## Features\n\n- 📁 **Profile Management** - Organize configurations by environment (dev, staging, prod)\n- 🔄 **Smart Merging** - Intelligently merge kubeconfig files with conflict detection\n- 🎯 **Interactive Mode** - Fuzzy search and guided context switching\n- 🔍 **Dry Run** - Preview changes before applying them\n- ⚡ **Conflict Resolution** - Handle duplicate contexts with user guidance\n- 📦 **Automatic Backups** - Never lose your configurations\n- ✅ **Validation** - Ensure your kubeconfig files are valid\n\n## Installation\n\n```bash\n# Make the script executable\nchmod +x kubeconfig-manager.py\n\n# Optionally, create a symlink for easier access\nln -s $(pwd)/kubeconfig-manager.py /usr/local/bin/kcman\n```\n\n## Quick Start\n\n```bash\n# View current profile and contexts\nkcman profile current\nkcman switch\n\n# Create a new profile for development\nkcman profile create dev --description \"Development environment\"\nkcman profile switch dev\n\n# Add a kubeconfig file with preview\nkcman add ~/.kube/new-cluster.yaml --dry-run\n\n# Add with interactive conflict resolution\nkcman add ~/.kube/new-cluster.yaml --interactive\n\n# Switch contexts interactively\nkcman switch --interactive\n```\n\n## Command Reference\n\n### Profile Management\n\n#### Create a Profile\n```bash\nkcman profile create \u003cprofile-name\u003e [--description \"Description\"]\n```\n\n#### List Profiles\n```bash\nkcman profile list\n```\n\n#### Switch Profile\n```bash\nkcman profile switch \u003cprofile-name\u003e\n```\n\n#### Show Current Profile\n```bash\nkcman profile current\n```\n\n#### Delete Profile\n```bash\nkcman profile delete \u003cprofile-name\u003e\n```\n\n### Configuration Management\n\n#### Add Kubeconfig\n```bash\n# Basic usage\nkcman add \u003cconfig-file\u003e\n\n# With options\nkcman add \u003cconfig-file\u003e [OPTIONS]\n  --profile, -p TEXT      Target profile\n  --target, -t PATH       Target config file\n  --dry-run              Preview changes only\n  --interactive, -i      Interactive conflict resolution\n  --backup/--no-backup   Create backup (default: yes)\n```\n\n#### Switch Context\n```bash\n# List available contexts\nkcman switch\n\n# Switch to specific context\nkcman switch \u003ccontext-name\u003e\n\n# Interactive context selection\nkcman switch --interactive\n\n# Switch in specific profile\nkcman switch \u003ccontext-name\u003e --profile \u003cprofile-name\u003e\n```\n\n#### List Contexts\n```bash\n# List contexts in current profile\nkcman list\n\n# List contexts in specific config\nkcman list --config \u003cconfig-file\u003e\n```\n\n### Backup \u0026 Restore\n\n#### List Backups\n```bash\nkcman backups\n```\n\n#### Restore from Backup\n```bash\nkcman restore \u003cbackup-name\u003e\n```\n\n### Validation\n\n#### Validate Configuration\n```bash\n# Validate current profile's config\nkcman validate\n\n# Validate specific file\nkcman validate --config \u003cconfig-file\u003e\n```\n\n## Usage Examples\n\n### Setting Up Multiple Environments\n\n```bash\n# Create profiles for different environments\nkcman profile create development --description \"Dev clusters\"\nkcman profile create staging --description \"Staging environment\"\nkcman profile create production --description \"Production clusters\"\n\n# Switch to development profile\nkcman profile switch development\n\n# Add development clusters\nkcman add ~/.kube/dev-cluster-1.yaml\nkcman add ~/.kube/dev-cluster-2.yaml\n\n# Switch to production profile and add prod clusters\nkcman profile switch production\nkcman add ~/.kube/prod-cluster.yaml --interactive\n```\n\n### Safe Configuration Updates\n\n```bash\n# Preview what will change\nkcman add new-config.yaml --dry-run\n\n# Add with conflict resolution\nkcman add new-config.yaml --interactive\n\n# Validate the result\nkcman validate\n```\n\n### Interactive Workflows\n\n```bash\n# Interactive context switching with search\nkcman switch --interactive\n\n# Interactive conflict resolution\nkcman add conflicting-config.yaml --interactive\n```\n\n## Configuration Structure\n\nThe tool stores configurations in:\n\n```\n~/.kube/\n├── config                          # Default kubeconfig\n├── backups/                        # Automatic backups\n│   ├── config_backup_20231201_143022\n│   └── config_backup_20231201_143045\n└── profiles/                       # Profile management\n    ├── profiles.json               # Profile metadata\n    ├── dev_config                  # Development profile config\n    ├── staging_config              # Staging profile config\n    └── production_config           # Production profile config\n```\n\n## Safety Features\n\n### Automatic Backups\n- Every modification creates a timestamped backup\n- Backups are stored in `~/.kube/backups/`\n- Use `kcman backups` to list and `kcman restore` to recover\n\n### Conflict Detection\n- Automatically detects conflicting clusters, users, and contexts\n- Interactive resolution lets you choose which version to keep\n- Preview mode shows exactly what will change\n\n### Dry Run Mode\n- Preview all changes before applying\n- Shows before/after counts for all resources\n- No modifications made in dry-run mode\n\n### Validation\n- Validates kubeconfig structure and references\n- Checks for missing required fields\n- Verifies current-context exists\n\n## Advanced Usage\n\n### Profile-Specific Operations\n\n```bash\n# Add config to specific profile without switching\nkcman add config.yaml --profile staging\n\n# Switch context in specific profile\nkcman switch my-context --profile production\n\n# Validate specific profile\nkcman profile switch staging \u0026\u0026 kcman validate\n```\n\n### Batch Operations\n\n```bash\n# Add multiple configs with preview\nfor config in ~/.kube/clusters/*.yaml; do\n  kcman add \"$config\" --dry-run\ndone\n\n# Then apply after review\nfor config in ~/.kube/clusters/*.yaml; do\n  kcman add \"$config\" --interactive\ndone\n```\n\n### Scripting Support\n\n```bash\n# Check current profile in scripts\nCURRENT_PROFILE=$(kcman profile current | grep \"Current profile:\" | cut -d: -f2 | xargs)\n\n# Programmatic context switching\nkcman switch production-cluster --profile production\n```\n\n## Troubleshooting\n\n### Common Issues\n\n**Profile not found**\n```bash\n# List available profiles\nkcman profile list\n\n# Create if missing\nkcman profile create \u003cprofile-name\u003e\n```\n\n**Config file not found**\n```bash\n# Check current profile's config path\nkcman profile current\n\n# Validate the config\nkcman validate\n```\n\n**Context switching fails**\n```bash\n# List available contexts\nkcman switch\n\n# Use interactive mode for guidance\nkcman switch --interactive\n```\n\n### Recovery\n\n**Restore from backup**\n```bash\n# List available backups\nkcman backups\n\n# Restore specific backup\nkcman restore config_backup_20231201_143022\n```\n\n**Reset to clean state**\n```bash\n# Switch to default profile\nkcman profile switch default\n\n# Validate current state\nkcman validate\n```\n\n## Requirements\n\n- Python 3.7+\n- PyYAML\n- Click\n\n```bash\npip install pyyaml click\n```\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes\n4. Add tests for new functionality\n5. Submit a pull request\n\n## License\n\nMIT License - see LICENSE file for details.\n\n## Support\n\n- 🐛 **Issues**: Report bugs and request features\n- 📖 **Documentation**: Check this README for detailed usage\n- 💡 **Tips**: Use `--help` with any command for detailed options\n\n---\n\n**Made with ❤️ for Kubernetes users who manage multiple clusters and environments.**","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatricktrainer%2Fkubeconfig-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpatricktrainer%2Fkubeconfig-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatricktrainer%2Fkubeconfig-manager/lists"}