npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@andresnator/k8s-clone

v1.2.0

Published

A CLI tool to clone and migrate Kubernetes resources across namespaces

Readme

K8s Migrator

CI CodeQL npm version

A CLI tool to clone and migrate Kubernetes resources across namespaces.

Features

  • Granular selection of resources (Services, Deployments, ConfigMaps, Secrets, PVCs).
  • PVC data migration (copies volume contents).
  • Friendly interactive interface.
  • Automatic update notifications - displays when a newer version is available on npm.
  • Custom Apps - Group and deploy related Kubernetes resources as configurable applications (see CUSTOM_APPS.md).

Requirements

  • Node.js (Tested on v20.x and v22.x)
  • kubectl installed and available in your PATH.
  • Access to a Kubernetes cluster (current context in ~/.kube/config).

Installation

Global Installation (Recommended)

Install k8s-clone globally from npm:

npm install -g @andresnator/k8s-clone

Then run:

k8s-clone

Local Development

git clone https://github.com/andresnator/k8s-clone.git
cd k8s-clone
npm install
npm run build

Configuration

k8s-clone uses an optional configuration file at ~/.k8s-clone/config.yaml to store default cluster and namespace settings.

Setup: Run npm run setup to create the configuration directory and file automatically.

Custom Location: Set K8S_CLONE_CONFIG environment variable to use a different path.

Behavior: When empty, the tool auto-detects clusters from ~/.kube/config and fetches resources via Kubernetes API. When populated, it uses pre-configured values. See config.example.yaml for structure details.

Environment Variables

  • K8S_CLONE_CONFIG: Set a custom path for the configuration file (default: ~/.k8s-clone/config.yaml)
  • K8S_CLONE_SKIP_VERSION_CHECK: Set to any truthy value (true, 1, yes, or any non-empty string) to skip version update checks (useful for CI/CD environments)

Usage

If installed globally:

k8s-clone

If running locally:

npm start

Follow the on‑screen prompts to choose the source namespace, the destination namespace, and the resources you wish to migrate.

Command-Line Options

  • --version, -v: Display the current version number
  • --help, -h: Display help information

Custom Apps

The Custom Apps feature allows you to group related Kubernetes resources into logical applications and deploy them as a unit with optional spec overrides.

Key Features:

  • Define applications once in config, deploy multiple times
  • Override resource specs per environment (e.g., replica counts, storage sizes)
  • Support for deep nesting in overwrite-spec
  • Duplicate resource detection and warnings

For complete documentation, examples, and troubleshooting, see CUSTOM_APPS.md.

Demo

Want to see it in action? We have prepared a comprehensive Demo Guide that walks you through a realistic migration scenario.

The demo uses a full-stack application (Frontend + Backend + Database) with persistent storage to showcase:

  • Stateful Migration: Moving PVCs with actual data.
  • Configuration Handling: Migrating ConfigMaps and Secrets.
  • Networking: Preserving Services and Ingress rules.

Check out DEMO.md for step-by-step instructions on how to deploy the test app and run the migration.

Multi-Cluster Setup

For testing with Minikube profiles, see the detailed Demo Guide which includes multi-cluster migration scenarios.

How It Works

  1. Select Contexts & Namespaces: Choose source/destination clusters and namespaces
  2. Select Resources: Interactive prompts let you choose which resources to migrate
  3. Clean Metadata: System-generated fields are automatically removed
  4. Migrate Data: PVC data is transferred using temporary pods and tar streaming
  5. Create Resources: All selected resources are recreated in the destination namespace

Project Structure

  • src/index.ts - CLI entry point and user interaction flow
  • src/migrator.ts - Core migration logic
  • src/cleaner.ts - Resource cleanup logic
  • src/k8s.ts - Kubernetes API client wrapper
  • src/ui.ts - Interactive UI components
  • src/config.ts - Configuration management
  • src/metadata-cleaner.ts - Metadata cleaning utilities
  • src/resource-handlers.ts - Resource-specific handling logic
  • src/types.ts - TypeScript type definitions
  • src/Banner.tsx - Banner component
  • scripts/setup.sh - Configuration setup script
  • demo/demo.yaml - Complete demo application manifest

Testing

To run the unit tests:

npm test

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines on how to contribute, including our commit message conventions and automated release process.

License

This project is licensed under the MIT License — see the LICENSE file for details.

SPDX-License-Identifier: MIT