Skip to content

Crossplane

Kubernetes-native infrastructure as code control plane for composing cloud resources.

CommandDescription
helm repo add crossplane-stable https://charts.crossplane.io/stableAdd Crossplane Helm repo
helm repo updateUpdate Helm repositories
helm install crossplane crossplane-stable/crossplane -n crossplane-system --create-namespaceInstall Crossplane on Kubernetes
helm install crossplane crossplane-stable/crossplane -n crossplane-system --set args='{"--debug"}'Install with debug logging
helm upgrade crossplane crossplane-stable/crossplane -n crossplane-systemUpgrade Crossplane
helm uninstall crossplane -n crossplane-systemUninstall Crossplane
kubectl get pods -n crossplane-systemVerify Crossplane is running
kubectl get deployments -n crossplane-systemCheck deployment status
CommandDescription
curl -sL https://raw.githubusercontent.com/crossplane/crossplane/master/install.sh | shInstall Crossplane CLI
brew install crossplane/tap/crossplaneInstall CLI via Homebrew
crossplane --versionShow CLI version
CommandDescription
crossplane xpkg init my-config configurationInitialize new configuration package
crossplane xpkg init my-provider providerInitialize new provider package
crossplane xpkg buildBuild a Crossplane package
crossplane xpkg build --package-root=./package --examples-root=./examplesBuild with specific directories
crossplane xpkg push index.docker.io/org/config:v1Push package to registry
crossplane xpkg install provider index.docker.io/org/provider:v1Install a provider package
crossplane xpkg install configuration index.docker.io/org/config:v1Install a configuration package
CommandDescription
crossplane beta validate schema.yaml resources/Validate resources against schema
crossplane beta trace kind/nameTrace resource dependencies
crossplane beta trace kind/name -o wideTrace with extended output
crossplane beta convert composition comp.yamlConvert Composition to pipeline mode
crossplane beta render xr.yaml composition.yaml functions.yamlLocally render composed resources
CommandDescription
kubectl apply -f provider-aws.yamlInstall AWS provider
kubectl apply -f provider-gcp.yamlInstall GCP provider
kubectl apply -f provider-azure.yamlInstall Azure provider
kubectl apply -f provider-kubernetes.yamlInstall Kubernetes provider
kubectl apply -f provider-helm.yamlInstall Helm provider
kubectl get providersList installed providers
kubectl get provider.pkg provider-aws -o yamlShow provider details
kubectl describe providerrevisionShow provider revision status
kubectl get managedList all managed cloud resources
kubectl get managed -o wideList managed resources with status
apiVersion: aws.upbound.io/v1beta1
kind: ProviderConfig
metadata:
  name: default
spec:
  credentials:
    source: Secret
    secretRef:
      namespace: crossplane-system
      name: aws-creds
      key: credentials

Create the credentials secret:

kubectl create secret generic aws-creds \
  -n crossplane-system \
  --from-file=credentials=./aws-credentials.txt
apiVersion: gcp.upbound.io/v1beta1
kind: ProviderConfig
metadata:
  name: default
spec:
  projectID: my-gcp-project
  credentials:
    source: Secret
    secretRef:
      namespace: crossplane-system
      name: gcp-creds
      key: credentials
apiVersion: azure.upbound.io/v1beta1
kind: ProviderConfig
metadata:
  name: default
spec:
  credentials:
    source: Secret
    secretRef:
      namespace: crossplane-system
      name: azure-creds
      key: credentials
CommandDescription
kubectl apply -f xrd.yamlCreate CompositeResourceDefinition
kubectl get xrdList all XRDs
kubectl describe xrd xdatabases.custom.example.comShow XRD details
kubectl get compositeList all composite resources
kubectl describe compositeShow composite resource status
kubectl delete xrd xdatabases.custom.example.comDelete XRD
Set spec.claimNames in XRDEnable namespace-scoped claims
Set spec.versions[].schemaDefine OpenAPI schema for XRD
Set spec.connectionSecretKeysDefine which connection keys to expose
apiVersion: apiextensions.crossplane.io/v1
kind: CompositeResourceDefinition
metadata:
  name: xdatabases.platform.example.com
