Skip to content

Commit e0cfc0d

Browse files
committed
address some review comments
1 parent b91a94c commit e0cfc0d

7 files changed

Lines changed: 268 additions & 293 deletions

File tree

docs/content/en/docs/2_concepts/functions.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ For details on how to declare and configure functions in the Kptfile pipeline, s
2222

2323
## Function Configuration
2424

25-
Porch uses **FunctionConfig** custom resources to configure how functions execute. These configurations specify which executor type should handle specific function images and provide executor-specific settings.
25+
Porch uses **FunctionConfig** custom resources to configure how functions execute.
26+
These configurations determine which executor type should handle the given function images and provide executor-specific settings.
2627

27-
Each FunctionConfig specifies:
28+
Each FunctionConfig defines:
2829
- **Image and prefixes**: The function image name and optional registry prefixes
2930
- **Executor configurations**: One or more executor types (pod, binary, or go) with associated settings
3031
- **Version-specific settings**: Different executors and configurations for different image tags
@@ -57,7 +58,8 @@ spec:
5758
- v0.4.5
5859
```
5960
60-
Both the function-runner and porch-server components include an embedded FunctionConfig reconciler that watches FunctionConfig resources and populates an internal cache. This cache determines which executor to use for each function invocation.
61+
Most Porch components include an embedded reconciler that watches FunctionConfig resources and populates the component's own internal cache.
62+
This cache determines which executor to use for each function invocation.
6163
6264
## Function Execution in Porch
6365
@@ -78,9 +80,9 @@ Porch executes functions using multiple executor types, determined by FunctionCo
7880
- Only available for functions integrated as Go libraries
7981
- No container or process overhead
8082

81-
Regardless of executor type, Porch passes the package's resources to kpt, which passes the resources on as a [ResourceList](https://github.com/kubernetes-sigs/kustomize/blob/master/cmd/config/docs/api-conventions/functions-spec.md#resourcelist) to each function in the pipeline in turn.
83+
Regardless of executor type, Porch passes the package's resources to [kpt](https://kpt.dev), which passes the resources on as a [ResourceList](https://github.com/kubernetes-sigs/kustomize/blob/master/cmd/config/docs/api-conventions/functions-spec.md#resourcelist) to each function in the pipeline in turn.
8284
kpt executes the functions sequentially in the order declared in the Kptfile pipeline and passes the function results back to Porch, which stores them in the PackageRevisionResources's `status.renderStatus` field.
83-
Execution is triggered automatically following creation or clone of a package revision, update of a package revision, and when a package revision is proposed.
85+
Pipeline execution is triggered automatically following creation or clone of a package revision, update of a package revision, and when a package revision is proposed.
8486
kpt passes the function results back to Porch and Porch stores them in the PackageRevisionResources's `status.renderStatus` field.
8587

8688
## When Functions Execute
@@ -137,7 +139,7 @@ enabling iterative development on incomplete packages.
137139
138140
- Functions are standard KRM functions declared in the Kptfile pipeline (see [kpt functions docs](https://kpt.dev/book/04-using-functions/))
139141
- Function execution behavior is configured using FunctionConfig custom resources that specify executor types (pod, binary, or go)
140-
- Both function-runner and porch-server include FunctionConfig reconcilers that populate internal caches to determine which executor handles each function
142+
- Most Porch components include an embedded FunctionConfig reconciler that populates internal caches to determine which executor handles each function
141143
- Functions can execute via pod containers, local binaries, or in-process Go calls depending on configuration
142144
- Functions automatically execute during package rendering on Draft package revisions
143145
- Function results are stored in `status.renderStatus` of the PackageRevisionResources view of a package revision

docs/content/en/docs/5_architecture_and_components/function-runner/functionality/function-evaluation.md

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -589,43 +589,7 @@ The evaluation system employs several performance strategies.
589589
- Use executable evaluator for critical path
590590
- Monitor pod resource usage
591591
592-
## FunctionConfig CRD
593-
594-
The FunctionConfig CRD is the central configuration mechanism for function evaluation in both function-runner and porch-server.
595-
596-
### CRD Structure
597-
598-
**Core fields:**
599-
- **image**: Base image name (without prefix or tag)
600-
- **prefixes**: List of registry prefixes to match
601-
- **binaryExecutor**: Configuration for binary execution
602-
- **podExecutor**: Configuration for pod execution
603-
- **goExecutor**: Configuration for native Go execution (porch-server only)
604-
605-
### Executor Types
606-
607-
**Binary Executor:**
608-
- Maps specific image tags to local binary executables
609-
- **tags**: List of image tags to handle
610-
- **path**: Absolute or relative path to binary
611-
- Used by function-runner for fast local execution
612-
613-
**Pod Executor:**
614-
- Runs functions in containers with configurable settings
615-
- **tags**: List of image tags to handle
616-
- **timeToLive**: Duration pods remain cached (default: 30m)
617-
- **templateOverrides**: Customize pod/container specifications
618-
- Used by function-runner for containerized execution
619-
620-
**Go Executor:**
621-
- Executes functions as native Go calls
622-
- **tags**: List of image tags to handle
623-
- **id**: Registration ID for Go function (defaults to image name)
624-
- Used by porch-server for built-in functions
625-
626-
### Configuration Reconciliation
627-
628-
Both function-runner and porch-server embed a FunctionConfig reconciler:
592+
## Configuration Reconciliation
629593
630594
**Reconciler behavior:**
631595
- Watches FunctionConfig CRDs in the function namespace
@@ -669,8 +633,8 @@ spec:
669633
- v0.4.5
670634
```
671635

