Skip to content

Commit

Permalink
Merge pull request #22 from phisco/kubecon-2024-demo
Browse files Browse the repository at this point in the history
docs: add examples for kubecon 2024 demo
  • Loading branch information
phisco authored Mar 19, 2024
2 parents 22ffc74 + 50d356a commit 63571bc
Show file tree
Hide file tree
Showing 8 changed files with 202 additions and 0 deletions.
46 changes: 46 additions & 0 deletions example/kubecon-2024/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Example manifests

Before, one had to define references at `spec.environment.environmentConfigs`,
see [./old/composition.yaml]() and needed to have Crossplane actually deployed
to be able to validate that part of the logic.

The same can now be achieved using `function-environment-config`, which allows
to leverage the power of `crossplane beta render`:

```shell
$ crossplane beta render \
--extra-resources environmentConfigs.yaml \
--include-context \
xr.yaml composition.yaml functions.yaml
```

Which will output both the `Context` containing the `environment` and the `XR`
itself:

```yaml
---
apiVersion: example.crossplane.io/v1
kind: XR
metadata:
name: example-xr
status:
conditions:
- lastTransitionTime: "2024-01-01T00:00:00Z"
reason: Available
status: "True"
type: Ready
fromEnv: by-label
---
apiVersion: render.crossplane.io/v1beta1
kind: Context
fields:
apiextensions.crossplane.io/environment:
apiVersion: internal.crossplane.io/v1alpha1
kind: Environment
complex:
a: b
c:
d: by-label
f: "1"
g: by-label
```
42 changes: 42 additions & 0 deletions example/kubecon-2024/composition.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: function-environment-configs
spec:
compositeTypeRef:
apiVersion: example.crossplane.io/v1
kind: XR
mode: Pipeline
pipeline:
- step: environmentConfigs
functionRef:
name: function-environment-configs
input:
apiVersion: environmentconfigs.fn.crossplane.io/v1beta1
kind: Input
spec:
environmentConfigs:
- type: Reference
ref:
name: example-config
- type: Selector
selector:
mode: Single
matchLabels:
- type: Value
key: org
value: foo
- step: go-templating
functionRef:
name: function-go-templating
input:
apiVersion: gotemplating.fn.crossplane.io/v1beta1
kind: GoTemplate
source: Inline
inline:
template: |
---
apiVersion: example.crossplane.io/v1
kind: XR
status:
fromEnv: {{ index .context "apiextensions.crossplane.io/environment" "complex" "c" "d" }}
23 changes: 23 additions & 0 deletions example/kubecon-2024/environmentConfigs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
apiVersion: apiextensions.crossplane.io/v1alpha1
kind: EnvironmentConfig
metadata:
name: example-config
data:
complex:
a: b
c:
d: e
f: "1"
---
apiVersion: apiextensions.crossplane.io/v1alpha1
kind: EnvironmentConfig
metadata:
name: example-config-by-label
labels:
org: foo
data:
complex:
c:
d: by-label
g: by-label
14 changes: 14 additions & 0 deletions example/kubecon-2024/functions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
apiVersion: pkg.crossplane.io/v1beta1
kind: Function
metadata:
name: function-environment-configs
spec:
package: xpkg.upbound.io/crossplane-contrib/function-environment-configs:v0.0.4
---
apiVersion: pkg.crossplane.io/v1beta1
kind: Function
metadata:
name: function-go-templating
spec:
package: xpkg.upbound.io/crossplane-contrib/function-go-templating:v0.4.1
38 changes: 38 additions & 0 deletions example/kubecon-2024/old/composition.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: function-environment-configs
spec:
environment:
environmentConfigs:
- type: Reference
ref:
name: example-config
- type: Selector
selector:
mode: Single
matchLabels:
- type: Value
key: org
value: foo
policy:
resolve: Always
compositeTypeRef:
apiVersion: example.crossplane.io/v1
kind: XR
mode: Pipeline
pipeline:
- step: go-templating
functionRef:
name: function-go-templating
input:
apiVersion: gotemplating.fn.crossplane.io/v1beta1
kind: GoTemplate
source: Inline
inline:
template: |
---
apiVersion: example.crossplane.io/v1
kind: XR
status:
fromEnv: {{ index .context "apiextensions.crossplane.io/environment" "complex" "c" "d" }}
8 changes: 8 additions & 0 deletions example/kubecon-2024/provider.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
name: provider-nop
spec:
package: xpkg.upbound.io/crossplane-contrib/provider-nop:v0.2.1
ignoreCrossplaneConstraints: true
6 changes: 6 additions & 0 deletions example/kubecon-2024/xr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Replace this with your XR!
apiVersion: example.crossplane.io/v1
kind: XR
metadata:
name: example-xr
spec: {}
25 changes: 25 additions & 0 deletions example/kubecon-2024/xrd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
apiVersion: apiextensions.crossplane.io/v1
kind: CompositeResourceDefinition
metadata:
name: xrs.example.crossplane.io
spec:
group: example.crossplane.io
names:
kind: XR
plural: xrs
connectionSecretKeys:
- test
versions:
- name: v1
served: true
referenceable: true
schema:
openAPIV3Schema:
type: object
properties:
status:
type: object
properties:
fromEnv:
type: string

0 comments on commit 63571bc

Please sign in to comment.