spec:
  group: platform.example.com
  names:
    kind: XDatabase
    plural: xdatabases
  claimNames:
    kind: Database
    plural: databases
  connectionSecretKeys:
    - endpoint
    - port
    - username
    - password
  versions:
    - name: v1alpha1
      served: true
      referenceable: true
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              properties:
                parameters:
                  type: object
                  properties:
                    engine:
                      type: string
                      enum: ["postgres", "mysql", "mariadb"]
                      description: "Database engine type"
                    engineVersion:
                      type: string
                      description: "Engine version"
                    storageGB:
                      type: integer
                      default: 20
                      description: "Storage size in GB"
                    instanceSize:
                      type: string
                      enum: ["small", "medium", "large"]
                      default: "small"
                  required:
                    - engine
              required:
                - parameters
CommandDescription
kubectl apply -f composition.yamlCreate a Composition
kubectl get compositionsList all Compositions
kubectl describe compositionShow Composition details
Set spec.compositeTypeRef in CompositionLink to XRD
Set spec.resources[] in CompositionDefine composed resources
Use patches in CompositionMap fields between composite and resources
patch: { type: FromCompositeFieldPath }Patch from composite to resource
patch: { type: ToCompositeFieldPath }Patch from resource to composite
patch: { type: CombineFromComposite }Combine multiple fields into one
Set spec.mode: Pipeline in CompositionUse function pipeline mode
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
  name: xdatabase-aws
  labels:
    provider: aws
    engine: postgres
spec:
  compositeTypeRef:
    apiVersion: platform.example.com/v1alpha1
    kind: XDatabase
  resources:
    - name: rds-instance
      base:
        apiVersion: rds.aws.upbound.io/v1beta1
        kind: Instance
        spec:
          forProvider:
            engine: postgres
            instanceClass: db.t3.micro
            allocatedStorage: 20
            publiclyAccessible: false
            skipFinalSnapshot: true
            region: us-east-1
      patches:
        - type: FromCompositeFieldPath
          fromFieldPath: spec.parameters.engineVersion
          toFieldPath: spec.forProvider.engineVersion
        - type: FromCompositeFieldPath
          fromFieldPath: spec.parameters.storageGB
          toFieldPath: spec.forProvider.allocatedStorage
        - type: FromCompositeFieldPath
          fromFieldPath: spec.parameters.instanceSize
          toFieldPath: spec.forProvider.instanceClass
          transforms:
            - type: map
              map:
                small: db.t3.micro
                medium: db.t3.medium
                large: db.t3.large
      connectionDetails:
        - type: FromFieldPath
          name: endpoint
          fromFieldPath: status.atProvider.endpoint
        - type: FromFieldPath
          name: port
          fromFieldPath: status.atProvider.port
    - name: subnet-group
      base:
        apiVersion: rds.aws.upbound.io/v1beta1
        kind: SubnetGroup
        spec:
          forProvider:
            region: us-east-1
            description: "Managed by Crossplane"
  writeConnectionSecretsToNamespace: crossplane-system
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
  name: xdatabase-pipeline
spec:
  compositeTypeRef:
    apiVersion: platform.example.com/v1alpha1
    kind: XDatabase
  mode: Pipeline
  pipeline:
    - step: patch-and-transform
      functionRef:
        name: function-patch-and-transform
      input:
        apiVersion: pt.fn.crossplane.io/v1beta1
        kind: Resources
        resources:
          - name: rds-instance
            base:
              apiVersion: rds.aws.upbound.io/v1beta1
              kind: Instance
              spec:
                forProvider:
                  engine: postgres
                  instanceClass: db.t3.micro
                  region: us-east-1
            patches:
              - type: FromCompositeFieldPath
                fromFieldPath: spec.parameters.storageGB
                toFieldPath: spec.forProvider.allocatedStorage
    - step: auto-ready
      functionRef:
        name: function-auto-detect-ready
CommandDescription
kubectl apply -f claim.yamlCreate a resource claim
kubectl get claimList all claims in namespace
kubectl get databaseList claims of type Database
kubectl describe claim my-databaseShow claim status and events
kubectl delete claim my-databaseDelete claim and managed resources
Set spec.compositionRef.name in claimSelect specific Composition
Set spec.compositionSelector.matchLabels in claimSelect Composition by labels
kubectl get events --field-selector involvedObject.name=my-dbView claim events
kubectl get secret my-db-conn -o jsonpath='{.data.endpoint}'Read connection details
apiVersion: platform.example.com/v1alpha1
kind: Database
metadata:
  name: my-app-db
  namespace: default
spec:
  parameters:
    engine: postgres
    engineVersion: "15"
    storageGB: 50
    instanceSize: medium
  compositionSelector:
    matchLabels:
      provider: aws
      engine: postgres
  writeConnectionSecretToRef:
    name: my-app-db-conn
