Kubernetes namespace migration to another cluster

4/8/2020

Let's assume we have a Kubernetes cluster called CLUSTER_01 and DEV namespace on it. I want to recreate this DEV name space in another cluster called CLUSTER_02. What will be the easiest and best way to do this.

-- anXler
azure-kubernetes
docker
google-kubernetes-engine
kubernetes
kubernetes-pod

3 Answers

4/8/2020

Although it is theoretically possible to query the data from etcd datastore and migrate it to another cluster, you'll hit inconsistencies in local settings and variables anyway. The easiest way would be to recreate all resources in the namespace from manifests or Helm charts (whatever you have for them).

-- Anton Matsiuk
Source: StackOverflow

4/8/2020

Velero (formerly Heptio Ark) gives you tools to back up and restore your Kubernetes cluster resources and persistent volumes. You can run Velero with a cloud provider or on-premises. Velero lets you:

  1. Take backups of your cluster and restore in case of loss.
  2. Migrate cluster resources to other clusters.
  3. Replicate your production cluster to development and testing clusters. Velero consists of:

A server that runs on your cluster

A command-line client that runs locally

-- Arghya Sadhu
Source: StackOverflow

4/8/2020

If you have standardized Kubernetes deployments via some tools like Jenkins or anything similar then you have set of standard objects you were creating for every deployment, Such as configmap, secret, ingress, deployment, hpa, etc.

Then the easiest way is to dump the objects as YAML to a file and then re-applying them to a new Custer. Though it is not a good practice but the easiest one.

kubectl get configmap -n <namespace> -o yaml > CLUSTER_O1_Namespace.yaml

Start with lower objects like configmap, secrets, external endpoints then apply the main objects like deployment, ingress, and hpa.

Make sure you have the external dependencies needed by the k8s objects like ingress controller are applied 1st and are identical with your CLUSTER_01.

As @Arghya suggested use Velero (formerly Heptio Ark) if you have the bandwidth.

-- Vaibhav Jain
Source: StackOverflow