672-
This configuration supports:
636+
This example configuration supports:
673637
- Binary execution for `set-namespace:v0.4.2`
674638
- Pod execution for `set-namespace:v0.4.1`
675-
- Native Go execution for `set-namespace:v0.4` and `v0.4.5` (porch-server only)
639+
- Native Go execution for `set-namespace:v0.4` and `v0.4.5`
676640
- Automatic prefix resolution for both qualified and unqualified images

docs/content/en/docs/5_architecture_and_components/function-runner/functionality/pod-lifecycle-management.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ The Pod Manager handles low-level Kubernetes operations for function pods and th
128128

129129
**Image Metadata Operations** - Cache image digests and entrypoints, inspect container images to extract configuration, handle private registry authentication and TLS configuration, manage image pull secrets for function pods.
130130

131-
**Template System** - Retrieve or create base pod and service templates from ServiceTemplate CRDs or inline defaults, track template versions to detect changes requiring pod replacement, patch templates with function-specific configuration and template overrides from FunctionConfig.
131+
**Template System** - Retrieve or create base pod and service templates from ServiceTemplate custom resources or inline defaults, track template versions to detect changes requiring pod replacement, patch templates with function-specific configuration and template overrides from FunctionConfig.
132132

133133
### Pod Template System
134134

135135
The pod manager supports two template sources: ConfigMap-based templates for customization and inline templates as fallback defaults.
136136

137-
The pod manager retrieves base pod and service templates from PodTemplate resources and ServiceTemplate CRs in the function execution namespace.
137+
The pod manager retrieves base pod and service templates from PodTemplate resources and ServiceTemplate resources in the function execution namespace.
138138
If these resources are not found, the pod manager creates them from embedded inline defaults.
139139

140140
The template's `ResourceVersion` is used as the template version for tracking changes. When a template is updated, existing pods with old template versions are replaced on next use.
@@ -154,10 +154,6 @@ FunctionConfig resources can specify template overrides that customize the base
154154

155155
These overrides are merged with the base template during pod creation, allowing function-specific customization without requiring separate templates for each function.
156156

157-
**Legacy ConfigMap Approach:**
158-
159-
Prior to the ServiceTemplate CRD implementation, pod and service templates were stored in ConfigMaps. This approach is deprecated. See [function-runner-pod-templates.md](../relevant_old_docs/function-runner-pod-templates.md) for historical reference.
160-
161157
### Container Configuration
162158

163159
The pod manager patches the function container in the template with function-specific configuration before creating the pod:

docs/content/en/docs/6_configuration_and_deployments/configurations/components/function-runner-config/_index.md

Lines changed: 1 addition & 232 deletions
Original file line numberDiff line numberDiff line change
@@ -11,238 +11,6 @@ KPT functions and KRM functions are synonymous terms referring to the same conta
1111

1212
The Function Runner executes KRM functions in a secure, isolated environment.
1313

14-
## Function Configuration via FunctionConfig CRD
15-
16-
FunctionConfig CRDs provide declarative configuration for KRM function execution. This is the primary method for configuring functions and replaces the previous ConfigMap-based approach.
17-
18-
The function-runner includes an embedded reconciler that:
19-
- Watches FunctionConfig resources in the configured namespace
20-
- Maintains an internal cache of function configurations
21-
- Uses the cached configuration to determine executor selection and execution parameters
22-
23-
### FunctionConfig Resource Structure
24-
25-
```yaml
26-
apiVersion: config.porch.kpt.dev/v1alpha1
27-
kind: FunctionConfig
28-
metadata:
29-
name: <function-name>
30-
namespace: porch-fn-system
31-
spec:
32-
# Base function image name (without registry prefix or tag)
33-
image: <image-name>
34-
35-
# Optional: List of registry prefixes that should be matched
36-
# Empty string or omitted uses the default prefix
37-
prefixes:
38-
- ""
39-
- ghcr.io/kptdev/krm-functions-catalog
40-
41-
# Optional: Configuration for pod-based execution
42-
podExecutor:
43-
tags:
44-
- v1.0.0
45-
timeToLive: 30m
46-
maxParallelExecutions: 2
47-
preferredMaxQueueLength: 1
48-
templateOverrides:
49-
serviceAccountName: custom-sa
50-
securityContext:
51-
runAsUser: 1000
52-
initContainer:
53-
resources:
54-
limits:
55-
memory: "256Mi"
56-
container:
57-
resources:
58-
limits:
59-
memory: "512Mi"
60-
61-
# Optional: Configuration for binary executable substitution
62-
binaryExecutor:
63-
tags:
64-
- v1.0.0
65-
path: /path/to/binary # Absolute or relative to functions directory
66-
67-
# Optional: Configuration for native Go execution
68-
goExecutor:
69-
tags:
70-
- v1.0
71-
id: custom-function-id # Optional: defaults to spec.image
72-
```
73-
74-
### Configuration Fields
75-
76-
#### spec.image
77-
The base function image name without registry prefix or tag. This is matched against function references to determine which configuration to apply.
78-
79-
#### spec.prefixes
80-
List of registry prefixes that should be matched for this function. An empty string matches the default registry prefix. If omitted, only exact image matches are considered.
81-
82-
#### spec.podExecutor
83-
Configuration for running functions as Kubernetes pods:
84-
- **tags**: List of image tags this configuration applies to
85-
- **timeToLive**: Duration pods live before garbage collection (default: 30m)
86-
- **maxParallelExecutions**: Maximum number of concurrent pods for this function
87-
- **preferredMaxQueueLength**: Maximum waitlist length per pod
88-
- **templateOverrides**: Customizations to apply to the pod template
89-
90-
#### spec.binaryExecutor
91-
Configuration for substituting function execution with a local binary:
92-
- **tags**: List of image tags that should use the binary
93-
- **path**: Absolute path or relative path to the functions directory
94-
95-
#### spec.goExecutor
96-
Configuration for native Go function execution within the porch-server:
97-
- **tags**: List of image tags that should use native execution
98-
- **id**: Function identifier for registration (defaults to spec.image if omitted)
99-
100-
### Template Overrides
101-
102-
The `templateOverrides` structure allows customization of pod execution:
103-
104-
```yaml
105-
templateOverrides:
106-
# Service account for the function pod
107-
serviceAccountName: function-sa
108-
109-
# Pod security context
110-
securityContext:
111-
runAsUser: 1000
112-
runAsGroup: 1000
113-
fsGroup: 1000
114-
115-
# Init container customizations
116-
initContainer:
117-
resources:
118-
limits:
119-
memory: "256Mi"
120-
cpu: "500m"
121-
requests:
122-
memory: "128Mi"
123-
cpu: "250m"
124-
env:
125-
- name: CUSTOM_VAR
126-
value: "value"
127-
envFrom:
128-
- secretRef:
129-
name: function-secret
130-
131-
# Main container customizations
132-
container:
133-
resources:
134-
limits:
135-
memory: "512Mi"
136-
cpu: "1000m"
137-
requests:
138-
memory: "256Mi"
139-
cpu: "500m"
140-
env:
141-
- name: CUSTOM_VAR
142-
value: "value"
143-
envFrom:
144-
- configMapRef:
145-
name: function-config
146-
```
147-
148-
### Example FunctionConfig Resources
149-
150-
Basic pod executor configuration:
151-
152-
```yaml
153-
apiVersion: config.porch.kpt.dev/v1alpha1
154-
kind: FunctionConfig
155-
metadata:
156-
name: set-namespace
157-
namespace: porch-fn-system
158-
spec:
159-
image: set-namespace
160-
prefixes:
161-
- ""
162-
- ghcr.io/kptdev/krm-functions-catalog
163-
podExecutor:
164-
tags:
165-
- v0.4.1
166-
timeToLive: 30m
167-
```
168-
169-
Multi-executor configuration:
170-
171-
```yaml
172-
apiVersion: config.porch.kpt.dev/v1alpha1
173-
kind: FunctionConfig
174-
metadata:
175-
name: starlark
176-
namespace: porch-fn-system
177-
spec:
178-
image: starlark
179-
prefixes:
180-
- ""
181-
- ghcr.io/kptdev/krm-functions-catalog
182-
podExecutor:
183-
tags:
184-
- v0.4.3
185-
timeToLive: 30m
186-
binaryExecutor:
187-
tags:
188-
- v0.5.2
189-
path: starlark
190-
goExecutor:
191-
id: starlark
192-
tags:
193-
- v0.5
194-
- v0.5.5
195-
```
196-
197-
Configuration with resource limits:
198-
199-
```yaml
200-
apiVersion: config.porch.kpt.dev/v1alpha1
201-
kind: FunctionConfig
202-
metadata:
203-
name: gatekeeper
204-
namespace: porch-fn-system
205-
spec:
206-
image: gatekeeper
207-
prefixes:
208-
- ""
209-
- ghcr.io/kptdev/krm-functions-catalog
210-
podExecutor:
211-
tags:
212-
- v0.2.1
213-
timeToLive: 30m
214-
maxParallelExecutions: 3
215-
preferredMaxQueueLength: 2
216-
templateOverrides:
217-
container:
218-
resources:
219-
limits:
220-
memory: "1Gi"
221-
cpu: "1000m"
222-
requests:
223-
memory: "512Mi"
224-
cpu: "500m"
225-
```
226-
227-
### RBAC Requirements
228-
229-
The function-runner requires permissions to watch FunctionConfig resources:
230-
231-
```yaml
232-
apiVersion: rbac.authorization.k8s.io/v1
233-
kind: Role
234-
metadata:
235-
name: function-runner
236-
namespace: porch-fn-system
237-
rules:
238-
- apiGroups: ["config.porch.kpt.dev"]
239-
resources: ["functionconfigs"]
240-
verbs: ["get", "list", "watch"]
241-
- apiGroups: ["config.porch.kpt.dev"]
242-
resources: ["functionconfigs/status"]
243-
verbs: ["get", "update", "patch"]
244-
```
245-
24614
## Configuration Options
24715

24816
### Command Line Arguments
@@ -437,5 +205,6 @@ spec:
437205
{{% alert title="Note" color="primary" %}}
438206
For advanced configuration options:
439207
- [Pod Templates]({{% relref "pod-templates" %}}) - Customize function pod specifications
208+
- [Function Configuration]({{% relref "function-configuration" %}}) - Customize function evaluation settings
440209
- [Private Registries]({{% relref "private-registries-config" %}}) - Configure private registry access
441210
{{% /alert %}}

0 commit comments

Comments
 (0)