-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the variable documentation (#266)
Co-authored-by: Salomon Popp <[email protected]>
- Loading branch information
Showing
18 changed files
with
864 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# CLI Environment variables | ||
# | ||
# The default setup is shown. These variables are a lower priority | ||
# alternative to the commands' flags. If a variable is set, the | ||
# corresponding flag does not have to be specified in commands. | ||
# Variables marked as required can instead be set as flags. | ||
# | ||
# Base directory to the pipelines (default is current working | ||
# directory) | ||
KPOPS_PIPELINE_BASE_DIR=. | ||
# Path to the config.yaml file | ||
KPOPS_CONFIG_PATH=config.yaml | ||
# Path to defaults folder | ||
KPOPS_DEFAULT_PATH # No default value, not required | ||
# Path to YAML with pipeline definition | ||
KPOPS_PIPELINE_PATH # No default value, required | ||
# Comma separated list of steps to apply the command on | ||
KPOPS_PIPELINE_STEPS # No default value, not required |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
These variables are a lower priority alternative to the commands' flags. If a variable is set, the corresponding flag does not have to be specified in commands. Variables marked as required can instead be set as flags. | ||
|
||
| Name |Default Value|Required| Description | | ||
|-----------------------|-------------|--------|----------------------------------------------------------------------| | ||
|KPOPS_PIPELINE_BASE_DIR|. |False |Base directory to the pipelines (default is current working directory)| | ||
|KPOPS_CONFIG_PATH |config.yaml |False |Path to the config.yaml file | | ||
|KPOPS_DEFAULT_PATH | |False |Path to defaults folder | | ||
|KPOPS_PIPELINE_PATH | |True |Path to YAML with pipeline definition | | ||
|KPOPS_PIPELINE_STEPS | |False |Comma separated list of steps to apply the command on | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Pipeline config environment variables | ||
# | ||
# The default setup is shown. These variables are a lower priority | ||
# alternative to the settings in `config.yaml`. Variables marked as | ||
# required can instead be set in the pipeline config. | ||
# | ||
# environment | ||
# The environment you want to generate and deploy the pipeline to. | ||
# Suffix your environment files with this value (e.g. | ||
# defaults_development.yaml for environment=development). | ||
KPOPS_ENVIRONMENT # No default value, required | ||
# brokers | ||
# The comma separated Kafka brokers address. | ||
KPOPS_KAFKA_BROKERS # No default value, required | ||
# schema_registry_url | ||
# Address of the Schema Registry. | ||
KPOPS_SCHEMA_REGISTRY_URL # No default value, not required | ||
# kafka_rest_host | ||
# Address of the Kafka REST Proxy. | ||
KPOPS_REST_PROXY_HOST # No default value, not required | ||
# kafka_connect_host | ||
# Address of Kafka Connect. | ||
KPOPS_CONNECT_HOST # No default value, not required | ||
# timeout | ||
# The timeout in seconds that specifies when actions like deletion or | ||
# deploy timeout. | ||
KPOPS_TIMEOUT=300 | ||
# retain_clean_jobs | ||
# Whether to retain clean up jobs in the cluster or uninstall the, | ||
# after completion. | ||
KPOPS_RETAIN_CLEAN_JOBS=False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
These variables are a lower priority alternative to the settings in `config.yaml`. Variables marked as required can instead be set in the pipeline config. | ||
|
||
| Name |Default Value|Required| Description | Setting name | | ||
|-------------------------|-------------|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------| | ||
|KPOPS_ENVIRONMENT | |True |The environment you want to generate and deploy the pipeline to. Suffix your environment files with this value (e.g. defaults_development.yaml for environment=development).|environment | | ||
|KPOPS_KAFKA_BROKERS | |True |The comma separated Kafka brokers address. |brokers | | ||
|KPOPS_SCHEMA_REGISTRY_URL| |False |Address of the Schema Registry. |schema_registry_url| | ||
|KPOPS_REST_PROXY_HOST | |False |Address of the Kafka REST Proxy. |kafka_rest_host | | ||
|KPOPS_CONNECT_HOST | |False |Address of Kafka Connect. |kafka_connect_host | | ||
|KPOPS_TIMEOUT | 300|False |The timeout in seconds that specifies when actions like deletion or deploy timeout. |timeout | | ||
|KPOPS_RETAIN_CLEAN_JOBS |False |False |Whether to retain clean up jobs in the cluster or uninstall the, after completion. |retain_clean_jobs | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
- type: scheduled-producer | ||
app: | ||
labels: | ||
app_type: "${component_type}" | ||
app_name: "${component_name}" | ||
app_schedule: "${component_app_schedule}" | ||
commandLine: | ||
FAKE_ARG: "fake-arg-value" | ||
schedule: "30 3/8 * * *" | ||
- type: converter | ||
app: | ||
commandLine: | ||
CONVERT_XML: true | ||
resources: | ||
limits: | ||
memory: 2G | ||
requests: | ||
memory: 2G | ||
- type: filter | ||
name: "filter-app" | ||
app: | ||
labels: | ||
app_type: "${component_type}" | ||
app_name: "${component_name}" | ||
app_resources_requests_memory: "${component_app_resources_requests_memory}" | ||
${component_type}: "${component_app_labels_app_name}-${component_app_labels_app_type}" | ||
test_placeholder_in_placeholder: "${component_app_labels_${component_type}}" | ||
commandLine: | ||
TYPE: "nothing" | ||
resources: | ||
requests: | ||
memory: 3G | ||
replicaCount: 4 | ||
autoscaling: | ||
minReplicas: 4 | ||
maxReplicas: 4 |
This file was deleted.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
docs/docs/user/references/variables/environment_variables.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Environment variables | ||
|
||
Environment variables can be set by using the [export](https://www.unix.com/man-page/linux/1/export/){target=_blank} command in Linux or the [set](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/set_1){target=_blank} command in Windows. | ||
|
||
!!! tip "dotenv files" | ||
|
||
Support for `.env` files is on the roadmap, but not implemented in KPOps yet. One of the possible ways to still use one and export the contents manually is with the following command: `#!sh export $(xargs < .env)`. This would work in `bash` suppose there are no spaces inside the values. | ||
|
||
## Config | ||
|
||
--8<-- | ||
./docs/resources/variables/config_env_vars.md | ||
--8<-- | ||
|
||
??? example "config_env_vars.env" | ||
|
||
```py title="Exhaustive list of all config-related environment variables" | ||
--8<-- | ||
./docs/resources/variables/config_env_vars.env | ||
--8<-- | ||
``` | ||
|
||
## CLI | ||
|
||
--8<-- | ||
./docs/resources/variables/cli_env_vars.md | ||
--8<-- | ||
|
||
??? example "cli_env_vars.env" | ||
|
||
```py title="Exhaustive list of all cli-related environment variables" | ||
--8<-- | ||
./docs/resources/variables/cli_env_vars.env | ||
--8<-- | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Substitution | ||
|
||
KPOps supports the usage of placeholders and environment variables in [pipeline definition](../components.md) and [defaults](../defaults.md). | ||
|
||
## Component-specific variables | ||
|
||
These variables can be used in a component's definition to refer to any of its attributes, including ones that the user has defined in the defaults. | ||
|
||
All of them are prefixed with `component_` and follow the following form: `component_{attribute_name}`. If the attribute itself contains attributes, they can be referred to like this: `component_{attribute_name}_{subattribute_name}`. | ||
|
||
??? Example | ||
```yaml | ||
--8<-- | ||
./docs/resources/variables/variable_substitution.yaml | ||
--8<-- | ||
``` | ||
|
||
## Pipeline-config-specific variables | ||
|
||
These variables include all fields in the [config](../config.md) and refer to the pipeline configuration that is independent of the components. | ||
|
||
!!! info Aliases | ||
`error_topic_name` is an alias for `topic_name_config_default_error_topic_name` | ||
`output_topic_name` is an alias for `topic_name_config_default_output_topic_name` | ||
|
||
## Environment variables | ||
|
||
Environment variables such as `$PATH` can be used in the pipeline definition and defaults without any transformation following the form `${ENV_VAR_NAME}`. This, of course, includes variables like the ones relevant to the [KPOps cli](../cli-commands.md) that are exported by the user. | ||
|
||
[See all KPOps environment variables](environment_variables.md) | ||
|
||
## Pipeline name variables | ||
|
||
These are special variables that refer to the name and path of a pipeline. | ||
|
||
- `${pipeline_name}` | ||
Concatenated path of the parent directory where pipeline.yaml is defined in. | ||
For instance, `./data/pipelines/v1/pipeline.yaml`, here the value for the variable would be `data-pipelines-v1`. | ||
|
||
- `${pipeline_name_<level>}` | ||
Similar to the previous variable, each `<level>` contains a part of the path to the `pipeline.yaml` file. | ||
Consider the previous example, `${pipeline_name_0}` would be `data`, `${pipeline_name_1}` would be `pipelines`, and `${pipeline_name_2}` equals to `v1`. | ||
|
||
## Advanced use cases | ||
|
||
1. **Refer to default component field values** | ||
As long as a value is assigned to a component attribute, it is possible to refer to it with a placeholder. To see all component fields, take a look at the [pipeline schema](../../../schema/pipeline.json). | ||
2. **Chaining variables** | ||
It is possible to chain any number of variables, see the [example](#component-specific-variables) above. | ||
3. **Cross-component substitution** | ||
[YAML](https://yaml.org/){target=_blank} is quite an intricate language and with some of its [magic](https://yaml.org/spec/1.2.2/#692-node-anchors){target=_blank} one could write cross-component references. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,30 @@ | ||
"""Documentation generation.""" | ||
|
||
from collections.abc import Generator | ||
from enum import Enum | ||
from typing import Any, Generic, TypeVar | ||
|
||
_T = TypeVar("_T") | ||
|
||
|
||
class SuperEnum(Generic[_T], Enum): | ||
"""Adds constructors that return all items in a ``Generator``. | ||
Introduces constructors that return a ``Generator`` object | ||
either containing all items, only their names or their values. | ||
""" | ||
|
||
@classmethod | ||
def items(cls) -> Generator[tuple[_T, Any], None, None]: | ||
"""Return all item names and values in tuples.""" | ||
return ((e.name, e.value) for e in cls) | ||
|
||
@classmethod | ||
def keys(cls) -> Generator[_T, None, None]: | ||
"""Return all item names.""" | ||
return (e.name for e in cls) | ||
|
||
@classmethod | ||
def values(cls) -> Generator[Any, None, None]: | ||
"""Return all item values.""" | ||
return (e.value for e in cls) |
Oops, something went wrong.