Git Product home page Git Product logo

crossplane-migrator's Introduction

crossplane-migrator

Note this project is archived, as of crossplane/crossplane#5275 and Crossplane 1.15 this functionality has been ported to the Crossplane CLI under crossplane beta convert.


Crossplane release 1.14 introduced functions and the Deployment Runtime.

In order to take advantage of these features, this golang-based binary can be used to convert legacy YAML manifests to newer APIs.

The following conversions are supported:

This utility is proposed to be added to the Crossplane CLI in 1.15.

Installing

Binary releases are available at https://github.com/crossplane-contrib/crossplane-migrator/releases.

To install the latest version, run:

go install github.com/crossplane-contrib/crossplane-migrator@latest

Example Use

Usage: crossplane-migrator <command>

Crossplane migration utilities

Commands:
  new-deployment-runtime      Convert deprecated ControllerConfigs to
                              DeploymentRuntimeConfigs.
  new-pipeline-composition    Convert Compositions to Composition Pipelines with
                              function-patch-and-transform.

Migrating ControllerConfigs to DeploymentRuntimeConfigs

Crossplane ControllerConfig to a DeploymentRuntimeConfig.

DeploymentRuntimeConfig was introduced in Crossplane 1.14 and ControllerConfig has been marked deprecated since Crossplane 1.11.0.

Write out a DeploymentRuntimeConfig file from a ControllerConfig manifest:

crossplane-migrator new-deployment-runtime  -i examples/enable-flags.yaml  -o my-drconfig.yaml

Create a new DeploymentRuntimeConfig via Stdout

crossplane-migrator new-deployment-runtime -i cc.yaml | grep -v creationTimestamp | kubectl apply -f - 

Once the new DeploymentRuntimeConfig has been created on the Crossplane Cluster it can be used by Function and Provider packages via the runtimeConfigRef, which replaces controllerConfigRef.

apiVersion: pkg.crossplane.io/v1beta1
kind: Function
metadata:
  name: function-patch-and-transform
spec:
  package: xpkg.upbound.io/crossplane-contrib/function-patch-and-transform:v0.1.4
  runtimeConfigRef:
    apiVersion: pkg.crossplane.io/v1beta1   # currently apiVersion and kind are optional
    kind: DeploymentRuntimeConfig
    name: func-env

Migrating Existing Compositions to use Pipelines

function-patch-and-transform runs Crossplane's built-in Patch&Transform engine in a function pipeline. This utility can migrate existing compositions to run in a pipeline:

./crossplane-migrator new-pipeline-composition -i composition.yaml -o composition-pipeline.yaml

Setting the Function Name

By default, the functionNameRef is set to function-patch-and-transform. If installing a function via a Crossplane Configuration package, the package organization will be added (i.e. crossplane-contrib-function-patch-and-transform).

./crossplane-migrator new-pipeline-composition --function-name crossplane-contrib-function-patch-and-transform -i composition.yaml

Migrating Running Compositions to Function Patch and Transform

Note: please test this procedure in non-production environments and back up all resources before attempting a migration of live resources.

First, ensure that a function that supports the legacy Path and Transform is installed in your cluster and is in a healthy state.

$ kubectl get function
NAME                           INSTALLED   HEALTHY   PACKAGE                                                       AGE
function-patch-and-transform   True        True      xpkg.upbound.io/upbound/function-patch-and-transform:v0.2.1   8m48s

Ensure all resources generated by this Composition are healthy:

$ kubectl get composite 
NAME              SYNCED   READY   COMPOSITION                         AGE
ref-aws-network   True     True    xnetworks.aws.platform.upbound.io   33m

Convert the composition and apply it to the cluster:

crossplane-migrator new-pipeline-composition -i composition.yaml -o composition-pt.yaml
$ kubectl apply -f composition-pt.yaml
composition.apiextensions.crossplane.io/xnetworks.aws.platform.upbound.io configured

Confirm that resources are healthy:

$ kubectl get composite 
NAME              SYNCED   READY   COMPOSITION                         AGE
ref-aws-network   True     True    xnetworks.aws.platform.upbound.io   33m

Building

go build -o crossplane-migrator

Known Issues

  • The migrator attempts to be as accurate as possible in mapping fields but has not been fully tested. The ControllerConfig test suite and Composition test suite attempt to cover all cases.
  • The generated DeploymentRuntimeConfig has the same Name: as the ControllerConfig.

crossplane-migrator's People

Contributors

haarchri avatar phisco avatar stevendborrelli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

crossplane-migrator's Issues

DeploymentRuntimeConfig does not create serviceAccounts

With ControllerConfig, if a user specified a spec.serviceAccountName Crossplane would create one for you. With the DeploymentRuntimeConfig, this is no longer the case.

We should think of options of handling this to make it easy for users to migrate:

  • - adding a warning when converting
  • - adding a CLI option to create a ServiceAccount object with a namespace

math.type: Required value: math transform type is required - type Multiplay is missing

pld p&t:

          transforms:
          - math:
              multiply: 1024
            type: math

crossplane-migrator new-pipeline-composition -i database/sqlinstance/composition-mariadb.yaml -o xx.yaml

after migration:

          transforms:
          - math:
              multiply: 1024
            type: math

error:
crossplane: error: cannot render composite resource: pipeline step "patch-and-transform" returned a fatal result: invalid Function input: resources[0].patches[3].transforms[0].math.type: Required value: math transform type is required

                transforms:
                - math:
                    multiply: 1024
                    type: Multiply
                  type: math

new-pipeline-composition: `spec.environment` wrongly pushed down entirely to function

Currently the new-pipeline-composition command takes the whole spec.environment and moves it down to spec.pipeline[0].environment, but that's not correct, only spec.environment.patches should be pushed down at the Function level, while the rest should be kept at the Composition level.

This is most probably due to the drift between the vendored Input and the actual Resources expected by function-patch-and-transform.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.