Skip to content

Latest commit

 

History

History
83 lines (61 loc) · 3.32 KB

File metadata and controls

83 lines (61 loc) · 3.32 KB

Composite Resource Definitions - XRDs

XRDs can be created directly in Pkl or imported from Yaml.

Either can be converted to a Pkl Module.

Create a XRD (Skip if you already have a XRD)

When Creating a Pkl file ensure it amends CompositeResourceDefinition

amends "package://pkg.pkl-lang.org/github.com/crossplane-contrib/function-pkl/crospslane.contrib.xrd@<version>#/CompositeResourceDefinition.pkl"

view xrds/ExampleXR.pkl for more details on how to Build it.

running pkl eval xrds/ExampleXR.pkl renders the XRD in its Yaml manifest format.

Create a Module

Modules can be generated by creating a file like xrds/xrd2module.pkl and running pkl eval <filename> -m <outputDir>. This will create the Module in the Output directory. e.g. crds/XR.pkl was created by running:

pkl eval xrds/xrd2module.pkl -m crds

yaml manifests can be converted in the same way.

Create Managed Resource Modules

Managed Resources and any other CRDs can be converted similarly to XRDs by creating a file like crds/crd2module.pkl

pkl eval crds/crd2module.pkl -m crds

Create Pkl file for the Pipeline Step

The Pkl file referenced in the Composition must amend CompositionResponse.pkl.

The example at full.pkl gives an overview of what can be done.

CompositionResponse.pkl contains documentation on what the individual fields do.

The Observed State and other Parameters can be used to add Logic to the generated Response.

import "@crossplane.contrib/crossplane.pkl"
import "crds/XR.pkl"
local request = new crossplane {
  customResourceTemplates = new {
    ["XR"] {
      ["example.crossplane.io/v1"] = XR
    }
  }
}.Request

To Parse the Request into Pkl Language the XRD and all Managed Resources used must be declared in customResourceTemplates.

Create a Composition

The Composition itself can be created in yaml or in pkl. The latter is especially useful, if the the function is used with an inline Pkl file.

Create PklProject

PklProject contains the dependencies of the Project as well as Metadata on where it will be Published, version and name.

Resolve Dependencies

Running pkl project resolve will download the Project dependencies

Note: When having multiple Projects in a Repository, which have dependencies among each other use pkl project resolve ./*/ from the parent directory

Package Project

Run pkl project package to create releasable package artifacts.

Note: When having multiple Projects in a Repository, which have dependencies among each other use pkl project package ./*/ from the parent directory

Release Project

Pkl Packages can be released to any https server.

This Project uses the GitHub to store the artifacts within releases. Using pkg.pkl-lang.org as the domain helps with redirecting the requests from

When the Package is released it can be used in the Composition. See example/full/composition.yaml