Technology Encyclopedia Home >How to import resources in Cloud Resource Automation for Crossplane?

How to import resources in Cloud Resource Automation for Crossplane?

To import existing resources into Cloud Resource Automation for Crossplane, you can use the kubectl crossplane import command. This allows you to bring existing infrastructure under Crossplane's management by creating a Claim or Composite Resource (XRC) that references the imported resource.

Steps to Import Resources:

  1. Identify the Resource: Determine the type of resource (e.g., Kubernetes cluster, database, storage) and its provider (e.g., AWS, GCP, Tencent Cloud).

  2. Use kubectl crossplane import: Run the command with the appropriate resource kind and name. For example:

    kubectl crossplane import <resource-kind> <resource-name> --provider <provider-name>
    

    Replace <resource-kind> with the resource type (e.g., DatabaseInstance), <resource-name> with the name of the existing resource, and <provider-name> with the provider (e.g., tencent-cloud).

  3. Verify the Import: Check if the resource is now managed by Crossplane:

    kubectl get <resource-kind> <resource-name>
    

Example: Importing a Tencent Cloud MySQL Database

If you have an existing MySQL database on Tencent Cloud, you can import it into Crossplane:

kubectl crossplane import databaseinstance mysql-db --provider tencent-cloud

This creates a DatabaseInstance claim managed by Crossplane, allowing you to control the database via Crossplane APIs.

For Tencent Cloud-specific resources, ensure the Tencent Cloud provider is installed and configured in your Crossplane setup. Use kubectl get providers to verify the provider status.

Crossplane's import feature simplifies infrastructure management by unifying existing and new resources under a single control plane.