Skip to content

Commit 4bfa86c

Browse files
committed
update docs
1 parent 1820768 commit 4bfa86c

File tree

1 file changed

+54
-6
lines changed

1 file changed

+54
-6
lines changed

website/content/en/docs/generators/kustomize.md

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,54 @@ This generator allows to generate the manifests of the component's resources fro
1111
As a special case, one or more simple Kubernetes manifests (without a `kustomization.yaml`) are supported as well.
1212
In addition, all (or selected; see below) files in the kustomization directory can be templatized in a helm'ish way.
1313
That means, they will be considered as a common template group (where all templates are associated with each other),
14-
and the same template function set that is available on Helm can be used; so, all the [sprig](http://masterminds.github.io/sprig) functions, and custom functions such as `include`, `tpl`, `lookup` can be used. In addition:
15-
- parameterless functions `namespace` and `name` are defined, which return the corresponding arguments passed to `Generate()`
16-
- a function `kubernetesVersion` is available, which returns the version information of the target cluster, as a [version.Info](https://pkg.go.dev/k8s.io/apimachinery/pkg/version#Info) structure
17-
- files from the kustomization path can be retrieved using the template function `readFile`; there are auxiliary functions `existsFile` and `listFiles`,
18-
the latter one expecting a pattern as supported by the [gobwas/glob](https://pkg.go.dev/github.com/gobwas/glob) library.
14+
and the well-known template function set that is available in Helm can be used; that is, all the [sprig](http://masterminds.github.io/sprig) functions, plus functions like `include`, `tpl`, `lookup`, plus further functions are supported:
15+
16+
| Function name | Description |
17+
|-----------------------------------------|------------ |
18+
| `toYaml <input any>` | Encode input to YAML string. |
19+
| `mustToYaml <input any>` | Same as `toYaml`. |
20+
| `fromYaml <input string>` | Parse YAML string to object. |
21+
| `mustFromYaml <input string>` | Same as `fromYaml`. |
22+
| `fromYamlArray <input string>` | Parse YAML string to array. |
23+
| `mustFromYamlArray <input string>` | Same as `fromYamlArray`. |
24+
| `toJson <input any>` | Encode input to JSON string. |
25+
| `mustToJson <input any>` | Same as `toJson`. |
26+
| `toPrettyJson <input any>` | Encode object to pretty JSON string. |
27+
| `mustToPrettyJson <input any>` | Same as `toPrettyJson`. |
28+
| `toRawJson <input any> ` | Encode input to JSON string with no escaping of HTML characters. |
29+
| `mustToRawJson <input any> ` | Same as `toRawJson`. |
30+
| `fromJson <input string>` | Parse JSON string to object. |
31+
| `mustFromJson <input string>` | Same as `fromJson`. |
32+
| `fromJsonArray <input string>` | Parse JSON string to array. |
33+
| `mustFromJsonArray <input string>` | Same as `fromJsonArray`|
34+
| `required <warn string, input any>` | Fail with the given error message if the input is `nil` or can be converted to an empty string. |
35+
| `bitwiseShiftLeft <by any, input any>` | Perform a bitwise left shift on the input by the given number of places. |
36+
| `bitwiseShiftRight <by any, input any>` | Perform a bitwise right shift on the input by the given number of places. |
37+
| `bitwiseAnd <input ...any>` | Perform a bitwise logical 'and' on the inputs. |
38+
| `bitwiseOr <input ...any>` | Perform a bitwise logical 'or' on the inputs. |
39+
| `bitwiseXor <input ...any>` | Perform a bitwise logical 'xor' on the inputs. |
40+
| `parseIPv4Address <input any>` | Convert a string representation of an IPv4 address into a 32 bit integer. |
41+
| `formatIPv4Address <input any>` | Convert a 32 bit integer representation of an IPv4 address into a string. |
42+
| `include <name string, input any>` | Render the given named template with the input as data values. |
43+
| `tpl <template string, input any>` | Render the given template string with the input as data values. |
44+
| `lookup <apiVersion string, kind string, namespace string, name string>` | Lookup a Kubernetes resource with the target client; return nil in case of 404 (not found) errors. |
45+
| `mustLookup <apiVersion string, kind string, namespace string, name string>` | Lookup a Kubernetes resource with the target client; fail in case of 404 (not found) errors. |
46+
| `localLookup <apiVersion string, kind string, namespace string, name string>` | Lookup a Kubernetes resource with the local client; return nil in case of 404 (not found) errors. |
47+
| `mustLocalLookup <apiVersion string, kind string, namespace string, name string>` | Lookup a Kubernetes resource with the local client; fail in case of 404 (not found) errors. |
48+
| `lookupWithKubeConfig <apiVersion string, kind string, namespace string, name string kubeConfig string> ` | Lookup a Kubernetes resource with the given kubeconfig; return nil in case of 404 (not found) errors. |
49+
| `mustLookupWithKubeConfig <apiVersion string, kind string, namespace string, name string, kubeConfig string>` | Lookup a Kubernetes resource with the given kubeconfig; fail in case of 404 (not found) errors. |
50+
| `listFiles <pattern string>` | List files relative to the provided kustomization directory, matching the given [pattern](https://pkg.go.dev/github.com/gobwas/glob). |
51+
| `existsFile <path string>` | Check if the given file path exists, relative to the provided kustomization directory. |
52+
| `readFile <path string>` | Read the given file, relative to the provided kustomization directory. |
53+
| `namespace` | Return the deployment namespace as passed to the generator. |
54+
| `name` | Return the deployment name as passed to the generator. |
55+
| `kubernetesVersion` | Return a `*version.Info` [struct](https://pkg.go.dev/k8s.io/apimachinery/pkg/version#Info) containing Kubernetes version details about the deployment target. |
56+
| `apiResources` | Return a slice of `[]*metav1.APIResourceList` [structs](https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1#APIResourceList) containing Kubernetes API discovery details about the deployment target. |
57+
58+
Notes:
59+
- in case a function is provided by sprig and by us, our implementation is used
60+
- all functions (unless otherwise stated) make the using template fail in case of errors
61+
- as for the lookup functions, the target client points to the deployment target, the local client points to the cluster where the executing controller is running.
1962

2063
In the generation step, first, all the go templates will be rendered, and the result of this pre-step will be passed to kustomize.
2164

@@ -52,4 +95,9 @@ Here:
5295
}
5396
```
5497
55-
As of now, the specified kustomization must not reference files or paths outside `kustomizationPath`. Remote references are generally not supported.
98+
The generator options can be overridden on source level by creating a file `.component-config.yaml` in the specified `kustomizationPath`; the file can contain JSON or YAML, compatible with the `KustomizeGeneratorOptions` struct.
99+
100+
As of now, the specified kustomization must not reference files or paths outside `kustomizationPath`. Remote references are generally not supported.
101+
By default, all `.yaml` or `.yml` files in `kustomizationPath`, and its subdirectories, are subject to templating, and are considered if a `kustomization.yaml`
102+
is auto-generated. It is possible to exclude certain files by creating a file `.component-ignore` in `kustomizationPath`; this `.component-ignore` file uses
103+
the common `.gitignore syntax`.

0 commit comments

Comments
 (0)