Move your Developer Sandbox objects to another cluster

This learning path walks you through the process of exporting your OpenShift objects from one cluster and importing them into another.

Access the Developer Sandbox

Moving objects from one cluster to another involves an export and an import. The import step in between is to remove unwanted objects.

In order to get full benefit from taking this lesson, you need to:

  • Have access to the OpenShift dashboard.
  • Have access to a command line to run the oc command.

In this lesson, you will:

  • Remove unwanted objects from your YAML files.
  • Import objects at the command line.

Remove unwanted objects

Unzip the exported objects into a directory, then navigate to that directory. There will be several YAML files, some of which are not related to your application. Inside the YAML files, a label identifies the files that are related to your application, in the form of app.kubernetes.io/part-of: {your_application_name_goes_here} Those are the files you want to import.

Remain in the directory. Log in to your cluster from the command line and run the following command:

If using PowerShell:

Remove-Item (gci | Where-Object { !( $_ | Select-String "app.kubernetes.io/part-of: {your_application_name_goes_here}" -quiet) })

If using Bash shell:

grep -L "app.kubernetes.io/part-of: {your_application_name_goes_here}" * | xargs rm

This will reduce the number of files in the directory from several dozen to just a few.

Import objects

Import the objects with one command:

oc apply -f .

Summary

You now know how to remove unwanted objects from your list of objects and then import the remaining objects.

Want to learn more? Try these:

Previous resource
Export objects from an OpenShift cluster