CommandDescription
kubectl apply -f function.yamlInstall a Composition function
kubectl get functionsList installed functions
kubectl describe function function-patch-and-transformShow function details
crossplane beta render xr.yaml composition.yaml functions.yamlTest pipeline locally
# Install function-patch-and-transform
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.7.0
---
# Install function-auto-detect-ready
apiVersion: pkg.crossplane.io/v1beta1
kind: Function
metadata:
  name: function-auto-detect-ready
spec:
  package: xpkg.upbound.io/crossplane-contrib/function-auto-detect-ready:v0.2.1
---
# Install function-go-templating
apiVersion: pkg.crossplane.io/v1beta1
kind: Function
metadata:
  name: function-go-templating
spec:
  package: xpkg.upbound.io/crossplane-contrib/function-go-templating:v0.6.0
apiVersion: apiextensions.crossplane.io/v1alpha1
kind: EnvironmentConfig
metadata:
  name: production
data:
  region: us-east-1
  environment: production
  vpcId: vpc-0abc123def456
  subnetIds:
    - subnet-0abc123
    - subnet-0def456
    - subnet-0ghi789
  tags:
    team: platform
    costCenter: engineering
CommandDescription
kubectl create secret generic aws-creds -n crossplane-system --from-file=creds=./aws-creds.txtCreate provider credentials secret
Set spec.credentials.source: Secret in ProviderConfigReference credentials secret
kubectl apply -f environmentconfig.yamlCreate EnvironmentConfig
kubectl get storeconfigList store configurations
Set spec.publishConnectionDetailsTo in CompositionConfigure connection secret publishing
Set spec.writeConnectionSecretToRef in claimWrite connection details to secret
kubectl get secrets -l crossplane.io/claim-name=my-dbList secrets for a claim
apiVersion: secrets.crossplane.io/v1alpha1
kind: StoreConfig
metadata:
  name: vault
spec:
  type: Vault
  defaultScope: crossplane-system
  vault:
    mountPath: secret
    version: v2
    auth:
      method: Token
      token:
        source: Secret
        secretRef:
          namespace: crossplane-system
          name: vault-token
          key: token
CommandDescription
kubectl get managed -o wideShow managed resources with status
kubectl describe managedShow detailed managed resource info
kubectl logs -n crossplane-system deploy/crossplaneView Crossplane controller logs
kubectl logs -n crossplane-system deploy/crossplane -fFollow controller logs
kubectl get events --sort-by='.lastTimestamp'View recent cluster events
crossplane beta trace xdatabase my-dbTrace full resource tree
crossplane beta trace xdatabase my-db -o wideTrace with detailed status
kubectl get managed -l crossplane.io/composite=my-dbFind resources for a composite
kubectl annotate managed resource.api.example.com/name crossplane.io/paused=truePause resource reconciliation
kubectl annotate managed resource.api.example.com/name crossplane.io/paused-Resume resource reconciliation
CommandDescription
kubectl get providerrevisionCheck if provider is healthy
kubectl describe providerrevisionView provider install errors
kubectl get managed -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.conditions[*].reason}{"\n"}{end}'Quick status of all managed resources
kubectl patch managed resource.api.example.com/name --type merge -p '{"metadata":{"annotations":{"crossplane.io/paused":"true"}}}'Pause via patch
kubectl delete managed --allDelete all managed resources (use caution)
  1. Use Claims instead of direct Composites — claims are namespace-scoped and provide proper RBAC boundaries between teams.

  2. Pin provider versions — always specify exact provider versions to prevent unexpected changes during upgrades.

  3. Use Pipeline mode for new Compositions — Pipeline mode with functions is more flexible and testable than Resources mode.

  4. Implement EnvironmentConfigs — store shared environment data like VPC IDs and subnet lists to avoid duplication across Compositions.

  5. Set up connection secret publishing — always define writeConnectionSecretToRef in claims so applications can consume connection details.

  6. Use crossplane beta trace — this is the fastest way to debug issues by visualizing the entire resource tree from claim to managed resource.

  7. Label Compositions for selection — use labels like provider: aws and engine: postgres so claims can select Compositions by label rather than by name.

  8. Test locally with crossplane beta render — render your Compositions locally before applying them to a cluster.

  9. Implement readiness checks — use function-auto-detect-ready or custom readiness checks to ensure composite resources report accurate status.

  10. Version your XRDs — start with v1alpha1 and promote through v1beta1 to v1 as your API stabilizes.