Migrate Virtual Cluster Workloads
It is sometimes necessary to migrate workloads from one virtual cluster to another. For instance, if a virtual cluster cannot be upgraded, migrating its workloads becomes the only option. This guide provides high-level steps to help you migrate workloads between virtual clusters and delete legacy virtual clusters. The steps in Palette need to be performed in cluster mode.
Migrate Workloads to New Virtual Cluster
Prerequisites
-
Access to your legacy and new virtual clusters through kubectl.
-
The Virtual Cluster Admin role in Palette.
-
The necessary prerequisites to create a new cluster group to host the virtual clusters. Refer to Create and Manage Cluster Groups - Prerequisites for guidance.
Migrate Workloads
This guide covers a common method of migrating workloads between clusters, which is a manual export and import of YAML manifests.
The following steps may not cover all use-cases. Ensure you adjust them to your environment and needs.
-
Identify all resources on your virtual clusters that need to be migrated. Typical resources include the following:
- Deployments, StatefulSets, DaemonSets, or other workload controllers
- Services
- ConfigMaps
- Secrets
- Ingress objects
- PersistentVolumeClaims and associated PersistentVolumes, if needed
- Role-Based Access Control (RBAC) resources, such as Roles, RoleBindings, ClusterRoles, and ClusterRoleBindings
- Custom Resource Definitions (CRDs) and their instances
-
Export the resources from legacy virtual clusters using
kubectl
.Service export examplekubectl get service my-app-service \
--namespace my-namespace \
--output yaml > my-app-service.yaml -
Remove any cluster-specific fields from the exported YAML files, such as
resourceVersion
,uid
,creationTimestamp
, ormanagedFields
. Also ensure to remove anystatus
fields or finalizers in the exported YAML files, if they appear. This will prevent conflicts in the new cluster. -
In the exported YAML files, update references to external resources, such as a specific PersistentVolume name or private registry secrets. For example, if your YAML references a PersistentVolume named
pv-old-cluster
in the old namespace, rename it topv-new-cluster
in the new namespace before deployment.Also ensure that
metadata.namespace
points to the expected target namespace in the new virtual cluster. -
Log in to Palette.
-
Create a new cluster group for the new virtual clusters. You can use the same host clusters that are used for your legacy virtual clusters or select different ones.
warningIf using the same host clusters for your new cluster group, ensure there are enough resources for both the legacy and new virtual clusters to claim.
-
Deploy new virtual clusters to your new cluster group. These will replace your legacy clusters so it is advisable to set the same amount of maximum resources to each new virtual cluster.
-
Apply your YAML manifests to each new virtual cluster using
kubectl
.For example, create the namespace for the resource on the new cluster if it does not exist.
Example namespace creationkubectl create namespace my-namespace
Example outputnamespace/my-namespace created
Then, import the YAML manifest to the new cluster.
Service import examplekubectl apply --filename my-app-service.yaml
Example outputservice/my-app-service created
-
Migrate any persistent data to the storage accessible to the new virtual clusters, if required.
For example, you can use a tool like
rsync
to copy data from your old storage path to your new storage path.Rsync copy examplersync \
--archive \ # Ensures that symbolic links, file permissions, user & group ownerships, and timestamps are preserved
--verbose \ # Prints detailed information about the transfer
--compress \ # Compress file data during the transfer to reduce network usage
--human-readable \ # Outputs file sizes in a more readable format (e.g., 1K, 24M, 2G)
--progress \ # Shows progress during file transfer (percentages, estimated time, etc.)
--rsh="ssh -i /path/to/key" # Optional: Use a custom SSH key for authentication; remove if not required
/path/on/oldserver/ \
user@newserver.example.com:/path/on/newserver/ -
If needed, adjust your DNS records to point at the new ingress or load balancer IPs of the new virtual clusters.
For example, if using a
CNAME
record for a load balancer, log in to your DNS management console and update the target for theCNAME
record. -
Modify any application and CI/CD pipelines to point at the new virtual clusters.
Validate
-
Check that your deployments and pods are active on new virtual clusters using
kubectl
.Example command to check status of Deployments in a namespacekubectl get deployments --namespace my-namespace
Example command to check status of Pods in a namespacekubectl get pods --namespace my-namespace
-
Verify that the outputs are satisfactory, for example:
-
Pods should display a
Running
orReady
state. -
Services should display a
ClusterIP
,ExternalIP
,LoadBalancer
, orIngress
, depending on the type of Service.
-
-
If you’re using an Ingress, verify that the Ingress Controller is correctly routing traffic. For example, use the following command to check that the Ingress controller has assigned an external IP or hostname and is processing the rules you configured.
Replace
<appIngress>
with your Ingress name and<namespace>
with the namespace for your Ingress on the cluster.kubectl describe ingress <appIngress> --namespace <namespace>
Example outputName: my-app-ingress
Namespace: my-namespace
Address: 203.0.113.10
Default backend: <default>
Rules:
Host Path Backends
---- ---- --------
example.com
/ my-app-service:80 (10.44.0.2:8080,10.44.0.3:8080)
Annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal CreateCertificate 1m cert-manager-controller Successfully created Certificate "my-app-tls"
Normal IPAllocated 1m nginx-ingress-controller Assigned IP or LB address
Normal UpdateIngress 50s (x2 over 1m) nginx-ingress-controller Ingress my-app-ingress configuration updated
Delete Legacy Virtual Clusters
If all workloads have been fully migrated to a new virtual cluster, or your virtual cluster is no longer required, use the steps in this section to delete your legacy clusters.
Prerequisites
- The Virtual Cluster Admin role in Palette.
Delete Clusters
-
Log in to Palette.
-
On the left main menu, select Clusters and click on the Virtual Clusters tab.
-
Locate and click on the virtual cluster that you want to delete.
-
Click on the Settings drop-down menu and select Delete Cluster.
-
Enter the cluster name and click OK. The cluster status will change to Deleting.
Wait for the virtual cluster resources to be deleted. This may take up to 10 minutes.
-
If you have deleted all virtual clusters in a cluster group, you can then delete your cluster group.
Validate
-
Log in to Palette.
-
On the left main menu, select Clusters and click on the Virtual Clusters tab.
-
Check that your virtual clusters are no longer displayed. You can also click the Show Deleted checkbox to show deleted virtual clusters.
-
If you deleted your cluster group, navigate to the left main menu and select Cluster Groups.
Your legacy cluster group is no longer displayed.