From d9b783f7709f457f51dd6d2e244b16bb6040cfe9 Mon Sep 17 00:00:00 2001 From: Rishab49 <25582966+Rishab49@users.noreply.github.com> Date: Sat, 18 Apr 2026 22:33:40 +0530 Subject: [PATCH 1/2] making function-go-templating default tab in composition getting started guide Signed-off-by: Rishab49 <25582966+Rishab49@users.noreply.github.com> --- .../get-started-with-composition.md | 203 +++++++++--------- 1 file changed, 102 insertions(+), 101 deletions(-) diff --git a/content/v2.2/get-started/get-started-with-composition.md b/content/v2.2/get-started/get-started-with-composition.md index 4fd70411c..5f407e341 100644 --- a/content/v2.2/get-started/get-started-with-composition.md +++ b/content/v2.2/get-started/get-started-with-composition.md @@ -192,19 +192,20 @@ Pick what language to use to configure how Crossplane turns an `App` XR into a {{< tabs >}} -{{< tab "YAML" >}} -YAML is a good choice for small, static compositions. It doesn't support loops -or conditionals. -Create this composition function to install YAML support: +{{< tab "Templated YAML" >}} +Templated YAML is a good choice if you're used to writing +[Helm charts](https://helm.sh). + +Create this composition function to install templated YAML support: ```yaml apiVersion: pkg.crossplane.io/v1 kind: Function metadata: - name: crossplane-contrib-function-patch-and-transform + name: crossplane-contrib-function-go-templating spec: - package: xpkg.crossplane.io/crossplane-contrib/function-patch-and-transform:v0.8.2 + package: xpkg.crossplane.io/crossplane-contrib/function-go-templating:v0.9.2 ``` Save the function as `fn.yaml` and apply it: @@ -217,25 +218,24 @@ Check that Crossplane installed the function: ```shell {copy-lines="1"} kubectl get -f fn.yaml -NAME INSTALLED HEALTHY PACKAGE AGE -crossplane-contrib-function-patch-and-transform True True xpkg.crossplane.io/crossplane-contrib/function-patch-and-transform:v0.8.2 10s +NAME INSTALLED HEALTHY PACKAGE AGE +crossplane-contrib-function-go-templating True True xpkg.crossplane.io/crossplane-contrib/function-go-templating:v0.9.2 9s ``` {{< /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. +{{< tab "YAML" >}} +YAML is a good choice for small, static compositions. It doesn't support loops +or conditionals. -Create this composition function to install YAML+CEL support: +Create this composition function to install YAML support: ```yaml apiVersion: pkg.crossplane.io/v1 kind: Function metadata: - name: crossplane-contrib-function-kro + name: crossplane-contrib-function-patch-and-transform spec: - package: xpkg.crossplane.io/crossplane-contrib/function-kro:v0.1.0 + package: xpkg.crossplane.io/crossplane-contrib/function-patch-and-transform:v0.8.2 ``` Save the function as `fn.yaml` and apply it: @@ -248,24 +248,25 @@ 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 +NAME INSTALLED HEALTHY PACKAGE AGE +crossplane-contrib-function-patch-and-transform True True xpkg.crossplane.io/crossplane-contrib/function-patch-and-transform:v0.8.2 10s ``` {{< /tab >}} -{{< tab "Templated YAML" >}} -Templated YAML is a good choice if you're used to writing -[Helm charts](https://helm.sh). +{{< 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 templated YAML support: +Create this composition function to install YAML+CEL support: ```yaml apiVersion: pkg.crossplane.io/v1 kind: Function metadata: - name: crossplane-contrib-function-go-templating + name: crossplane-contrib-function-kro spec: - package: xpkg.crossplane.io/crossplane-contrib/function-go-templating:v0.9.2 + package: xpkg.crossplane.io/crossplane-contrib/function-kro:v0.1.0 ``` Save the function as `fn.yaml` and apply it: @@ -278,8 +279,8 @@ Check that Crossplane installed the function: ```shell {copy-lines="1"} kubectl get -f fn.yaml -NAME INSTALLED HEALTHY PACKAGE AGE -crossplane-contrib-function-go-templating True True xpkg.crossplane.io/crossplane-contrib/function-go-templating:v0.9.2 9s +NAME INSTALLED HEALTHY PACKAGE AGE +crossplane-contrib-function-kro True True xpkg.crossplane.io/crossplane-contrib/function-kro:v0.1.0 6s ``` {{< /tab >}} @@ -387,6 +388,82 @@ Create a composition to tell Crossplane what to do when you create or update an {{< tabs >}} +{{< tab "Templated YAML" >}} +Create this composition to use templated YAML to configure Crossplane: + +```yaml +apiVersion: apiextensions.crossplane.io/v1 +kind: Composition +metadata: + name: app-templated-yaml +spec: + compositeTypeRef: + apiVersion: example.crossplane.io/v1 + kind: App + mode: Pipeline + pipeline: + - step: create-deployment-and-service + functionRef: + name: crossplane-contrib-function-go-templating + input: + apiVersion: gotemplating.fn.crossplane.io/v1beta1 + kind: GoTemplate + source: Inline + inline: + template: | + --- + apiVersion: apps/v1 + kind: Deployment + metadata: + annotations: + gotemplating.fn.crossplane.io/composition-resource-name: deployment + {{ if eq (.observed.resources.deployment | getResourceCondition "Available").Status "True" }} + gotemplating.fn.crossplane.io/ready: "True" + {{ end }} + labels: + example.crossplane.io/app: {{ .observed.composite.resource.metadata.name }} + spec: + replicas: 2 + selector: + matchLabels: + example.crossplane.io/app: {{ .observed.composite.resource.metadata.name }} + template: + metadata: + labels: + example.crossplane.io/app: {{ .observed.composite.resource.metadata.name }} + spec: + containers: + - name: app + image: {{ .observed.composite.resource.spec.image }} + ports: + - containerPort: 80 + --- + apiVersion: v1 + kind: Service + metadata: + annotations: + gotemplating.fn.crossplane.io/composition-resource-name: service + {{ if (get (getComposedResource . "service").spec "clusterIP") }} + gotemplating.fn.crossplane.io/ready: "True" + {{ end }} + labels: + example.crossplane.io/app: {{ .observed.composite.resource.metadata.name }} + spec: + selector: + example.crossplane.io/app: {{ .observed.composite.resource.metadata.name }} + ports: + - protocol: TCP + port: 8080 + targetPort: 80 + --- + apiVersion: example.crossplane.io/v1 + kind: App + status: + replicas: {{ get (getComposedResource . "deployment").status "availableReplicas" | default 0 }} + address: {{ get (getComposedResource . "service").spec "clusterIP" | default "" | quote }} +``` +{{< /tab >}} + {{< tab "YAML" >}} Create this composition to use YAML to configure Crossplane: @@ -541,82 +618,6 @@ resource definitions work without changes. {{}} {{< /tab >}} -{{< tab "Templated YAML" >}} -Create this composition to use templated YAML to configure Crossplane: - -```yaml -apiVersion: apiextensions.crossplane.io/v1 -kind: Composition -metadata: - name: app-templated-yaml -spec: - compositeTypeRef: - apiVersion: example.crossplane.io/v1 - kind: App - mode: Pipeline - pipeline: - - step: create-deployment-and-service - functionRef: - name: crossplane-contrib-function-go-templating - input: - apiVersion: gotemplating.fn.crossplane.io/v1beta1 - kind: GoTemplate - source: Inline - inline: - template: | - --- - apiVersion: apps/v1 - kind: Deployment - metadata: - annotations: - gotemplating.fn.crossplane.io/composition-resource-name: deployment - {{ if eq (.observed.resources.deployment | getResourceCondition "Available").Status "True" }} - gotemplating.fn.crossplane.io/ready: "True" - {{ end }} - labels: - example.crossplane.io/app: {{ .observed.composite.resource.metadata.name }} - spec: - replicas: 2 - selector: - matchLabels: - example.crossplane.io/app: {{ .observed.composite.resource.metadata.name }} - template: - metadata: - labels: - example.crossplane.io/app: {{ .observed.composite.resource.metadata.name }} - spec: - containers: - - name: app - image: {{ .observed.composite.resource.spec.image }} - ports: - - containerPort: 80 - --- - apiVersion: v1 - kind: Service - metadata: - annotations: - gotemplating.fn.crossplane.io/composition-resource-name: service - {{ if (get (getComposedResource . "service").spec "clusterIP") }} - gotemplating.fn.crossplane.io/ready: "True" - {{ end }} - labels: - example.crossplane.io/app: {{ .observed.composite.resource.metadata.name }} - spec: - selector: - example.crossplane.io/app: {{ .observed.composite.resource.metadata.name }} - ports: - - protocol: TCP - port: 8080 - targetPort: 80 - --- - apiVersion: example.crossplane.io/v1 - kind: App - status: - replicas: {{ get (getComposedResource . "deployment").status "availableReplicas" | default 0 }} - address: {{ get (getComposedResource . "service").spec "clusterIP" | default "" | quote }} -``` -{{< /tab >}} - {{< tab "Python" >}} Create this composition to use Python to configure Crossplane: From 86f496a0dcaea44eb54955cc23ecee2cde148040 Mon Sep 17 00:00:00 2001 From: Rishab49 <25582966+Rishab49@users.noreply.github.com> Date: Wed, 22 Apr 2026 17:32:53 +0530 Subject: [PATCH 2/2] making function-go-templating default tab in composition getting started in master Signed-off-by: Rishab49 <25582966+Rishab49@users.noreply.github.com> --- .../get-started-with-composition.md | 202 +++++++++--------- 1 file changed, 101 insertions(+), 101 deletions(-) diff --git a/content/master/get-started/get-started-with-composition.md b/content/master/get-started/get-started-with-composition.md index 4fd70411c..51a73ee58 100644 --- a/content/master/get-started/get-started-with-composition.md +++ b/content/master/get-started/get-started-with-composition.md @@ -192,19 +192,19 @@ Pick what language to use to configure how Crossplane turns an `App` XR into a {{< tabs >}} -{{< tab "YAML" >}} -YAML is a good choice for small, static compositions. It doesn't support loops -or conditionals. +{{< tab "Templated YAML" >}} +Templated YAML is a good choice if you're used to writing +[Helm charts](https://helm.sh). -Create this composition function to install YAML support: +Create this composition function to install templated YAML support: ```yaml apiVersion: pkg.crossplane.io/v1 kind: Function metadata: - name: crossplane-contrib-function-patch-and-transform + name: crossplane-contrib-function-go-templating spec: - package: xpkg.crossplane.io/crossplane-contrib/function-patch-and-transform:v0.8.2 + package: xpkg.crossplane.io/crossplane-contrib/function-go-templating:v0.9.2 ``` Save the function as `fn.yaml` and apply it: @@ -217,25 +217,24 @@ Check that Crossplane installed the function: ```shell {copy-lines="1"} kubectl get -f fn.yaml -NAME INSTALLED HEALTHY PACKAGE AGE -crossplane-contrib-function-patch-and-transform True True xpkg.crossplane.io/crossplane-contrib/function-patch-and-transform:v0.8.2 10s +NAME INSTALLED HEALTHY PACKAGE AGE +crossplane-contrib-function-go-templating True True xpkg.crossplane.io/crossplane-contrib/function-go-templating:v0.9.2 9s ``` {{< /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. +{{< tab "YAML" >}} +YAML is a good choice for small, static compositions. It doesn't support loops +or conditionals. -Create this composition function to install YAML+CEL support: +Create this composition function to install YAML support: ```yaml apiVersion: pkg.crossplane.io/v1 kind: Function metadata: - name: crossplane-contrib-function-kro + name: crossplane-contrib-function-patch-and-transform spec: - package: xpkg.crossplane.io/crossplane-contrib/function-kro:v0.1.0 + package: xpkg.crossplane.io/crossplane-contrib/function-patch-and-transform:v0.8.2 ``` Save the function as `fn.yaml` and apply it: @@ -248,24 +247,25 @@ 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 +NAME INSTALLED HEALTHY PACKAGE AGE +crossplane-contrib-function-patch-and-transform True True xpkg.crossplane.io/crossplane-contrib/function-patch-and-transform:v0.8.2 10s ``` {{< /tab >}} -{{< tab "Templated YAML" >}} -Templated YAML is a good choice if you're used to writing -[Helm charts](https://helm.sh). +{{< 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 templated YAML support: +Create this composition function to install YAML+CEL support: ```yaml apiVersion: pkg.crossplane.io/v1 kind: Function metadata: - name: crossplane-contrib-function-go-templating + name: crossplane-contrib-function-kro spec: - package: xpkg.crossplane.io/crossplane-contrib/function-go-templating:v0.9.2 + package: xpkg.crossplane.io/crossplane-contrib/function-kro:v0.1.0 ``` Save the function as `fn.yaml` and apply it: @@ -278,8 +278,8 @@ Check that Crossplane installed the function: ```shell {copy-lines="1"} kubectl get -f fn.yaml -NAME INSTALLED HEALTHY PACKAGE AGE -crossplane-contrib-function-go-templating True True xpkg.crossplane.io/crossplane-contrib/function-go-templating:v0.9.2 9s +NAME INSTALLED HEALTHY PACKAGE AGE +crossplane-contrib-function-kro True True xpkg.crossplane.io/crossplane-contrib/function-kro:v0.1.0 6s ``` {{< /tab >}} @@ -387,6 +387,82 @@ Create a composition to tell Crossplane what to do when you create or update an {{< tabs >}} +{{< tab "Templated YAML" >}} +Create this composition to use templated YAML to configure Crossplane: + +```yaml +apiVersion: apiextensions.crossplane.io/v1 +kind: Composition +metadata: + name: app-templated-yaml +spec: + compositeTypeRef: + apiVersion: example.crossplane.io/v1 + kind: App + mode: Pipeline + pipeline: + - step: create-deployment-and-service + functionRef: + name: crossplane-contrib-function-go-templating + input: + apiVersion: gotemplating.fn.crossplane.io/v1beta1 + kind: GoTemplate + source: Inline + inline: + template: | + --- + apiVersion: apps/v1 + kind: Deployment + metadata: + annotations: + gotemplating.fn.crossplane.io/composition-resource-name: deployment + {{ if eq (.observed.resources.deployment | getResourceCondition "Available").Status "True" }} + gotemplating.fn.crossplane.io/ready: "True" + {{ end }} + labels: + example.crossplane.io/app: {{ .observed.composite.resource.metadata.name }} + spec: + replicas: 2 + selector: + matchLabels: + example.crossplane.io/app: {{ .observed.composite.resource.metadata.name }} + template: + metadata: + labels: + example.crossplane.io/app: {{ .observed.composite.resource.metadata.name }} + spec: + containers: + - name: app + image: {{ .observed.composite.resource.spec.image }} + ports: + - containerPort: 80 + --- + apiVersion: v1 + kind: Service + metadata: + annotations: + gotemplating.fn.crossplane.io/composition-resource-name: service + {{ if (get (getComposedResource . "service").spec "clusterIP") }} + gotemplating.fn.crossplane.io/ready: "True" + {{ end }} + labels: + example.crossplane.io/app: {{ .observed.composite.resource.metadata.name }} + spec: + selector: + example.crossplane.io/app: {{ .observed.composite.resource.metadata.name }} + ports: + - protocol: TCP + port: 8080 + targetPort: 80 + --- + apiVersion: example.crossplane.io/v1 + kind: App + status: + replicas: {{ get (getComposedResource . "deployment").status "availableReplicas" | default 0 }} + address: {{ get (getComposedResource . "service").spec "clusterIP" | default "" | quote }} +``` +{{< /tab >}} + {{< tab "YAML" >}} Create this composition to use YAML to configure Crossplane: @@ -541,82 +617,6 @@ resource definitions work without changes. {{}} {{< /tab >}} -{{< tab "Templated YAML" >}} -Create this composition to use templated YAML to configure Crossplane: - -```yaml -apiVersion: apiextensions.crossplane.io/v1 -kind: Composition -metadata: - name: app-templated-yaml -spec: - compositeTypeRef: - apiVersion: example.crossplane.io/v1 - kind: App - mode: Pipeline - pipeline: - - step: create-deployment-and-service - functionRef: - name: crossplane-contrib-function-go-templating - input: - apiVersion: gotemplating.fn.crossplane.io/v1beta1 - kind: GoTemplate - source: Inline - inline: - template: | - --- - apiVersion: apps/v1 - kind: Deployment - metadata: - annotations: - gotemplating.fn.crossplane.io/composition-resource-name: deployment - {{ if eq (.observed.resources.deployment | getResourceCondition "Available").Status "True" }} - gotemplating.fn.crossplane.io/ready: "True" - {{ end }} - labels: - example.crossplane.io/app: {{ .observed.composite.resource.metadata.name }} - spec: - replicas: 2 - selector: - matchLabels: - example.crossplane.io/app: {{ .observed.composite.resource.metadata.name }} - template: - metadata: - labels: - example.crossplane.io/app: {{ .observed.composite.resource.metadata.name }} - spec: - containers: - - name: app - image: {{ .observed.composite.resource.spec.image }} - ports: - - containerPort: 80 - --- - apiVersion: v1 - kind: Service - metadata: - annotations: - gotemplating.fn.crossplane.io/composition-resource-name: service - {{ if (get (getComposedResource . "service").spec "clusterIP") }} - gotemplating.fn.crossplane.io/ready: "True" - {{ end }} - labels: - example.crossplane.io/app: {{ .observed.composite.resource.metadata.name }} - spec: - selector: - example.crossplane.io/app: {{ .observed.composite.resource.metadata.name }} - ports: - - protocol: TCP - port: 8080 - targetPort: 80 - --- - apiVersion: example.crossplane.io/v1 - kind: App - status: - replicas: {{ get (getComposedResource . "deployment").status "availableReplicas" | default 0 }} - address: {{ get (getComposedResource . "service").spec "clusterIP" | default "" | quote }} -``` -{{< /tab >}} - {{< tab "Python" >}} Create this composition to use Python to configure Crossplane: