phisco / crossplane-migrator-archived

Migrates Crossplane manifests to newer APIs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

crossplane-migrator

This golang-based binary migrates YAML manifests to newer APIs. The following migrations are supported:

  • ControllerConfig to DeploymentRuntimeConfig
  • Compositions to use Function-based Patch&Transform instead of the built-in engine.

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

Installing

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

Example Use

Usage: crossplane-migrate <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

Building

go build -o crossplane-migrator

Known Issues

  • The migrator attempts to be as accurate as possible in mapping the fields but has not been fully tested. The ControllerConfig test suite Composition test suite attempt to cover all cases.
  • The generated DeploymentRuntimeConfig has the same Name: as the ControllerConfig
  • Output metadata fields contain a creationTimestamp. This is a known Kubernetes issue that may be addressed via PR kubernetes/kubernetes#120757 merged in October 2023. Until upstream tooling is updated, remove the field from manifests.

About

Migrates Crossplane manifests to newer APIs

License:Apache License 2.0


Languages

Language:Go 100.0%