Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
raminqaf committed Dec 10, 2024
2 parents 08b5ced + 1da0bef commit 884565e
Show file tree
Hide file tree
Showing 16 changed files with 2,129 additions and 1,052 deletions.
1,464 changes: 1,038 additions & 426 deletions docs/docs/schema/defaults.json

Large diffs are not rendered by default.

1,153 changes: 817 additions & 336 deletions docs/docs/schema/pipeline.json

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions docs/docs/user/changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
# Changelog
## [8.1.4](https://github.com/bakdata/kpops/releases/tag/8.1.4) - Release Date: [2024-12-09]

### 🐛 Fixes

- Fix `kpops --version` - [#551](https://github.com/bakdata/kpops/pull/551)


### 🌀 Miscellaneous

- Trim Helm name override for Producer CronJob to 52 characters - [#550](https://github.com/bakdata/kpops/pull/550)






## [8.1.3](https://github.com/bakdata/kpops/releases/tag/8.1.3) - Release Date: [2024-12-05]

### 🌀 Miscellaneous

- Remove repeated defaults from streams-bootstrap values - [#547](https://github.com/bakdata/kpops/pull/547)






## [8.1.2](https://github.com/bakdata/kpops/releases/tag/8.1.2) - Release Date: [2024-12-04]

### 🌀 Miscellaneous
Expand Down
34 changes: 21 additions & 13 deletions kpops/components/common/kubernetes_model.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import enum
from typing import Annotated

import pydantic
from pydantic import Field

from kpops.utils.docstring import describe_attr
from kpops.utils.pydantic import DescConfigModel

# Matches plain integer or numbers with valid suffixes: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-memory
MEMORY_PATTERN = r"^\d+([EPTGMk]|Ei|Pi|Ti|Gi|Mi|Ki)?$"


class ServiceType(str, enum.Enum):
"""Represents the different Kubernetes service types.
Expand Down Expand Up @@ -72,13 +71,11 @@ class Toleration(DescConfigModel):
:param toleration_seconds: The duration for which the toleration is valid.
"""

key: str = Field(default=..., description=describe_attr("key", __doc__))
key: str = Field(description=describe_attr("key", __doc__))

operator: Operation = Field(
default=Operation.EQUAL, description=describe_attr("operator", __doc__)
)
operator: Operation = Field(description=describe_attr("operator", __doc__))

effect: Effects = Field(default=..., description=describe_attr("effect", __doc__))
effect: Effects = Field(description=describe_attr("effect", __doc__))

value: str | None = Field(default=None, description=describe_attr("value", __doc__))

Expand All @@ -87,16 +84,27 @@ class Toleration(DescConfigModel):
)


CPUStr = Annotated[str, pydantic.StringConstraints(pattern=r"^\d+m$")]
MemoryStr = Annotated[
# Matches plain number string or number with valid suffixes: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-memory
str, pydantic.StringConstraints(pattern=r"^\d+([EPTGMk]|Ei|Pi|Ti|Gi|Mi|Ki)?$")
]


class ResourceDefinition(DescConfigModel):
"""Model representing the 'limits' or `request` section of Kubernetes resource specifications.
"""Model representing the `limits` or `requests` section of Kubernetes resource specifications.
:param cpu: The maximum amount of CPU a container can use, expressed in milli CPUs (e.g., '300m').
:param memory: The maximum amount of memory a container can use, with valid units such as 'Mi' or 'Gi' (e.g., '2G').
:param memory: The maximum amount of memory a container can use, as integer or string with valid units such as 'Mi' or 'Gi' (e.g., '2G').
"""

cpu: str | int = Field(pattern=r"^\d+m$", description=describe_attr("cpu", __doc__))
memory: str = Field(
pattern=MEMORY_PATTERN, description=describe_attr("memory", __doc__)
cpu: CPUStr | pydantic.PositiveInt | None = Field(
default=None,
description=describe_attr("cpu", __doc__),
)
memory: MemoryStr | pydantic.PositiveInt | None = Field(
default=None,
description=describe_attr("memory", __doc__),
)


Expand Down
4 changes: 3 additions & 1 deletion kpops/components/streams_bootstrap/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ def version_validator(cls, version: str) -> str:

@pydantic.model_validator(mode="after")
def warning_for_latest_image_tag(self) -> Self:
if self.validate_ and self.values.image_tag == "latest":
if self.validate_ and (
not self.values.image_tag or self.values.image_tag == "latest"
):
log.warning(
f"The image tag for component '{self.name}' is set or defaulted to 'latest'. Please, consider providing a stable image tag."
)
Expand Down
95 changes: 46 additions & 49 deletions kpops/components/streams_bootstrap/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from kpops.components.common.kubernetes_model import (
ImagePullPolicy,
ProtocolSchema,
ResourceDefinition,
Resources,
ServiceType,
Toleration,
Expand Down Expand Up @@ -43,8 +42,9 @@ class PortConfig(CamelCaseConfigModel, DescConfigModel):
default=None,
description=describe_attr("name", __doc__),
)
schema: ProtocolSchema = Field(
schema_: ProtocolSchema = Field(
default=ProtocolSchema.TCP,
alias="schema", # because schema is already a builtin of Pydantic
description=describe_attr("schema", __doc__),
)
service_port: int | None = Field(
Expand All @@ -69,8 +69,8 @@ class ServiceConfig(CamelCaseConfigModel, DescConfigModel):
default_factory=dict,
description=describe_attr("labels", __doc__),
)
type: ServiceType = Field(
default=ServiceType.CLUSTER_IP,
type: ServiceType | None = Field(
default=None,
description=describe_attr("type", __doc__),
)

Expand All @@ -82,8 +82,8 @@ class JavaOptions(CamelCaseConfigModel, DescConfigModel):
:param others: List of Java VM options passed to the streams app.
"""

max_RAM_percentage: int = Field(
default=75,
max_RAM_percentage: int | None = Field(
default=None,
description=describe_attr("max_RAM_percentage", __doc__),
)
others: list[str] = Field(
Expand Down Expand Up @@ -120,111 +120,108 @@ class StreamsBootstrapValues(HelmAppValues):
description=describe_attr("image", __doc__),
)

image_tag: str = Field(
default="latest",
image_tag: str | None = Field(
default=None,
pattern=IMAGE_TAG_PATTERN,
description=describe_attr("image_tag", __doc__),
)

image_pull_policy: ImagePullPolicy = Field(
default=ImagePullPolicy.ALWAYS,
image_pull_policy: ImagePullPolicy | None = Field(
default=None,
description=describe_attr("image_pull_policy", __doc__),
)

image_pull_secrets: list[dict[str, str]] = Field(
default_factory=list,
image_pull_secrets: list[dict[str, str]] | None = Field(
default=None,
description=describe_attr("image_pull_secret", __doc__),
)

kafka: KafkaConfig = Field(
description=describe_attr("kafka", __doc__),
)

resources: Resources = Field(
default=Resources(
requests=ResourceDefinition(cpu="100m", memory="500Mi"),
limits=ResourceDefinition(cpu="300m", memory="2G"),
),
resources: Resources | None = Field(
default=None,
description=describe_attr("resources", __doc__),
)

ports: list[PortConfig] = Field(
default_factory=list,
ports: list[PortConfig] | None = Field(
default=None,
description=describe_attr("ports", __doc__),
)

service: ServiceConfig = Field(
default_factory=ServiceConfig,
service: ServiceConfig | None = Field(
default=None,
description=describe_attr("service", __doc__),
)

configuration_env_prefix: str = Field(
default="APP",
configuration_env_prefix: str | None = Field(
default=None,
description=describe_attr("configuration_env_prefix", __doc__),
)

command_line: dict[str, str | bool | int] = Field(
default_factory=dict,
command_line: dict[str, str | bool | int] | None = Field(
default=None,
description=describe_attr("command_line", __doc__),
)

env: dict[str, str] = Field(
default_factory=dict,
env: dict[str, str] | None = Field(
default=None,
description=describe_attr("env", __doc__),
)

secrets: dict[str, str] = Field(
default_factory=dict,
secrets: dict[str, str] | None = Field(
default=None,
description=describe_attr("secrets", __doc__),
)

secret_refs: dict[str, Any] = Field(
default_factory=dict,
secret_refs: dict[str, Any] | None = Field(
default=None,
description=describe_attr("secret_refs", __doc__),
)

secret_files_refs: list[str] = Field(
default_factory=list,
secret_files_refs: list[str] | None = Field(
default=None,
description=describe_attr("secret_files_refs", __doc__),
)

files: dict[str, Any] = Field(
default_factory=dict,
files: dict[str, Any] | None = Field(
default=None,
description=describe_attr("files", __doc__),
)

java_options: JavaOptions = Field(
default_factory=JavaOptions,
java_options: JavaOptions | None = Field(
default=None,
description=describe_attr("java_options", __doc__),
)

pod_annotations: dict[str, str] = Field(
default_factory=dict,
pod_annotations: dict[str, str] | None = Field(
default=None,
description=describe_attr("pod_annotations", __doc__),
)

pod_labels: dict[str, str] = Field(
default_factory=dict,
pod_labels: dict[str, str] | None = Field(
default=None,
description=describe_attr("pod_labels", __doc__),
)

liveness_probe: dict[str, Any] = Field(
default_factory=dict,
liveness_probe: dict[str, Any] | None = Field(
default=None,
description=describe_attr("liveness_probe", __doc__),
)

readiness_probe: dict[str, Any] = Field(
default_factory=dict,
readiness_probe: dict[str, Any] | None = Field(
default=None,
description=describe_attr("readiness_probe", __doc__),
)

affinity: dict[str, Any] = Field(
default_factory=dict,
affinity: dict[str, Any] | None = Field(
default=None,
description=describe_attr("affinity", __doc__),
)

tolerations: list[Toleration] = Field(
default_factory=list,
tolerations: list[Toleration] | None = Field(
default=None,
description=describe_attr("tolerations", __doc__),
)

Expand Down
31 changes: 17 additions & 14 deletions kpops/components/streams_bootstrap/producer/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,42 +30,45 @@ class ProducerAppValues(StreamsBootstrapValues):

kafka: ProducerConfig = Field(description=describe_attr("kafka", __doc__))

deployment: bool = Field(
default=False, description=describe_attr("deployment", __doc__)
deployment: bool | None = Field(
default=None, description=describe_attr("deployment", __doc__)
)

restart_policy: RestartPolicy = Field(
default=RestartPolicy.ON_FAILURE,
restart_policy: RestartPolicy | None = Field(
default=None,
description=describe_attr("restart_policy", __doc__),
)

schedule: str | None = Field(
default=None, description=describe_attr("schedule", __doc__)
)

suspend: bool = Field(default=False, description=describe_attr("suspend", __doc__))
suspend: bool | None = Field(
default=None, description=describe_attr("suspend", __doc__)
)

successful_jobs_history_limit: int = Field(
default=1, description=describe_attr("successful_jobs_history_limit", __doc__)
successful_jobs_history_limit: int | None = Field(
default=None,
description=describe_attr("successful_jobs_history_limit", __doc__),
)

failed_jobs_history_limit: int = Field(
default=1, description=describe_attr("failed_jobs_history_limit", __doc__)
failed_jobs_history_limit: int | None = Field(
default=None, description=describe_attr("failed_jobs_history_limit", __doc__)
)

backoff_limit: int = Field(
default=6, description=describe_attr("backoff_limit", __doc__)
backoff_limit: int | None = Field(
default=None, description=describe_attr("backoff_limit", __doc__)
)

ttl_seconds_after_finished: int = Field(
default=100, description=describe_attr("ttl_seconds_after_finished", __doc__)
ttl_seconds_after_finished: int | None = Field(
default=None, description=describe_attr("ttl_seconds_after_finished", __doc__)
)

model_config = ConfigDict(extra="allow")

@field_validator("schedule")
@classmethod
def schedule_cron_validator(cls, schedule: str) -> str:
def schedule_cron_validator(cls, schedule: str | None) -> str | None:
"""Ensure that the defined schedule value is valid."""
if schedule and not croniter.is_valid(schedule):
msg = f"The schedule field '{schedule}' must be a valid cron expression."
Expand Down
Loading

0 comments on commit 884565e

Please sign in to comment.