Skip to content

Commit

Permalink
replace native patch&transform with composite functions
Browse files Browse the repository at this point in the history
- Remove deprecated native crossplane functions
- Update function usage across codebase
- Add patch&transform function to deployment
  • Loading branch information
mkfdoherty committed Dec 9, 2024
1 parent 4174a5c commit 56bace7
Show file tree
Hide file tree
Showing 18 changed files with 919 additions and 812 deletions.
6 changes: 6 additions & 0 deletions bind/deploy/functions/function-patch-and-transform.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: pkg.crossplane.io/v1
kind: Function
metadata:
name: function-patch-and-transform
spec:
package: xpkg.upbound.io/crossplane-contrib/function-patch-and-transform:v0.1.4
15 changes: 15 additions & 0 deletions crossplane-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,21 @@ Crossplane won't be able to manage RBAC dynamically. As a result, Compositions
will not be able to configure the provider-anynines managed resources due to
authorization issues.
##### Install Crossplane Functions
Additionally, we install composition functions. Composition functions (or simply “functions”) are Crossplane extensions that template Crossplane resources. Crossplane uses these functions to determine which resources to create when a composite resource (XR) is created. To verify that the composition functions are correctly installed, use the following command:
```bash
kubectl get function
```
Expected output:
```text
NAME INSTALLED HEALTHY PACKAGE AGE
function-patch-and-transform True True xpkg.upbound.io/crossplane-contrib/function-patch-and-transform:v0.1.4
```
#### Install ProviderConfig for provider-anynines
To configure the provider, based on your development environment, make sure to
Expand Down
107 changes: 57 additions & 50 deletions crossplane-api/api/a8s/backup/composition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,53 +6,60 @@ spec:
compositeTypeRef:
apiVersion: anynines.com/v1
kind: XBackup
resources:
- name: a8s-backup
base:
apiVersion: kubernetes.crossplane.io/v1alpha1
kind: Object
spec:
forProvider:
manifest:
apiVersion: backups.anynines.com/v1beta3
kind: Backup
providerConfigRef:
name: kubernetes-provider
patches:
- fromFieldPath: metadata.labels[crossplane.io/claim-namespace]
toFieldPath: spec.forProvider.manifest.metadata.namespace
- fromFieldPath: metadata.labels[crossplane.io/claim-name]
toFieldPath: spec.forProvider.manifest.metadata.name
- fromFieldPath: spec.serviceInstanceType
toFieldPath: spec.forProvider.manifest.spec.serviceInstance.apiGroup
transforms:
- type: map
map:
postgresql: postgresql.anynines.com
- fromFieldPath: spec.serviceInstanceType
toFieldPath: spec.forProvider.manifest.spec.serviceInstance.kind
transforms:
- type: map
map:
postgresql: PostgreSQL
- fromFieldPath: spec.instanceRef
toFieldPath: spec.forProvider.manifest.spec.serviceInstance.name
- type: ToCompositeFieldPath
fromFieldPath: status.atProvider.manifest.status.backupID
toFieldPath: status.managed.backupID
- type: ToCompositeFieldPath
fromFieldPath: status.atProvider.manifest.status.conditions
toFieldPath: status.managed.conditions
- type: ToCompositeFieldPath
fromFieldPath: status.atProvider.manifest.status.lastObservationTime
toFieldPath: status.managed.lastObservationTime
- type: ToCompositeFieldPath
fromFieldPath: status.atProvider.manifest.status.podUsedNamespacedName
toFieldPath: status.managed.podUsedNamespacedName
- type: ToCompositeFieldPath
fromFieldPath: status.atProvider.manifest.status.podUsedUID
toFieldPath: status.managed.podUsedUID
- type: ToCompositeFieldPath
fromFieldPath: status.atProvider.manifest.status.retries
toFieldPath: status.managed.retries

mode: Pipeline
pipeline:
- step: patch-and-transform
functionRef:
name: function-patch-and-transform
input:
apiVersion: pt.fn.crossplane.io/v1beta1
kind: Resources
resources:
- name: a8s-backup
base:
apiVersion: kubernetes.crossplane.io/v1alpha1
kind: Object
spec:
forProvider:
manifest:
apiVersion: backups.anynines.com/v1beta3
kind: Backup
providerConfigRef:
name: kubernetes-provider
patches:
- fromFieldPath: metadata.labels[crossplane.io/claim-namespace]
toFieldPath: spec.forProvider.manifest.metadata.namespace
- fromFieldPath: metadata.labels[crossplane.io/claim-name]
toFieldPath: spec.forProvider.manifest.metadata.name
- fromFieldPath: spec.serviceInstanceType
toFieldPath: spec.forProvider.manifest.spec.serviceInstance.apiGroup
transforms:
- type: map
map:
postgresql: postgresql.anynines.com
- fromFieldPath: spec.serviceInstanceType
toFieldPath: spec.forProvider.manifest.spec.serviceInstance.kind
transforms:
- type: map
map:
postgresql: PostgreSQL
- fromFieldPath: spec.instanceRef
toFieldPath: spec.forProvider.manifest.spec.serviceInstance.name
- type: ToCompositeFieldPath
fromFieldPath: status.atProvider.manifest.status.backupID
toFieldPath: status.managed.backupID
- type: ToCompositeFieldPath
fromFieldPath: status.atProvider.manifest.status.conditions
toFieldPath: status.managed.conditions
- type: ToCompositeFieldPath
fromFieldPath: status.atProvider.manifest.status.lastObservationTime
toFieldPath: status.managed.lastObservationTime
- type: ToCompositeFieldPath
fromFieldPath: status.atProvider.manifest.status.podUsedNamespacedName
toFieldPath: status.managed.podUsedNamespacedName
- type: ToCompositeFieldPath
fromFieldPath: status.atProvider.manifest.status.podUsedUID
toFieldPath: status.managed.podUsedUID
- type: ToCompositeFieldPath
fromFieldPath: status.atProvider.manifest.status.retries
toFieldPath: status.managed.retries
Loading

0 comments on commit 56bace7

Please sign in to comment.