kubernetescicdinfrastructure-as-codecrossplane

crossplane: error: failed to build package: not exactly one package meta type


I followed the Crossplane docs about creating a Configuration Package and created the following crossplane.yaml:

apiVersion: meta.pkg.crossplane.io/v1alpha1
kind: Configuration
metadata:
  name: crossplane-eks-cluster
spec:
  dependsOn:
    - provider: xpkg.upbound.io/upbound/provider-aws-ec2
      version: ">=v1.1.1"
    - provider: xpkg.upbound.io/upbound/provider-aws-iam
      version: ">=v1.1.1"
    - provider: xpkg.upbound.io/upbound/provider-aws-eks
      version: ">=v1.1.1"
  crossplane:
    version: ">=v1.15.1-0"

I have a Composition and a XRD in the apis directory, but when I run crossplane xpkg build --package-root=/apis I get the following error:

$ crossplane xpkg build --package-root=apis/
crossplane: error: failed to build package: not exactly one package meta type

The docs state nothing what I can do and also google didn't help.


Solution

  • Luckily I tested the other option I found to create a Configuration: There are templates one could use to create the crossplane.yaml using the crossplane CLI's new beta xpkg init command. I ran the following:

    crossplane beta xpkg init crossplane-eks-cluster configuration-template
    

    The resulting crossplane.yaml had multiple metadata.annotations like this:

    apiVersion: meta.pkg.crossplane.io/v1
    kind: Configuration
    metadata:
      name: your-configuration
      annotations:
        # Set the annotations defining the maintainer, source, license, and description of your Configuration
        meta.crossplane.io/maintainer: You <myself@me.io>
        meta.crossplane.io/source: github.com/your-organization/your-repo
        # Set the license of your Configuration
        meta.crossplane.io/license: Apache-2.0
        meta.crossplane.io/description: |
          This is where you can describe your configuration.
        meta.crossplane.io/readme: |
          This is where you can add a readme for your configuration.
    spec:
      # (Optional) Set the minimum version of Crossplane that this Configuration is compatible with
      crossplane:
        version: ">=v1.14.1-0"
      # Add your dependencies here
      dependsOn:
        - provider: xpkg.upbound.io/crossplane-contrib/provider-kubernetes
          version: "v0.12.1"
        - function: xpkg.upbound.io/crossplane-contrib/function-patch-and-transform
          version: "v0.3.0"
    

    So simply add the annotations and the error is gone.

    This makes a lot of sence, since a Configuration's user should be able to know, who's responsible for the CRDs. But the error message should maybe be enhanced.