Skip to content

Commit e5b9483

Browse files
authored
feat: update Function CRD to use packageRef instead of package field (#204)
### Motivation The Function CRD was using a simple `package` field as a string, which limited the ability to reference Package resources across namespaces and didn't follow Kubernetes best practices for resource references. This change updates the Function CRD to use a proper `packageRef` object that includes both name and namespace fields, allowing for better resource management and cross-namespace package references. ### Modifications - **Updated Function CRD schema**: Changed the `package` field from a simple string to a `packageRef` object with `name` and `namespace` properties - **Enhanced developer documentation**: Added a new section in `operator/DEVELOPER.md` explaining the process for updating CRD definitions and ensuring Helm chart templates stay in sync - **Updated Helm chart templates**: Modified the CRD template in `operator/deploy/chart/templates/crd/fs.functionstream.github.io_functions.yaml` to reflect the new schema structure The changes ensure that: - Functions can now reference Package resources across different namespaces - The CRD follows Kubernetes conventions for resource references - Developers have clear guidance on maintaining CRD and Helm chart consistency - Both direct CRD installation and Helm chart installation will have consistent behavior
1 parent 985bd76 commit e5b9483

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

operator/DEVELOPER.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,17 @@ is manually re-applied afterwards.
109109

110110
**NOTE:** Run `make help` for more information on all potential `make` targets
111111

112+
### CRD Updates
113+
114+
When CRD definitions are updated in `operator/config/crd/bases/`, you need to ensure the Helm chart CRD templates are also updated to match. The Helm chart CRD templates are located in `operator/deploy/chart/templates/crd/`.
115+
116+
To update the Helm chart CRD templates:
117+
118+
1. Update the CRD definitions in `operator/config/crd/bases/`
119+
2. Manually update the corresponding files in `operator/deploy/chart/templates/crd/` to match the base definitions
120+
3. Ensure any Helm-specific templating (like `{{- if .Values.crd.enable }}`) is preserved
121+
4. Test the changes to ensure the CRDs work correctly
122+
123+
**Important:** The Helm chart CRD templates should always reflect the latest changes from the base CRD definitions to ensure consistency between direct CRD installation and Helm chart installation.
124+
112125
More information can be found via the [Kubebuilder Documentation](https://book.kubebuilder.io/introduction.html)

operator/deploy/chart/templates/crd/fs.functionstream.github.io_functions.yaml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,18 @@ spec:
5959
module:
6060
description: Module name
6161
type: string
62-
package:
63-
description: Package name
64-
type: string
62+
packageRef:
63+
description: Package reference
64+
properties:
65+
name:
66+
description: Name of the Package resource
67+
type: string
68+
namespace:
69+
description: Namespace of the Package resource
70+
type: string
71+
required:
72+
- name
73+
type: object
6574
replicas:
6675
default: 1
6776
description: Number of replicas for the function deployment
@@ -113,7 +122,7 @@ spec:
113122
type: string
114123
required:
115124
- module
116-
- package
125+
- packageRef
117126
type: object
118127
status:
119128
description: FunctionStatus defines the observed state of Function

0 commit comments

Comments
 (0)