Recreating GCP kubernetes cluster

4/18/2018

I'm looking to understand how to recreate my cluster. There's a cluster-level setting to specify the IP range for nodes created within it, which I want to use so I can set a decent firewall rule. However, it looks like that can't be changed once the cluster is created.

I have a number of namespaces, deployments, services, secrets, persistent volumes and claims. If I wanted to transfer them all to a new cluster, should I just kubectl get all --namespace=whatever --format=yaml, kubectl delete -f, and then kubectl apply -f on the new cluster?

Would something so crude work for mapping to the same load balancers / public IPs, persistent volumes, secrets, etc?

-- Kieren Johnstone
google-cloud-platform
google-kubernetes-engine
kubernetes

1 Answer

4/19/2018

As you can see the backup and the migration of whole clusters is quite a discussed matter and still an open issue on Kubernetes github as well:

Therefore I do not believe that the command that you posted might be considered a solution or work. I think it will fail due to different resources that are cluster dependent and IPs. Moreover since this kind of use is not supported It will lead for to multiple issues.

Lets say that you change zone of the cluster, how could be possible to move the PV if the disk cannot be attached to an instance in a different zone (or possibly if you migrate to a different cloud service)?

More important I would not risk to delete my production to run a command that is not documented or indicated as best practise. You could try it on test namespace, but I would not suggest to go further.

You can check reshifter and ark since they might cover your needs. I have never tested them but they are mentioned in the thread, so they might be of your interest.


I tried this approach in one of my test cluster obtaining:

Error from server (Conflict): Operation cannot be fulfilled 
Error from server (Conflict): Operation cannot be fulfilled 
Error from server (Forbidden): [...]

Honestly I believe that for a limited subset of resources it might be possible (Note that some resources were created correctly) , but it cannot be considered at all a way to migrate.

-- GalloCedrone
Source: StackOverflow