Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 110 additions & 4 deletions content/master/get-started/get-started-with-composition.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ user calls the custom resource API to create an `App`, Crossplane creates a


{{<hint "tip">}}
The guide shows how to configure composition using YAML, templated YAML, Python,
and KCL. You can pick your preferred language.
The guide shows how to configure composition using YAML, YAML+CEL, templated
YAML, Python, and KCL. You can pick your preferred language.
{{</hint>}}

An `App` custom resource looks like this:
Expand Down Expand Up @@ -222,6 +222,37 @@ crossplane-contrib-function-patch-and-transform True True xpkg.cro
```
{{< /tab >}}

{{< tab "YAML+CEL" >}}
YAML+CEL is a good choice for defining resources in plain YAML and wiring them
together with CEL expressions. The function resolves dependencies between
resources automatically.

Create this composition function to install YAML+CEL support:

```yaml
apiVersion: pkg.crossplane.io/v1
kind: Function
metadata:
name: crossplane-contrib-function-kro
spec:
package: xpkg.crossplane.io/crossplane-contrib/function-kro:v0.1.0
```

Save the function as `fn.yaml` and apply it:

```shell
kubectl apply -f fn.yaml
```

Check that Crossplane installed the function:

```shell {copy-lines="1"}
kubectl get -f fn.yaml
NAME INSTALLED HEALTHY PACKAGE AGE
crossplane-contrib-function-kro True True xpkg.crossplane.io/crossplane-contrib/function-kro:v0.1.0 6s
```
{{< /tab >}}

{{< tab "Templated YAML" >}}
Templated YAML is a good choice if you're used to writing
[Helm charts](https://helm.sh).
Expand Down Expand Up @@ -435,6 +466,81 @@ spec:
```
{{< /tab >}}

{{< tab "YAML+CEL" >}}
Create this composition to use YAML and CEL to configure Crossplane. Define
resources in YAML, wire them with CEL expressions, and let Crossplane handle
the rest.

```yaml
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: app-yaml-cel
spec:
compositeTypeRef:
apiVersion: example.crossplane.io/v1
kind: App
mode: Pipeline
pipeline:
- step: create-deployment-and-service
functionRef:
name: crossplane-contrib-function-kro
input:
apiVersion: kro.fn.crossplane.io/v1beta1
kind: ResourceGraph
status:
replicas: ${deployment.status.?availableReplicas.orValue(0)}
address: ${service.spec.?clusterIP.orValue("")}
resources:
- id: deployment
template:
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
example.crossplane.io/app: ${schema.metadata.name}
spec:
replicas: 2
selector:
matchLabels:
example.crossplane.io/app: ${schema.metadata.name}
template:
metadata:
labels:
example.crossplane.io/app: ${schema.metadata.name}
spec:
containers:
- name: app
image: ${schema.spec.image}
ports:
- containerPort: 80
readyWhen:
- ${deployment.status.?conditions.orValue([]).exists(c, c.type == "Available" && c.status == "True")}
- id: service
template:
apiVersion: v1
kind: Service
metadata:
labels:
example.crossplane.io/app: ${schema.metadata.name}
spec:
selector:
example.crossplane.io/app: ${schema.metadata.name}
ports:
- protocol: TCP
port: 8080
targetPort: 80
readyWhen:
- ${service.spec.?clusterIP.hasValue()}
```

