An introductory example to Crossplane and Compositions using provider-nop. This will enable provisioning of several different fake resource types.
This repository contains a reference configuration for Crossplane v2. This configuration is built with provider-nop, a Crossplane provider that simulates the creation of external resources. All composite resources are namespaced — claims are not used (they don't exist in Crossplane v2).
This platform offers APIs for setting up a variety of basic resources that mirror what you'd find in a Cloud Service Provider such as AWS, Azure, or GCP. The resource types include:
- Cluster, a resource that loosely represents a Kubernetes cluster.
- NodePool, a resource that loosely represents a Nodepool in a Kubernetes cluster.
- Database, a resource that loosely represents a cloud database.
- Network, a resource that loosely represents a cloud network resource.
- Subnetwork, a resource that loosely represents a subnetwork resource within a cloud network.
- ServiceAccount, a resource that loosely represents a service account in the cloud.
This configuration also demonstrates the power of Crossplane to build abstractions called "compositions", which assemble multiple basic resources into a more complex resource. These are demonstrated with:
- CompositeCluster, a resource abstraction that composes a cluster, nodepool, network, subnetwork, and service account.
- AccountScaffold, a resource abstraction that composes a service account, network, and subnetwork.
Learn more about Composite Resources in the Crossplane Docs.
You need a running Crossplane v2 control plane. You can create a managed control plane on Upbound, or run upstream Crossplane locally with kind.
Install the up CLI:
curl -sL https://cli.upbound.io | shSee up docs for more install options.
Alternatively, install the Crossplane CLI:
curl -sL https://raw.githubusercontent.com/crossplane/crossplane/master/install.sh | shInstall the configuration package:
kubectl apply -f - <<EOF
apiVersion: pkg.crossplane.io/v1
kind: Configuration
metadata:
name: configuration-getting-started
spec:
package: xpkg.upbound.io/upbound/configuration-getting-started:v1.0.0
EOFWait for the configuration and all dependencies to become healthy:
kubectl get configurations,providers,functionsVerify all XRDs are established:
kubectl get xrdYou should see 8 XRDs, all with ESTABLISHED=True and an empty OFFERED column (no claims in v2).
All resources are namespaced in Crossplane v2 — you apply XRs directly to a namespace instead of creating claims.
Create a custom defined cluster:
kubectl apply -f examples/cluster/xr.yamlCreate a custom defined database:
kubectl apply -f examples/database/xr.yamlCreate a composite cluster (composes 5 nested XRs):
kubectl apply -f examples/compositecluster/xr.yamlYou can verify the status by inspecting the composite and managed resources:
kubectl get managed,composite -n defaultTo delete the provisioned resources:
kubectl delete -f examples/cluster/xr.yaml
kubectl delete -f examples/database/xr.yaml
kubectl delete -f examples/compositecluster/xr.yamlTo uninstall the configuration:
kubectl delete configurations.pkg.crossplane.io configuration-getting-startedRender compositions locally:
make renderRun end-to-end tests:
make e2eNote: The
rendertarget uses thecrossplaneCLI under the hood (crossplane render), which has noupequivalent for classic configuration packages.
We recommend you check out one of Upbound's platform reference architectures to learn how to use Crossplane to provision real external resources:
For any questions, thoughts and comments don't hesitate to reach out or drop by slack.crossplane.io, and say hi!