You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/en/docs/2_concepts/functions.md
+8-6Lines changed: 8 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,9 +22,10 @@ For details on how to declare and configure functions in the Kptfile pipeline, s
22
22
23
23
## Function Configuration
24
24
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.
26
27
27
-
Each FunctionConfig specifies:
28
+
Each FunctionConfig defines:
28
29
-**Image and prefixes**: The function image name and optional registry prefixes
29
30
-**Executor configurations**: One or more executor types (pod, binary, or go) with associated settings
30
31
-**Version-specific settings**: Different executors and configurations for different image tags
@@ -57,7 +58,8 @@ spec:
57
58
- v0.4.5
58
59
```
59
60
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.
61
63
62
64
## Function Execution in Porch
63
65
@@ -78,9 +80,9 @@ Porch executes functions using multiple executor types, determined by FunctionCo
78
80
- Only available for functions integrated as Go libraries
79
81
- No container or process overhead
80
82
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.
82
84
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.
84
86
kpt passes the function results back to Porch and Porch stores them in the PackageRevisionResources's `status.renderStatus` field.
85
87
86
88
## When Functions Execute
@@ -137,7 +139,7 @@ enabling iterative development on incomplete packages.
137
139
138
140
- Functions are standard KRM functions declared in the Kptfile pipeline (see [kpt functions docs](https://kpt.dev/book/04-using-functions/))
139
141
- 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
141
143
- Functions can execute via pod containers, local binaries, or in-process Go calls depending on configuration
142
144
- Functions automatically execute during package rendering on Draft package revisions
143
145
- Function results are stored in `status.renderStatus` of the PackageRevisionResources view of a package revision
Copy file name to clipboardExpand all lines: docs/content/en/docs/5_architecture_and_components/function-runner/functionality/pod-lifecycle-management.md
+2-6Lines changed: 2 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -128,13 +128,13 @@ The Pod Manager handles low-level Kubernetes operations for function pods and th
128
128
129
129
**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.
130
130
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.
132
132
133
133
### Pod Template System
134
134
135
135
The pod manager supports two template sources: ConfigMap-based templates for customization and inline templates as fallback defaults.
136
136
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.
138
138
If these resources are not found, the pod manager creates them from embedded inline defaults.
139
139
140
140
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
154
154
155
155
These overrides are merged with the base template during pod creation, allowing function-specific customization without requiring separate templates for each function.
156
156
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
-
161
157
### Container Configuration
162
158
163
159
The pod manager patches the function container in the template with function-specific configuration before creating the pod:
Copy file name to clipboardExpand all lines: docs/content/en/docs/6_configuration_and_deployments/configurations/components/function-runner-config/_index.md
+1-232Lines changed: 1 addition & 232 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,238 +11,6 @@ KPT functions and KRM functions are synonymous terms referring to the same conta
11
11
12
12
The Function Runner executes KRM functions in a secure, isolated environment.
13
13
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
-
246
14
## Configuration Options
247
15
248
16
### Command Line Arguments
@@ -437,5 +205,6 @@ spec:
437
205
{{% alert title="Note" color="primary" %}}
438
206
For advanced configuration options:
439
207
- [Pod Templates]({{% relref "pod-templates" %}}) - Customize function pod specifications
0 commit comments