{{<hint "tip">}}
This function uses the same resource graph syntax as
[kro](https://github.com/crossplane-contrib/function-kro), so existing kro
resource definitions work without changes.
{{</hint>}}
{{< /tab >}}

{{< tab "Templated YAML" >}}
Create this composition to use templated YAML to configure Crossplane:

Expand Down Expand Up @@ -666,7 +772,7 @@ spec:
observed_service = option("params").ocds["service"]?.Resource
if observed_service?.spec?.clusterIP:
_desired_service.metadata.annotations["krm.kcl.dev/ready"] = "True"

_desired_xr = {
**option("params").dxr

Expand Down Expand Up @@ -810,7 +916,7 @@ When you delete the `App`, Crossplane deletes the `Deployment` and `Service`.

## Next steps

Managed resources (MRs) are ready-made Kubernetes custom resources.
Managed resources (MRs) are ready-made Kubernetes custom resources.

Crossplane has an extensive library of managed resources you can use to manage
almost any cloud provider, or cloud native software.
Expand Down
1 change: 1 addition & 0 deletions content/master/learn/community-extension-projects.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ use by Crossplane adopters.
- [function-go-templating](https://github.com/crossplane-contrib/function-go-templating)
- [function-hcl](https://github.com/crossplane-contrib/function-hcl)
- [function-kcl](https://github.com/crossplane-contrib/function-kcl)
- [function-kro](https://github.com/crossplane-contrib/function-kro)
- [function-patch-and-transform](https://github.com/crossplane-contrib/function-patch-and-transform)
- [function-python](https://github.com/crossplane-contrib/function-python)
- [function-pythonic](https://github.com/crossplane-contrib/function-pythonic)
Expand Down
114 changes: 110 additions & 4 deletions content/v2.2/get-started/get-started-with-composition.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ user calls the custom resource API to create an `App`, Crossplane creates a


{{<hint "tip">}}
The guide shows how to configure composition using YAML, templated YAML, Python,
and KCL. You can pick your preferred language.
The guide shows how to configure composition using YAML, YAML+CEL, templated
YAML, Python, and KCL. You can pick your preferred language.
{{</hint>}}

An `App` custom resource looks like this:
Expand Down Expand Up @@ -222,6 +222,37 @@ crossplane-contrib-function-patch-and-transform True True xpkg.cro
```
{{< /tab >}}

{{< tab "YAML+CEL" >}}
YAML+CEL is a good choice for defining resources in plain YAML and wiring them
together with CEL expressions. The function resolves dependencies between
resources automatically.

Create this composition function to install YAML+CEL support:

```yaml
apiVersion: pkg.crossplane.io/v1
kind: Function
metadata:
name: crossplane-contrib-function-kro
spec:
package: xpkg.crossplane.io/crossplane-contrib/function-kro:v0.1.0
```

Save the function as `fn.yaml` and apply it:

```shell
kubectl apply -f fn.yaml
```

Check that Crossplane installed the function:

```shell {copy-lines="1"}
kubectl get -f fn.yaml
NAME INSTALLED HEALTHY PACKAGE AGE
crossplane-contrib-function-kro True True xpkg.crossplane.io/crossplane-contrib/function-kro:v0.1.0 6s
```
{{< /tab >}}

{{< tab "Templated YAML" >}}
Templated YAML is a good choice if you're used to writing
[Helm charts](https://helm.sh).
Expand Down Expand Up @@ -435,6 +466,81 @@ spec:
```
{{< /tab >}}

{{< tab "YAML+CEL" >}}
Create this composition to use YAML and CEL to configure Crossplane. Define
resources in YAML, wire them with CEL expressions, and let Crossplane handle
the rest.

```yaml
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: app-yaml-cel
spec:
compositeTypeRef:
apiVersion: example.crossplane.io/v1
kind: App
mode: Pipeline
pipeline:
- step: create-deployment-and-service
functionRef:
name: crossplane-contrib-function-kro
input:
apiVersion: kro.fn.crossplane.io/v1beta1
kind: ResourceGraph
status:
replicas: ${deployment.status.?availableReplicas.orValue(0)}
address: ${service.spec.?clusterIP.orValue("")}
resources:
- id: deployment
template:
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
example.crossplane.io/app: ${schema.metadata.name}
spec:
replicas: 2
selector:
matchLabels:
example.crossplane.io/app: ${schema.metadata.name}
template:
metadata:
labels:
example.crossplane.io/app: ${schema.metadata.name}
spec:
containers:
- name: app
image: ${schema.spec.image}
ports:
- containerPort: 80
readyWhen:
- ${deployment.status.?conditions.orValue([]).exists(c, c.type == "Available" && c.status == "True")}
- id: service
template:
apiVersion: v1
kind: Service
metadata:
labels:
example.crossplane.io/app: ${schema.metadata.name}
spec:
selector:
example.crossplane.io/app: ${schema.metadata.name}
ports:
- protocol: TCP
port: 8080
targetPort: 80
readyWhen:
- ${service.spec.?clusterIP.hasValue()}
```

{{<hint "tip">}}
This function uses the same resource graph syntax as
[kro](https://github.com/crossplane-contrib/function-kro), so existing kro
resource definitions work without changes.
{{</hint>}}
{{< /tab >}}

{{< tab "Templated YAML" >}}
Create this composition to use templated YAML to configure Crossplane:

Expand Down Expand Up @@ -666,7 +772,7 @@ spec:
observed_service = option("params").ocds["service"]?.Resource
if observed_service?.spec?.clusterIP:
_desired_service.metadata.annotations["krm.kcl.dev/ready"] = "True"

_desired_xr = {
**option("params").dxr

Expand Down Expand Up @@ -810,7 +916,7 @@ When you delete the `App`, Crossplane deletes the `Deployment` and `Service`.

## Next steps

Managed resources (MRs) are ready-made Kubernetes custom resources.
Managed resources (MRs) are ready-made Kubernetes custom resources.

Crossplane has an extensive library of managed resources you can use to manage
almost any cloud provider, or cloud native software.
Expand Down
1 change: 1 addition & 0 deletions content/v2.2/learn/community-extension-projects.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ use by Crossplane adopters.
- [function-go-templating](https://github.com/crossplane-contrib/function-go-templating)
- [function-hcl](https://github.com/crossplane-contrib/function-hcl)
- [function-kcl](https://github.com/crossplane-contrib/function-kcl)
- [function-kro](https://github.com/crossplane-contrib/function-kro)
- [function-patch-and-transform](https://github.com/crossplane-contrib/function-patch-and-transform)
- [function-python](https://github.com/crossplane-contrib/function-python)
- [function-pythonic](https://github.com/crossplane-contrib/function-pythonic)
Expand Down
3 changes: 3 additions & 0 deletions utils/vale/styles/Crossplane/crossplane-words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ fromFieldPath
function-environment-configs
function-extra-resources
function-go-templating
function-kro
function-patch-and-transform
function-python
function-template-python
Expand All @@ -63,6 +64,7 @@ ImageConfigs
InactivePackageRevision
initProvider
KCL
kro
LateInitialize
ManagedResourceActivationPolicies
ManagedResourceActivationPolicy
Expand Down Expand Up @@ -115,3 +117,4 @@ XRD's
XRDs
XR's
XRs
YAML+CEL
Loading