# Kubernetes Cluster migration

**URL:** <https://community.dynatrace.com/t/kubernetes-cluster-migration/35562>\
**Category:** Container platforms\
**Tags:** kubernetes\
**Created:** [June 22, 2022, 6:59am UTC](https://community.dynatrace.com/t/kubernetes-cluster-migration/35562 "2022-06-22T06:59:38Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![mkkr](https://avatars.discourse-cdn.com/v4/letter/m/7993a0/32.png) [@mkkr](https://community.dynatrace.com/u/mkkr)\
**Post date:** [June 22, 2022, 6:59am UTC](https://community.dynatrace.com/t/kubernetes-cluster-migration/35562/1 "2022-06-22T06:59:38Z")

</div>

Hi,

We are migrating applications/services from one Kubernetes cluster to a new Kubernetes cluster (both in GKE). What is the approach when migration applications?

We are using&nbsp;dynakube.yaml and kubectl to instrument our Kubernetes Clusters.  
We have done the migration on our test environments, but services are now recreated, rather than reused, which results in service settings (such as request naming) and “Multidimensional analysis views” being lost and historic service data only existing in the old service view.

Services are not mergeable, and we have many services, so we want to avoid manual process for each service.

What I’ve have tried, without success:  
- Use the same host group  
- Use the same tags

- Use the same network zone

- Use the same name for the new Dynatrace Kubernetes Cluster  
- Tried to change the Kubernetes cluster UUID in the existing Dynatrace Kubernetes Cluster settings, but this is not allowed.

I’ve managed to get a service to be linked to multiple Kubernetes clusters in the Dynatrace service view, but only to the same actual Kubernetes Cluster (UUID), just with multiple new Dynatrace Kubernetes Cluster entities. Which could indicate that a service in theory may exist in different Kubernetes Clusters?

I guess that services/process groups get split up per Kubernetes Cluster UUIDs, which is why services are recreated, but is there any way around this?

Best regards  
Mikkel Kristensen

---

<div class="post-metadata">

**Author:** ![pahofmann](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/pahofmann/32/17076_2.png) [@pahofmann](https://community.dynatrace.com/u/pahofmann)\
**Post date:** [June 23, 2022, 9:10am UTC](https://community.dynatrace.com/t/kubernetes-cluster-migration/35562/2 "2022-06-23T09:10:35Z")

</div>

Services can’t span across Process Groups. So if you want continuity there, you have to make sure the new processes land in the same PG.

By default dynatrace separates PG by workload in k8s. You can use&nbsp;[Workload detection rules](https://www.dynatrace.com/support/help/shortlink/workload-detection#workload-detection-rules-for-kubernetes)&nbsp;to group them based on different metadata.

---

<div class="post-metadata">

**Author:** ![techean](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/techean/32/227_2.png) [@techean](https://community.dynatrace.com/u/techean)\
**Post date:** [June 27, 2022, 8:23am UTC](https://community.dynatrace.com/t/kubernetes-cluster-migration/35562/3 "2022-06-27T08:23:25Z")

</div>

This can be experimental but read about this product call [velero](https://velero.io/) which is used for migrating work loads between kn8s clusters.

---

<div class="post-metadata">

**Author:** ![pahofmann](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/pahofmann/32/17076_2.png) [@pahofmann](https://community.dynatrace.com/u/pahofmann)\
**Post date:** [June 27, 2022, 8:46am UTC](https://community.dynatrace.com/t/kubernetes-cluster-migration/35562/4 "2022-06-27T08:46:07Z")

</div>

I don’t think the problem is with the migration itself, but with the non consistent data in dynatrace after migrating workloads.

---

<div class="post-metadata">

**Author:** ![techean](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/techean/32/227_2.png) [@techean](https://community.dynatrace.com/u/techean)\
**Post date:** [June 27, 2022, 9:32am UTC](https://community.dynatrace.com/t/kubernetes-cluster-migration/35562/5 "2022-06-27T09:32:56Z")

</div>

Oh, in this case it would need complete downtime before the actual migration here than.

---

<div class="post-metadata">

**Author:** ![pahofmann](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/pahofmann/32/17076_2.png) [@pahofmann](https://community.dynatrace.com/u/pahofmann)\
**Post date:** [June 27, 2022, 10:35am UTC](https://community.dynatrace.com/t/kubernetes-cluster-migration/35562/6 "2022-06-27T10:35:00Z")

</div>

Not really. You can do a live migration, the new pods just need to match to the same process group.

---

<div class="post-metadata">

**Author:** ![mkkr](https://avatars.discourse-cdn.com/v4/letter/m/7993a0/32.png) [@mkkr](https://community.dynatrace.com/u/mkkr)\
**Post date:** [June 29, 2022, 9:17am UTC](https://community.dynatrace.com/t/kubernetes-cluster-migration/35562/7 "2022-06-29T09:17:26Z")

</div>

I’ve tried Workload detection rules as well, but without success.

Process groups are still separated by Kubernetes clusters UUIDs.

---

<div class="post-metadata">

**Author:** ![pahofmann](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/pahofmann/32/17076_2.png) [@pahofmann](https://community.dynatrace.com/u/pahofmann)\
**Post date:** [June 29, 2022, 9:23am UTC](https://community.dynatrace.com/t/kubernetes-cluster-migration/35562/8 "2022-06-29T09:23:24Z")

</div>

Have you tried an _Advanced Detection Rule_ with _Standalone rule_ enabled? That should do the trick.

If all else fails you can always use&nbsp; **DT\_CLUSTER\_ID** &nbsp;and&nbsp; **DT\_NODE\_ID e** nvironment variables, they will ignore anything else. But i’d only use this as an last ditch effort on k8s..

---

<div class="post-metadata">

**Author:** ![mkkr](https://avatars.discourse-cdn.com/v4/letter/m/7993a0/32.png) [@mkkr](https://community.dynatrace.com/u/mkkr)\
**Post date:** [June 29, 2022, 9:37am UTC](https://community.dynatrace.com/t/kubernetes-cluster-migration/35562/9 "2022-06-29T09:37:08Z")

</div>

I haven’t tried that, I’ll give it a go.

Thanks for the help.

---

<div class="post-metadata">

**Author:** ![stefan\_penner](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/stefan_penner/32/10145_2.png) [@stefan\_penner](https://community.dynatrace.com/u/stefan_penner)\
**Post date:** [July 6, 2022, 11:32am UTC](https://community.dynatrace.com/t/kubernetes-cluster-migration/35562/10 "2022-07-06T11:32:13Z")

</div>

Hi Mikkel,

could provide some more details about the setup you tried with workload detection rules for k8s?

- Which rules did you create?  
I assume you did not include basePodName in the rule
- Which cluster/agent version did you use? Did the agent versions match between the two k8s clusters?
- Did you restart your pods in order to get those rules applied?
- Did you have any host-groups in parallel?

Thanks,&nbsp;  
Stefan

---

<div class="post-metadata">

**Author:** ![techean](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/techean/32/227_2.png) [@techean](https://community.dynatrace.com/u/techean)\
**Post date:** [July 6, 2022, 11:36am UTC](https://community.dynatrace.com/t/kubernetes-cluster-migration/35562/11 "2022-07-06T11:36:51Z")

</div>

Oh.. Should replicate this use case environment and try testing it ..I’ll Keep you posted.

Meanwhile&nbsp;[@mkkr](https://community.dynatrace.com/user/41064)&nbsp; were you able to close this?

---

<div class="post-metadata">

**Author:** ![mkkr](https://avatars.discourse-cdn.com/v4/letter/m/7993a0/32.png) [@mkkr](https://community.dynatrace.com/u/mkkr)\
**Post date:** [July 25, 2022, 12:13pm UTC](https://community.dynatrace.com/t/kubernetes-cluster-migration/35562/12 "2022-07-25T12:13:07Z")

</div>

Just to follow up

We ended up cutting losses and accepting the extra work of setting the service settings and view up again, as we had a hard deadline for the practical migration..

I don’t think we’ll look any further at this for now as the migration is complete and as it is very time consuming to be black-box testing this in the first place.&nbsp;  
This thread was a last try as the chat support said it was impossible, and it was created a bit late in the process, so we ended up not having that much time to test out your suggestions, unfortunately

Anyhow, thanks for the help&nbsp;😊

---

<div class="post-metadata">

**Author:** ![stefan\_penner](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/stefan_penner/32/10145_2.png) [@stefan\_penner](https://community.dynatrace.com/u/stefan_penner)\
**Post date:** [July 26, 2022, 6:56am UTC](https://community.dynatrace.com/t/kubernetes-cluster-migration/35562/13 "2022-07-26T06:56:59Z")

</div>

Hi Mikkel,

sorry to hear that you weren’t able to try/use the suggested approaches due to time restrictions.

I just want to use this thread to document how it would work here as well in case someone faces similar requirements:  
As mentioned by&nbsp;[@pahofmann](https://community.dynatrace.com/user/22796)&nbsp;you can use&nbsp;[Workload detection rules](https://www.dynatrace.com/support/help/shortlink/workload-detection#workload-detection-rules-for-kubernetes)&nbsp;to group Process Groups and Services based on different metadata. In order to merge workloads across clusters into a single service within Dynatrace, it is crucial to define a workload detection rule which utilizes “Product” (assuming Stage and container name are not sufficient/unique but can be optionally combined with Product). I’ve attached a sample which would work across clusters, assuming you just want to apply it for one specific namespace (in this case: “merge-demo”). Hence, you can also do a migration on a per namespace basis instead of a big-bang.

KR,&nbsp;  
Stefan&nbsp;

 ![Screenshot 2022-07-26 at 08.38.02.png](https://global.discourse-cdn.com/dynatrace/original/3X/2/4/245c97b75ca66931771ddae3e6c0b440b5fdab39.png)
