{"id":31324784,"url":"https://github.com/epolevov/k8s-migrate","last_synced_at":"2026-05-18T04:36:13.265Z","repository":{"id":308361340,"uuid":"1032549794","full_name":"epolevov/k8s-migrate","owner":"epolevov","description":"Migrate Kubernetes namespaces and resources between clusters using kubectl in one command.","archived":false,"fork":false,"pushed_at":"2025-08-05T13:23:18.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-05T15:20:46.287Z","etag":null,"topics":["devops","devops-tools","k8s","kubernetes","transfer-data"],"latest_commit_sha":null,"homepage":"","language":"Shell","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/epolevov.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-08-05T13:21:43.000Z","updated_at":"2025-08-05T15:00:29.000Z","dependencies_parsed_at":"2025-08-06T01:00:41.477Z","dependency_job_id":null,"html_url":"https://github.com/epolevov/k8s-migrate","commit_stats":null,"previous_names":["epolevov/k8s-migrate"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/epolevov/k8s-migrate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epolevov%2Fk8s-migrate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epolevov%2Fk8s-migrate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epolevov%2Fk8s-migrate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epolevov%2Fk8s-migrate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/epolevov","download_url":"https://codeload.github.com/epolevov/k8s-migrate/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epolevov%2Fk8s-migrate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276987453,"owners_count":25740583,"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","status":"online","status_checked_at":"2025-09-25T02:00:09.612Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["devops","devops-tools","k8s","kubernetes","transfer-data"],"created_at":"2025-09-25T21:38:36.425Z","updated_at":"2025-09-25T21:38:37.860Z","avatar_url":"https://github.com/epolevov.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🛠️ k8s-migrate\n\n[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](./LICENSE)\n[![Shell Script](https://img.shields.io/badge/Language-Bash-blue)](https://www.gnu.org/software/bash/)\n[![Kubernetes](https://img.shields.io/badge/Kubernetes-namespace--migrator-blue)](https://kubernetes.io/)\n\nA lightweight Bash CLI utility to **migrate a namespace's resources between Kubernetes clusters** (contexts) using `kubectl`.\n\n---\n\n## 📆 What This Tool Does\n\n`k8s-migrate.sh` interactively exports and applies Kubernetes resources from a specified namespace between two kube-contexts — allowing you to:\n\n- Migrate applications from **dev ➔ prod**, **test ➔ staging**, etc.\n- Sync environments quickly\n- Prepare for cluster upgrades or provider migrations\n\nIt works using native `kubectl` commands and supports all common namespaced resources.\n\n---\n\n## 🚀 Quick Start\n\n### ✅ Prerequisites\n\n- `kubectl` installed and configured\n- Both clusters defined in your `~/.kube/config`\n- Access rights to export and apply resources\n\n\u003e Optional:\n\u003e\n\u003e - [`yq`](https://github.com/mikefarah/yq) for sanitizing exported YAML\n\u003e - `kubectl neat` for cleaning unnecessary fields\n\n---\n\n### 🧪 Demo\n\n```bash\nchmod +x k8s-migrate.sh\n./k8s-migrate.sh [--dryRun]\n```\n\n```text\nEnter namespace to migrate: my-app\nEnter source K8S context (from-cluster): dev-cluster\nEnter target K8S context (to-cluster): prod-cluster\n\nSelect resources to migrate (space-separated or 'all'):\nAvailable: deployments services configmaps secrets ingresses pvc all\n\u003e all\n\n🔍 Migration Summary:\nNamespace:        my-app\nSource cluster:   dev-cluster\nTarget cluster:   prod-cluster\nResources:        deployments services configmaps secrets ingresses pvc\nDry Run Mode:     true\n\nProceed with migration? (y/n): y\n\n📤 Exporting...\n📥 Importing...\n✅ Migration complete (dry-run only).\n```\n\n---\n\n## 🔧 Supported Resources\n\n- `deployments`\n- `services`\n- `configmaps`\n- `secrets` ⚠️\n- `ingresses`\n- `pvc` (PersistentVolumeClaims)\n\nYou can select specific types or use `all` to migrate everything listed above.\n\n---\n\n## 🔐 Secret Handling\n\nSecrets are exported and applied as-is. Be careful:\n\n- **Do not** migrate `service account tokens` or `cloud provider credentials` unless necessary.\n- Consider sanitizing secrets before applying them to another cluster.\n\n---\n\n## 📂 Temporary Files\n\nAll exported resources are saved to a temporary working directory (via `mktemp -d`) and applied from there. This folder is **not deleted automatically**, so you can inspect or archive it if needed.\n\n---\n\n## 🧱 Advanced Ideas\n\nWant to improve or extend this?\n\n- ✅ Add `--dryRun` support to preview changes before applying ✅\n- Sanitize YAML via `yq` or `kubectl neat`\n- Support Helm releases or CRDs\n- Use labels or selectors to filter resources\n- Migrate RBAC (`RoleBinding`, `ServiceAccount`, etc.)\n\n---\n\n## 🧑‍💻 Author\n\nCreated by [@epolevov](https://github.com/epolevov)\\\nMaintained by the engineering team at [EMD Labs](https://emd.one)\n\n---\n\n## 📜 License\n\nThis project is licensed under the [MIT License](./LICENSE).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fepolevov%2Fk8s-migrate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fepolevov%2Fk8s-migrate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fepolevov%2Fk8s-migrate/lists"}