1
1
# Running Configuration Functions using kustomize CLI
2
2
3
- Configuration functions can be implemented using any toolchain and invoked using any
4
- container workflow orchestrator including Tekton, Cloud Build, or run directly using ` docker run ` .
3
+ Configuration functions can be implemented using any toolchain and invoked using
4
+ any container workflow orchestrator including Tekton, Cloud Build, or run
5
+ directly using ` docker run ` .
5
6
6
7
Run ` config help docs-fn-spec ` to see the Configuration Functions Specification.
7
8
8
- ` kustomize fn run ` is an example orchestrator for invoking Configuration Functions. This
9
- document describes how to implement and invoke an example function.
9
+ ` kustomize fn run ` is an example orchestrator for invoking Configuration
10
+ Functions. This document describes how to implement and invoke an example
11
+ function.
10
12
11
13
## Example Function Implementation
12
14
13
- Following is an example for implementing an nginx abstraction using a configuration
14
- function.
15
+ Following is an example for implementing an nginx abstraction using a
16
+ configuration function.
15
17
16
18
### ` nginx-template.sh `
17
19
18
- ` nginx-template.sh ` is a simple bash script which uses a _ heredoc_ as a templating solution
19
- for generating Resources from the functionConfig input fields.
20
+ ` nginx-template.sh ` is a simple bash script which uses a _ heredoc_ as a
21
+ templating solution for generating Resources from the functionConfig input
22
+ fields.
20
23
21
24
The script wraps itself using ` config run wrap -- $0 ` which will:
22
25
23
- 1 . Parse the ` ResourceList.functionConfig ` (provided to the container stdin) into env vars
26
+ 1 . Parse the ` ResourceList.functionConfig ` (provided to the container stdin)
27
+ into env vars
24
28
2 . Merge the stdout into the original list of Resources
25
- 3 . Defaults filenames for newly generated Resources (if they are not set as annotations)
26
- to ` config/NAME_KIND.yaml `
29
+ 3 . Defaults filenames for newly generated Resources (if they are not set as
30
+ annotations) to ` config/NAME_KIND.yaml `
27
31
4 . Format the output
28
32
29
33
``` bash
@@ -82,10 +86,11 @@ End-of-message
82
86
83
87
### Dockerfile
84
88
85
- ` Dockerfile ` installs ` kustomize fn ` and copies the script into the container image.
89
+ ` Dockerfile ` installs ` kustomize fn ` and copies the script into the container
90
+ image.
86
91
87
92
```
88
- FROM golang:1.21 -bullseye
93
+ FROM public.ecr.aws/docker/library/ golang:1.22.7 -bullseye
89
94
RUN go get sigs.k8s.io/kustomize/cmd/config
90
95
RUN mv /go/bin/config /usr/bin/config
91
96
COPY nginx-template.sh /usr/bin/nginx-template.sh
@@ -94,20 +99,23 @@ CMD ["nginx-template.sh]
94
99
95
100
## Example Function Usage
96
101
97
- Following is an example of running the ` kustomize fn run ` using the preceding API.
102
+ Following is an example of running the ` kustomize fn run ` using the preceding
103
+ API.
98
104
99
105
When run by ` kustomize fn run ` , functions are run in containers with the
100
106
following environment:
101
107
102
108
- Network: ` none `
103
109
- User: ` nobody `
104
110
- Security Options: ` no-new-privileges `
105
- - Volumes: the volume containing the ` functionConfig ` yaml is mounted under ` /local ` as ` ro `
111
+ - Volumes: the volume containing the ` functionConfig ` yaml is mounted under
112
+ ` /local ` as ` ro `
106
113
107
114
### Input
108
115
109
- ` dir/nginx.yaml ` contains a reference to the Function. The contents of ` nginx.yaml `
110
- are passed to the Function through the ` ResourceList.functionConfig ` field.
116
+ ` dir/nginx.yaml ` contains a reference to the Function. The contents of
117
+ ` nginx.yaml ` are passed to the Function through the
118
+ ` ResourceList.functionConfig ` field.
111
119
112
120
``` yaml
113
121
apiVersion : example.com/v1beta1
@@ -123,9 +131,10 @@ spec:
123
131
replicas : 5
124
132
` ` `
125
133
126
- - ` annotations[config.kubernetes.io/function].container.image`: the image to use for this API
127
- - `annotations[config.kubernetes.io/local-config]` : mark this as not a Resource that should
128
- be applied
134
+ - ` annotations[config.kubernetes.io/function].container.image`: the image to use
135
+ for this API
136
+ - `annotations[config.kubernetes.io/local-config]` : mark this as not a Resource
137
+ that should be applied
129
138
130
139
# ## Output
131
140
0 commit comments