|
| 1 | +--- |
| 2 | +title: Functions |
| 3 | +weight: 100 |
| 4 | +description: "Functions extend Crossplane with new ways to configure composition" |
| 5 | +--- |
| 6 | + |
| 7 | +Functions extend Crossplane with new ways to configure |
| 8 | +[composition]({{<ref "../composition">}}). |
| 9 | + |
| 10 | +You can use different _composition functions_ to configure what Crossplane does |
| 11 | +when someone creates or updates a |
| 12 | +[composite resource (XR)]({{<ref "../composition/composite-resources">}}). |
| 13 | + |
| 14 | +{{<hint "important">}} |
| 15 | +This page is a work in progress. |
| 16 | + |
| 17 | +Functions are packages, like [Providers]({{<ref "./providers">}}) and |
| 18 | +[Configurations]({{<ref "./configurations">}}). Their APIs are similar. You |
| 19 | +install and configure them the same way as a provider. |
| 20 | + |
| 21 | +Read the [composition]({{<ref "../composition/compositions">}}) documentation to |
| 22 | +learn how to use functions in a composition. |
| 23 | +{{</hint>}} |
| 24 | + |
| 25 | +## Install a Function |
| 26 | + |
| 27 | +Install a Function with a Crossplane |
| 28 | +{{<hover label="install" line="2">}}Function{{</hover >}} object setting the |
| 29 | +{{<hover label="install" line="6">}}spec.package{{</hover >}} value to the |
| 30 | +location of the function package. |
| 31 | + |
| 32 | +{{< hint "important" >}} |
| 33 | +Beginning with Crossplane version 1.20.0 Crossplane uses the [crossplane-contrib](https://github.com/orgs/crossplane-contrib/packages) GitHub Container Registry at `xpkg.crossplane.io` by default for downloading and |
| 34 | +installing packages. |
| 35 | + |
| 36 | +Specify the full domain name with the `package` or change the default Crossplane |
| 37 | +registry with the `--registry` flag on the [Crossplane pod]({{<ref "../guides/pods">}}) |
| 38 | +{{< /hint >}} |
| 39 | + |
| 40 | +For example, to install the |
| 41 | +[patch and transform function](https://github.com/crossplane-contrib/function-patch-and-transform), |
| 42 | + |
| 43 | +```yaml {label="install"} |
| 44 | +apiVersion: pkg.crossplane.io/v1 |
| 45 | +kind: Function |
| 46 | +metadata: |
| 47 | + name: crossplane-contrib-function-patch-and-transform |
| 48 | +spec: |
| 49 | + package: xpkg.crossplane.io/crossplane-contrib/function-patch-and-transform:v0.8.2 |
| 50 | +``` |
| 51 | +
|
| 52 | +By default, the Function pod installs in the same namespace as Crossplane |
| 53 | +(`crossplane-system`). |
| 54 | + |
| 55 | +{{<hint "note" >}} |
| 56 | +Functions are part of the |
| 57 | +{{<hover label="install" line="1">}}pkg.crossplane.io{{</hover>}} group. |
| 58 | + |
| 59 | +The {{<hover label="meta-pkg" line="1">}}meta.pkg.crossplane.io{{</hover>}} |
| 60 | +group is for creating Function packages. |
| 61 | + |
| 62 | +Instructions on building Functions are outside of the scope of this |
| 63 | +document. |
| 64 | +Read the Crossplane contributing |
| 65 | +[Function Development Guide](https://github.com/crossplane/crossplane/blob/main/contributing/guide-provider-development.md) |
| 66 | +for more information. |
| 67 | + |
| 68 | +For information on the specification of Function packages read the |
| 69 | +[Crossplane Function Package specification](https://github.com/crossplane/crossplane/blob/main/contributing/specifications/xpkg.md#provider-package-requirements). |
| 70 | + |
| 71 | +```yaml {label="meta-pkg"} |
| 72 | +apiVersion: meta.pkg.crossplane.io/v1 |
| 73 | +kind: Function |
| 74 | +metadata: |
| 75 | + name: provider-aws |
| 76 | +spec: |
| 77 | +# Removed for brevity |
| 78 | +``` |
| 79 | +{{</hint >}} |
0 commit comments