Technology

Simplifying Developer Self-Service with Crossplane Compositions

February 22nd, 2024

Crossplane is an open-source project that extends the Kubernetes API to allow users to declaratively define and manage infrastructure resources using the familiar Kubernetes-style API and tools. It essentially brings a cloud-native approach to managing infrastructure and resources across various providers.

Crossplane Compositions are a feature within Crossplane that enables users to define and create complex infrastructure stacks by composing and reusing smaller, modular components. These components are often referred to as "Compositions" and can represent a variety of resources such as databases, storage systems, or other infrastructure elements.

Key concepts related to Crossplane Compositions include:

  1. Composition: A Composition is a Kubernetes custom resource (CR) that defines a set of infrastructure resources and their configurations. It acts as a blueprint for creating more complex infrastructure.

  2. Composite Resource Definition (XRD): An XRD is a Kubernetes custom resource definition that defines the structure and behavior of a composite resource, which is an instance of a Composition. It specifies how a Composition should be interpreted and translated into actual infrastructure resources.

  3. Composite Resource (XR): A Composite Resource is an instance of a Composition. When a Composition is applied, it creates a Composite Resource, which represents the actual infrastructure resources that need to be provisioned.

  4. Infrastructure Composition Controller: This controller is responsible for reconciling Composite Resources based on the definitions specified in Compositions.

By using Crossplane Compositions, users can break down complex infrastructure requirements into smaller, manageable pieces. These pieces can then be composed and reused across different projects or environments, promoting a modular and scalable approach to infrastructure management.

Example

This is the manifest for the "claim" this website has on an S3 storage bucket:

apiVersion: storage.circatree.net/v1beta1
kind: S3BucketClaim
metadata:
  name: circatree-com-web-assets
spec:
  name: "circatree-com-web-assets"
  writeConnectionSecretToRef:
    name: "circatree-com-web-assets-s3-details"

Adding this file to the repository for this website, triggered the creation of all the resources needed for this application to have access to durable storage that is specifically tuned for our organization. Every aspect of identity, networking, security, and retention are abstracted away from me as a developer.