Skip to content

Crossplane managed resources: provisioning cloud infra from Kubernetes

Install Crossplane, install a provider, create managed resources for cloud infra, and compose them into platform APIs via Compositions and XRDs.

You manage cloud infrastructure with Terraform and the team is asking whether Crossplane should replace it. The short answer is “for self-service platform APIs yes; for one-shot infra it depends”. Crossplane runs in your management cluster and represents cloud resources — RDS instances, S3 buckets, IAM roles — as Kubernetes objects that the controller reconciles. The big win is Compositions: you author a single XRD (CRD) that bundles several cloud resources into a higher-level API that developers can request via YAML. This article is what we install on real platform clusters.

How to verify

The Crossplane controllers should be running:

kubectl -n crossplane-system get pods

Installed providers should report Healthy:

kubectl get providers
kubectl get providerconfigs

Managed resources show up as CRDs from the provider:

kubectl get crd | grep aws.upbound.io
kubectl get buckets,instances,clusters -A

A Composition should produce composite resources when claimed:

kubectl get compositions
kubectl get xrd
kubectl get compositeresourcedefinition

What’s happening

Crossplane has four moving parts. Providers are install packages (OCI images) that ship CRDs and controllers for a specific cloud or service — provider-aws, provider-gcp, provider-azure, provider-kubernetes, provider-helm, plus the newer family-split Upbound providers (provider-family-aws, provider-aws-s3, provider-aws-rds, etc., which let you install only the services you need). Managed Resources (MRs) are Kubernetes objects that map one-to-one to cloud resources — an Instance to an EC2 instance, a Bucket to an S3 bucket. The provider controller reconciles the MR with the cloud API.

Composite Resource Definitions (XRDs) define a new high-level CRD, e.g. PostgresInstance, that the platform team designs. Compositions are the templates that say “when someone requests a PostgresInstance, create an RDS Instance, an IAM role, a Secret with credentials, and a Kubernetes Service that points at the RDS endpoint”. A Claim is a namespaced request for a Composite (the dev’s PostgresInstance lives in their namespace, the underlying RDS Instance is cluster-scoped).

The Terraform-vs-Crossplane question hinges on this. Terraform is great at one-shot infrastructure. Crossplane is great at service catalogue — developers request, the platform team owns the recipe.

The procedure

  1. Install Crossplane.

    helm repo add crossplane-stable https://charts.crossplane.io/stable
    helm install crossplane crossplane-stable/crossplane \
      --namespace crossplane-system \
      --create-namespace \
      --version 1.18.0 \
      --set "args[0]=--enable-environment-configs" \
      --set "args[1]=--enable-composition-functions"
  2. Install the provider you need. For AWS RDS, install just the family + RDS:

    apiVersion: pkg.crossplane.io/v1
    kind: Provider
    metadata:
      name: provider-family-aws
    spec:
      package: xpkg.upbound.io/upbound/provider-family-aws:v1.18.0
    ---
    apiVersion: pkg.crossplane.io/v1
    kind: Provider
    metadata:
      name: provider-aws-rds
    spec:
      package: xpkg.upbound.io/upbound/provider-aws-rds:v1.18.0

    Apply it; wait for READY=True.

  3. Configure the provider with credentials. Create a Kubernetes Secret with AWS credentials and a ProviderConfig that references it:

    apiVersion: aws.upbound.io/v1beta1
    kind: ProviderConfig
    metadata:
      name: default
    spec:
      credentials:
        source: IRSA  # use IAM Roles for Service Accounts on EKS

    On EKS, IRSA is the recommended path. On non-EKS, mount a credentials Secret.

  4. Author an XRD. Define a PostgresInstance API:

    apiVersion: apiextensions.crossplane.io/v1
    kind: CompositeResourceDefinition
    metadata:
      name: xpostgresinstances.example.org
    spec:
      group: example.org
      names:
        kind: XPostgresInstance
        plural: xpostgresinstances
      claimNames:
        kind: PostgresInstance
        plural: postgresinstances
      versions:
        - name: v1alpha1
          served: true
          referenceable: true
          schema:
            openAPIV3Schema:
              type: object
              properties:
                spec:
                  type: object
                  properties:
                    parameters:
                      type: object
                      properties:
                        storageGB: { type: integer, default: 20 }
                        engineVersion: { type: string, default: "16.4" }
                      required: [storageGB]
  5. Author a Composition. This says how to satisfy the XRD:

    apiVersion: apiextensions.crossplane.io/v1
    kind: Composition
    metadata:
      name: postgresinstance-rds
    spec:
      compositeTypeRef:
        apiVersion: example.org/v1alpha1
        kind: XPostgresInstance
      resources:
        - name: rds-instance
          base:
            apiVersion: rds.aws.upbound.io/v1beta1
            kind: Instance
            spec:
              forProvider:
                region: us-east-1
                instanceClass: db.t3.medium
                engine: postgres
                username: appuser
                allocatedStorageGBRef:
                  name: ""
          patches:
            - fromFieldPath: spec.parameters.storageGB
              toFieldPath: spec.forProvider.allocatedStorageGB
            - fromFieldPath: spec.parameters.engineVersion
              toFieldPath: spec.forProvider.engineVersion
  6. Claim the API from a developer namespace.

    apiVersion: example.org/v1alpha1
    kind: PostgresInstance
    metadata:
      name: app-pg
      namespace: app
    spec:
      parameters:
        storageGB: 50

    Apply, then watch:

    kubectl -n app describe postgresinstance app-pg
    kubectl get instances.rds.aws.upbound.io

    Crossplane creates the RDS Instance, the controller calls the AWS API, and within a few minutes you have a database.

Operational notes

  • Drift is reconciled, not warned. If someone edits the RDS instance class via the AWS console, the Crossplane controller will revert it on the next reconcile. This is by design but surprising the first time. Document the boundary loudly.
  • DeletionPolicy Delete deletes the cloud resource on claim deletion. Default. Switch to Orphan for stateful resources you want to retain on YAML deletion.
  • Provider versions matter. Family providers and service providers must be compatible. A provider-family-aws@v1.18 paired with provider-aws-rds@v1.10 may not work.
  • Composition Functions are the modern path. The legacy patches syntax above is being replaced by Composition Functions (Go, Python, KCL, or shell) for templating. New compositions should consider functions from the start.
  • Credentials breadth is a concern. Crossplane often runs with very broad IAM permissions because it provisions across services. Use IRSA with narrow roles per provider, and scope ProviderConfigs accordingly.

Stack Harbor builds platform APIs on Crossplane for clients who want developer self-service over their cloud — XRD design, Composition authoring, IRSA-scoped credentials, and the policy gates (Gatekeeper/Kyverno) that prevent claims from drifting outside the supported envelope. See how we deliver that across our managed Kubernetes operations.