Notice something off about this package? Help us keep the marketplace safe and trustworthy by reporting inappropriate content or behavior.
Report this packageThis composition function automatically detects composed resources that are ready. It considers a composed resource ready if:
type: Ready, status: True.Crossplane considers a composite resource (XR) to be ready when all of its desired composed resources are ready.
This function implements resource-specific health checks for standard Kubernetes resources. The following table shows the current implementation status:
spec.replicas == status.availableReplicas, all replicas updated, Available condition is Truespec.replicas == status.readyReplicas, all replicas at current revisionFor all other resource types (Crossplane managed resources, custom resources, etc.), the function falls back to checking the standard Ready status condition.
In this example, the Go Templating function is used to add a desired composed resource - an Amazon Web Services S3 Bucket. Once Crossplane has created the Bucket, the Auto Ready function will let Crossplane know when it is ready. Because this XR only has one composed resource, the XR will become ready when the Bucket becomes ready.
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: example
spec:
compositeTypeRef:
apiVersion: example.crossplane.io/v1beta1
kind: XR
mode: Pipeline
pipeline:
- step: create-a-bucket
functionRef:
name: function-go-templating
input:
apiVersion: gotemplating.fn.crossplane.io/v1beta1
kind: GoTemplate
source: Inline
inline:
template: |
apiVersion: s3.aws.upbound.io/v1beta1
kind: Bucket
metadata:
annotations:
gotemplating.fn.crossplane.io/composition-resource-name: bucket
spec:
forProvider:
region: {{ .observed.composite.resource.spec.region }}
- step: automatically-detect-ready-composed-resources
functionRef:
name: function-auto-ready
See the example directory for an example you can run locally using the Crossplane CLI:
$ crossplane render xr.yaml composition.yaml functions.yaml
To test with observed resources (simulating resources that already exist):
$ crossplane render xr.yaml composition-k8s.yaml functions.yaml -o observed-k8s.yaml
See the composition functions documentation to learn more
about crossplane render.
This function uses Go, Docker, and the Crossplane CLI to build functions.
# Run code generation - see input/generate.go
$ go generate ./...
# Run tests - see fn_test.go
$ go test ./...
# Build the function's runtime image - see Dockerfile
$ docker build . --tag=runtime
# Build a function package - see package/crossplane.yaml
$ crossplane xpkg build -f package --embed-runtime-image=runtime